Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import os
  2. import json
  3. class PyCRCtrl(object):
  4. config = {}
  5. path = ""
  6. def loadConfigFile(self):
  7. if self.path == None:
  8. return False
  9.  
  10. self.config = json.load(open(os.path.join(self.path, "pycrctrl.conf"),"r"))
  11. return True
  12.  
  13. def getConfigEntry(self, entry=""):
  14. if type(self.config) != dict:
  15. return
  16.  
  17. try:
  18. return self.config[entry]
  19. except KeyError:
  20. return
  21.  
  22. def setConfigEntry(self, entry="", value=None):
  23. if type(self.config) != dict:
  24. return
  25.  
  26. try:
  27. self.config[entry] = value
  28. finally:
  29. json.dump(self.config, open(os.path.join(self.path, "pycrctrl.conf"), "w"),indent=4)
  30.  
  31. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement