File indexing completed on 2025-02-16 12:52:10
0001 #!/usr/bin/env python 0002 # -*- coding: utf-8 -*- 0003 0004 import sqlite3 0005 0006 db = sqlite3.connect("data/citydb.sqlite") 0007 db.text_factory = str 0008 0009 cursor = db.cursor() 0010 0011 cursor.execute('''SELECT DISTINCT Name, Province, Country from city''') 0012 all_rows = cursor.fetchall() 0013 all_rows.sort() 0014 for row in all_rows: 0015 name = row[0] 0016 province = row[1] 0017 country = row[2] 0018 0019 if format(province) != '': 0020 place = "{0} {1}".format(province, country) 0021 else: 0022 place = country 0023 0024 print('xi18nc("City in {0}", "{1}")'.format(place, name)) 0025 0026 cursor.execute('''SELECT DISTINCT Province, Country from city''') 0027 all_rows = cursor.fetchall() 0028 all_rows.sort() 0029 for row in all_rows: 0030 province = row[0] 0031 country = row[1] 0032 0033 if format(province) != '': 0034 print('xi18nc("Region/state in {0}", "{1}")'.format(country, province)) 0035 0036 cursor.execute('''SELECT DISTINCT Country from city''') 0037 all_rows = cursor.fetchall() 0038 all_rows.sort() 0039 for row in all_rows: 0040 print('xi18nc("Country name", "{0}")'.format(row[0])) 0041 0042 db.close()