您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1234567891011121314151617181920212223242526272829303132333435363738
  1. class Base(object):
  2. def __init__(self, rag, res_dict):
  3. self.rag = rag
  4. for k, v in res_dict.items():
  5. if isinstance(v, dict):
  6. self.__dict__[k] = Base(rag, v)
  7. else:
  8. self.__dict__[k] = v
  9. def to_json(self):
  10. pr = {}
  11. for name in dir(self):
  12. value = getattr(self, name)
  13. if not name.startswith('__') and not callable(value) and name != "rag":
  14. if isinstance(value, Base):
  15. pr[name] = value.to_json()
  16. else:
  17. pr[name] = value
  18. return pr
  19. def post(self, path, json=None, stream=False, files=None):
  20. res = self.rag.post(path, json, stream=stream,files=files)
  21. return res
  22. def get(self, path, params=None):
  23. res = self.rag.get(path, params)
  24. return res
  25. def rm(self, path, json):
  26. res = self.rag.delete(path, json)
  27. return res
  28. def put(self,path, json):
  29. res = self.rag.put(path,json)
  30. return res
  31. def __str__(self):
  32. return str(self.to_json())