Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

45 righe
1.2 KiB

  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
  2. # MIT License. See license.txt
  3. # all country info
  4. from __future__ import unicode_literals
  5. import os, json, webnotes
  6. def get_country_info(country=None):
  7. data = get_all()
  8. data = webnotes._dict(data.get(country, {}))
  9. if not 'date_format' in data:
  10. data.date_format = "dd-mm-yyyy"
  11. return data
  12. def get_all():
  13. with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "r") as local_info:
  14. all_data = json.loads(local_info.read())
  15. return all_data
  16. @webnotes.whitelist()
  17. def get_country_timezone_info():
  18. import pytz
  19. return {
  20. "country_info": get_all(),
  21. "all_timezones": pytz.all_timezones
  22. }
  23. def update():
  24. with open(os.path.join(os.path.dirname(__file__), "currency_info.json"), "r") as nformats:
  25. nformats = json.loads(nformats.read())
  26. all_data = get_all()
  27. for country in all_data:
  28. data = all_data[country]
  29. data["number_format"] = nformats.get(data.get("currency", "default"),
  30. nformats.get("default"))["display"]
  31. print all_data
  32. with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "w") as local_info:
  33. local_info.write(json.dumps(all_data, indent=1))