parser.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """
  2. This class refactors the default parsing class (better & streamlined implementation)
  3. """
  4. from multiprocessing import Process, RLock
  5. import os
  6. import json
  7. class parser (Process) :
  8. _CONFIGURATION = {}
  9. def __init__(self,path=None) :
  10. if not parser._CONFIGURATION :
  11. _path = path if path else os.sep.join([os.environ['HOME'],'.healthcareio/config.json'])
  12. #
  13. # @TODO: Load custom configuration just in case we need to do further processing
  14. config = json.loads(open(path).read())
  15. parser._CONFIGURATION = config['parser']
  16. #
  17. # do we have a custom configuration in this location
  18. #
  19. _custompath = _path.replace('config.json','')
  20. _custompath = _custompath if not _custompath.endswith(os.sep) else _custompath[:-1]
  21. _custompath = os.sep.join([_custompath,'custom'])
  22. if os.exists(_custompath) :
  23. files = os.listdir(_custompath)
  24. if files :
  25. _filename = os.sep.join([_custompath,files[0]])
  26. _customconf = json.loads(open(_filename).read())
  27. #
  28. # merge with existing configuration
  29. else:
  30. pass
  31. #
  32. #
  33. class getter :
  34. def value(self,) :
  35. pass
  36. class setter :
  37. def files(self,files):
  38. pass