__init__.py 785 B

1234567891011121314151617181920212223242526272829
  1. import json
  2. from pathlib import Path
  3. __init__ = ['ENGINES_LANGUGAGES', 'CURRENCIES', 'USER_AGENTS', 'EXTERNAL_URLS', 'WIKIDATA_UNITS',
  4. 'bangs_loader', 'ahmia_blacklist_loader']
  5. data_dir = Path(__file__).parent
  6. def load(filename):
  7. # add str(...) for Python 3.5
  8. with open(str(data_dir / filename), encoding='utf-8') as fd:
  9. return json.load(fd)
  10. def bangs_loader():
  11. return load('bangs.json')
  12. def ahmia_blacklist_loader():
  13. with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as fd:
  14. return fd.read().split()
  15. ENGINES_LANGUAGES = load('engines_languages.json')
  16. CURRENCIES = load('currencies.json')
  17. USER_AGENTS = load('useragents.json')
  18. EXTERNAL_URLS = load('external_urls.json')
  19. WIKIDATA_UNITS = load('wikidata_units.json')