Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Side by Side Diff: components/test/data/autofill/merge/tools/autofill_merge_common.py

Issue 2110563002: Use AutofillProfileComparator in place of ad-hoc merge logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge
Patch Set: Rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/test/data/autofill/merge/output/validation.out ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 5
6 class UnknownColumnNameException(Exception): 6 class UnknownColumnNameException(Exception):
7 """Exception type raised when encountering an unknown column name.""" 7 """Exception type raised when encountering an unknown column name."""
8 def __init__(self, column_name): 8 def __init__(self, column_name):
9 self.column_name = column_name 9 self.column_name = column_name
10 def __str__(self): 10 def __str__(self):
11 return repr(self.column_name) 11 return repr(self.column_name)
12 12
13 13
14 def SerializeProfiles(profiles): 14 def SerializeProfiles(profiles):
15 """Returns a serialized string for the given |profiles|. 15 """Returns a serialized string for the given |profiles|.
16 16
17 |profiles| should be a list of (field_type, value) string pairs. 17 |profiles| should be a list of (field_type, value) string pairs.
18 18
19 """ 19 """
20 20
21 lines = [] 21 lines = []
22 for profile in profiles: 22 for profile in profiles:
23 # Include a fixed string to separate profiles. 23 # Include a fixed string to separate profiles.
24 lines.append("---") 24 lines.append("---")
25 for (field_type, value) in profile: 25 for (field_type, value) in profile:
26 if field_type == "ignored": 26 if field_type == "ignored":
27 continue; 27 continue;
28 28
29 lines.append("%s: %s" % (field_type, value)) 29 lines.append("%s:%s%s" % (field_type, (' ' if value else ''), value))
30 30
31 return '\n'.join(lines) 31 return '\n'.join(lines)
32 32
33 33
34 def ColumnNameToFieldType(column_name): 34 def ColumnNameToFieldType(column_name):
35 """Converts the given |column_name| to the corresponding AutofillField type. 35 """Converts the given |column_name| to the corresponding AutofillField type.
36 36
37 |column_name| should be a string drawn from the column names of the 37 |column_name| should be a string drawn from the column names of the
38 autofill_profiles table in the Chromium "Web Data" database. 38 autofill_profiles table in the Chromium "Web Data" database.
39 39
(...skipping 30 matching lines...) Expand all
70 elif column_name == "zipcode": 70 elif column_name == "zipcode":
71 field_type = "ADDRESS_HOME_ZIP" 71 field_type = "ADDRESS_HOME_ZIP"
72 elif column_name == "country_code": 72 elif column_name == "country_code":
73 field_type = "ADDRESS_HOME_COUNTRY" 73 field_type = "ADDRESS_HOME_COUNTRY"
74 elif column_name == "phone": 74 elif column_name == "phone":
75 field_type = "PHONE_HOME_WHOLE_NUMBER" 75 field_type = "PHONE_HOME_WHOLE_NUMBER"
76 else: 76 else:
77 raise UnknownColumnNameException(column_name) 77 raise UnknownColumnNameException(column_name)
78 78
79 return field_type 79 return field_type
OLDNEW
« no previous file with comments | « components/test/data/autofill/merge/output/validation.out ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698