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

Side by Side Diff: chrome/test/data/autofill/merge/tools/reserialize_profiles_from_query.py

Issue 8680018: Fix python scripts in src/chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 4 # found in the LICENSE file.
4 5
5 import sys 6 import sys
6 7
7 from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType 8 from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType
8 9
10
9 def main(): 11 def main():
10 """Serializes the output of the query 'SELECT * from autofill_profiles;'. 12 """Serializes the output of the query 'SELECT * from autofill_profiles;'.
11
12 """ 13 """
13 14
14 COLUMNS = ['GUID', 'LABEL', 'FIRST_NAME', 'MIDDLE_NAME', 'LAST_NAME', 'EMAIL', 15 COLUMNS = ['GUID', 'LABEL', 'FIRST_NAME', 'MIDDLE_NAME', 'LAST_NAME', 'EMAIL',
15 'COMPANY_NAME', 'ADDRESS_LINE_1', 'ADDRESS_LINE_2', 'CITY', 16 'COMPANY_NAME', 'ADDRESS_LINE_1', 'ADDRESS_LINE_2', 'CITY',
16 'STATE', 'ZIPCODE', 'COUNTRY', 'PHONE', 'DATE_MODIFIED'] 17 'STATE', 'ZIPCODE', 'COUNTRY', 'PHONE', 'DATE_MODIFIED']
17 18
18 if len(sys.argv) != 2: 19 if len(sys.argv) != 2:
19 print ("Usage: python reserialize_profiles_from_query.py " 20 print ("Usage: python reserialize_profiles_from_query.py "
20 "<path/to/serialized_profiles>") 21 "<path/to/serialized_profiles>")
21 return 22 return
22 23
23 types = [ColumnNameToFieldType(column_name) for column_name in COLUMNS] 24 types = [ColumnNameToFieldType(column_name) for column_name in COLUMNS]
24 profiles = [] 25 profiles = []
25 with open(sys.argv[1], 'r') as serialized_profiles: 26 with open(sys.argv[1], 'r') as serialized_profiles:
26 for line in serialized_profiles: 27 for line in serialized_profiles:
27 # trim the newline if present 28 # trim the newline if present
28 if line[-1] == '\n': 29 if line[-1] == '\n':
29 line = line[:-1] 30 line = line[:-1]
30 31
31 values = line.split("|") 32 values = line.split("|")
32 profiles.append(zip(types, values)) 33 profiles.append(zip(types, values))
33 34
34 print SerializeProfiles(profiles) 35 print SerializeProfiles(profiles)
36 return 0
35 37
36 38
37 if __name__ == '__main__': 39 if __name__ == '__main__':
38 main() 40 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/test/data/autofill/merge/tools/flatten.py ('k') | chrome/test/data/autofill/merge/tools/serialize_profiles.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698