encoding.py 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. def checkTransformEncoding(encoding):
  2. # ENCODING
  3. # --------------------------------------------------
  4. # --------------------------------------------------
  5. # --------------------------------------------------
  6. if 'macLangID' not in encoding:
  7. raise ValueError(f"encoding.macLangID not found in the manifest. {checkDocMsg}")
  8. if 'msftLangID' not in encoding:
  9. raise ValueError(f"encoding.msftLangID not found in the manifest. {checkDocMsg}")
  10. if type(encoding['macLangID']) is not str:
  11. raise ValueError(f"encoding.macLangID is not formatted as a string. {checkDocMsg}")
  12. try:
  13. # try to convert to int
  14. encoding['macLangID'] = int(encoding['macLangID'])
  15. except ValueError:
  16. raise ValueError(f"encoding.macLangID is not a string that represents a valid integer. {checkDocMsg}")
  17. if type(encoding['msftLangID']) is not str:
  18. raise ValueError(f"encoding.msftLangID is not formatted as a string. {checkDocMsg}")
  19. try:
  20. # try to convert to int
  21. encoding['msftLangID'] = int(encoding['msftLangID'], 16)
  22. except ValueError:
  23. raise ValueError(f"encoding.msftLangID is not a string that represents a valid hexadecimal number. {checkDocMsg}")