Guest User

Untitled

a guest
Aug 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. class World(CSVFile):
  2. class_csv_guess = True
  3.  
  4. columns = ['id', 'continent', 'sub_id', 'sub_continent', 'country_id',
  5. 'iana_root_zone', 'country', 'region', 'county']
  6.  
  7. schema = {'id': Integer,
  8. 'continent': String,
  9. 'sub_id': Integer,
  10. 'sub_continent': String,
  11. 'country_id': Integer,
  12. 'iana_root_zone': String,
  13. 'country': String,
  14. 'region': Unicode,
  15. 'county': Unicode}
  16.  
  17.  
  18. class ImportCountries(STLForm):
  19. access = 'is_admin'
  20. title = MSG(u'Import countries')
  21. template = '/ui/abakuc/import.xml'
  22.  
  23. def action(self, resource, context, form):
  24.  
  25. country_class_id = 'country'
  26. rw_database = RWDatabase()
  27. csv = rw_database.get_handler(get_abspath('/Users/khinester/lib/python2.6/site-packages/abakuc/data/countries_austria_full.csv'), World)
  28. rows = csv.get_rows()
  29. list_countries = set()
  30. # List countries and its regions
  31. for row in rows:
  32. country = row.get_value('country')
  33. iana_root_zone = row.get_value('iana_root_zone')
  34. name = checkid(country)
  35. list_countries.add((name, country, iana_root_zone))
  36. list_countries = sorted(list_countries)
  37. from country import Country
  38. for x in list_countries[233:235]:
  39. hosts = []
  40. hosts.append('%s.destinationsguide.info' % x[2])
  41. hosts.append('%s.destinationsguide.info' % x[0])
  42. title = u'%s' % x[1]
  43. country = resource.make_resource(x[0],
  44. Country,
  45. title={'en': title},
  46. website_is_open='community',
  47. website_languages=('en', 'fr'),
  48. vhosts=hosts,
  49. description={'en':u'Country description'},
  50. )
Add Comment
Please, Sign In to add comment