1#!/usr/bin/env python 2# Copyright 2013 The Chromium Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import sys 7 8from autofill_merge_common import SerializeProfiles, ColumnNameToFieldType 9 10 11def main(): 12 """Serializes the output of the query 'SELECT * from autofill_profiles;'. 13 """ 14 15 COLUMNS = ['GUID', 'LABEL', 'FIRST_NAME', 'MIDDLE_NAME', 'LAST_NAME', 'EMAIL', 16 'COMPANY_NAME', 'ADDRESS_LINE_1', 'ADDRESS_LINE_2', 'CITY', 17 'STATE', 'ZIPCODE', 'COUNTRY', 'PHONE', 'DATE_MODIFIED'] 18 19 if len(sys.argv) != 2: 20 print ("Usage: python reserialize_profiles_from_query.py " 21 "<path/to/serialized_profiles>") 22 return 23 24 types = [ColumnNameToFieldType(column_name) for column_name in COLUMNS] 25 profiles = [] 26 with open(sys.argv[1], 'r') as serialized_profiles: 27 for line in serialized_profiles: 28 # trim the newline if present 29 if line[-1] == '\n': 30 line = line[:-1] 31 32 values = line.split("|") 33 profiles.append(zip(types, values)) 34 35 print SerializeProfiles(profiles) 36 return 0 37 38 39if __name__ == '__main__': 40 sys.exit(main()) 41