-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsdk.py
More file actions
58 lines (43 loc) · 1.3 KB
/
sdk.py
File metadata and controls
58 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import voxgig_struct
# class StructUtils:
# def __init__(self):
# for attr_name in dir(voxgig_struct):
# if not attr_name.startswith('_'):
# setattr(self, attr_name, getattr(voxgig_struct, attr_name))
class Context:
def __init__(self):
self.client = None
self.utility = None
self.meta = {}
class Utility:
def __init__(self, opts=None):
self._opts = opts
# self.struct = StructUtils()
self.struct = voxgig_struct.StructUtility()
def contextify(self, ctxmap):
ctx = Context()
meta = ctxmap.get('meta', {})
for k, v in meta.items():
ctx.meta[k] = v
return ctx
def check(self, ctx):
zed = 'ZED'
if self._opts is None:
zed += ''
else:
foo = self._opts.get('foo')
zed += '0' if foo is None else str(foo)
zed += '_'
zed += str(ctx.meta.get('bar'))
return {'zed': zed}
class SDK:
def __init__(self, opts=None):
self._opts = opts or {}
self._utility = Utility(opts)
@staticmethod
def test(opts=None):
return SDK(opts)
def tester(self, opts=None):
return SDK(self.opts if opts is None else opts)
def utility(self):
return self._utility