示例#1
0
 def __init__(self,
              path,
              cdstar_url=None,
              cdstar_user=None,
              cdstar_pwd=None):
     self.path = pathlib.Path(path)
     self.objects = {}
     if self.path.exists():
         if self.path.suffix.lower() == '.zip':
             with zipfile.ZipFile(str(self.path), 'r') as z:
                 for filename in z.namelist():
                     with z.open(filename) as f:
                         self.objects = {
                             i: Object.fromdict(i, d)
                             for i, d in json.loads(f.read().decode(
                                 'utf-8')).items()
                         }
                     break
         else:
             self.objects = {
                 i: Object.fromdict(i, d)
                 for i, d in load(self.path).items()
             }
     self.api = Cdstar(service_url=cdstar_url,
                       user=cdstar_user,
                       password=cdstar_pwd)
示例#2
0
 def __init__(self,
              path,
              cdstar_url=None,
              cdstar_user=None,
              cdstar_pwd=None):
     self.path = Path(path)
     if self.path.exists():
         self.objects = {
             i: Object.fromdict(i, d)
             for i, d in load(self.path).items()
         }
     else:
         self.objects = {}
     self.api = Cdstar(service_url=cdstar_url,
                       user=cdstar_user,
                       password=cdstar_pwd)
示例#3
0
def get_api():
    return Cdstar(service_url=SERVICE_URL, user=USER, password=PWD)