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

Side by Side Diff: chrome/test/data/autofill/merge/tools/serialize_profiles.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 os.path 6 import os.path
6 import sqlite3 7 import sqlite3
7 import sys 8 import sys
8 9
9 from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType 10 from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType
10 11
12
11 def main(): 13 def main():
12 """Serializes the autofill_profiles table from the specified database.""" 14 """Serializes the autofill_profiles table from the specified database."""
13 15
14 if len(sys.argv) != 2: 16 if len(sys.argv) != 2:
15 print "Usage: python serialize_profiles.py <path/to/database>" 17 print "Usage: python serialize_profiles.py <path/to/database>"
16 return 18 return 1
17 19
18 database = sys.argv[1] 20 database = sys.argv[1]
19 if not os.path.isfile(database): 21 if not os.path.isfile(database):
20 print "Cannot read database at \"%s\"" % database 22 print "Cannot read database at \"%s\"" % database
21 return 23 return 1
22 24
23 # Read the autofill_profile_names table. 25 # Read the autofill_profile_names table.
24 try: 26 try:
25 connection = sqlite3.connect(database, 0) 27 connection = sqlite3.connect(database, 0)
26 cursor = connection.cursor() 28 cursor = connection.cursor()
27 cursor.execute("SELECT * from autofill_profile_names;") 29 cursor.execute("SELECT * from autofill_profile_names;")
28 except sqlite3.OperationalError: 30 except sqlite3.OperationalError:
29 print ("Failed to read the autofill_profile_names table from \"%s\"" % 31 print ("Failed to read the autofill_profile_names table from \"%s\"" %
30 database) 32 database)
31 raise 33 raise
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 except sqlite3.OperationalError: 72 except sqlite3.OperationalError:
71 print ("Failed to read the autofill_profile_phones table from \"%s\"" % 73 print ("Failed to read the autofill_profile_phones table from \"%s\"" %
72 database) 74 database)
73 raise 75 raise
74 76
75 for profile in cursor: 77 for profile in cursor:
76 guid = profile[0] 78 guid = profile[0]
77 profiles[guid].append(("PHONE_HOME_WHOLE_NUMBER", profile[2])) 79 profiles[guid].append(("PHONE_HOME_WHOLE_NUMBER", profile[2]))
78 80
79 print SerializeProfiles(profiles.values()) 81 print SerializeProfiles(profiles.values())
82 return 0
80 83
81 84
82 if __name__ == '__main__': 85 if __name__ == '__main__':
83 main() 86 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698