Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

35 рядки
964 B

  1. # all country info
  2. from __future__ import unicode_literals
  3. import os, json, webnotes
  4. def get_country_info(country=None):
  5. data = get_all()
  6. data = webnotes._dict(data.get(country, {}))
  7. if not 'date_format' in data:
  8. data.date_format = "dd-mm-yyyy"
  9. return data
  10. @webnotes.whitelist()
  11. def get_all():
  12. with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "r") as local_info:
  13. all_data = json.loads(local_info.read())
  14. return all_data
  15. def update():
  16. with open(os.path.join(os.path.dirname(__file__), "currency_info.json"), "r") as nformats:
  17. nformats = json.loads(nformats.read())
  18. all_data = get_all()
  19. for country in all_data:
  20. data = all_data[country]
  21. data["number_format"] = nformats.get(data.get("currency", "default"),
  22. nformats.get("default"))["display"]
  23. print all_data
  24. with open(os.path.join(os.path.dirname(__file__), "country_info.json"), "w") as local_info:
  25. local_info.write(json.dumps(all_data, indent=1))