A simple Bible translation parser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bver.py 986B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import json
  2. def getTranslations():
  3. translations = {}
  4. with open('bible-translations.json', 'r') as file:
  5. translations = json.loads(file.read())
  6. return translations
  7. def parse(version_to_parse):
  8. version_to_parse = version_to_parse.lower()
  9. versions = getTranslations()
  10. data = {}
  11. for version in versions:
  12. if version['name'].lower() == version_to_parse or version['abbr'].lower() == version_to_parse:
  13. data = version
  14. else:
  15. for alias in version['aliases']:
  16. if alias.lower() == version_to_parse:
  17. data = version
  18. return data
  19. def getAll(field, value):
  20. versions = getTranslations()
  21. data = []
  22. for version in versions:
  23. try:
  24. if version[field].lower() == value.lower():
  25. data.append(version)
  26. except KeyError: # some translations don't have certain information, thus raising a KeyError
  27. continue
  28. return data