-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaps.py
More file actions
47 lines (33 loc) · 1 KB
/
maps.py
File metadata and controls
47 lines (33 loc) · 1 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
from enum import Enum
from collections import namedtuple
from collections.abc import Iterable
class SwiftType(Enum):
integer = 'Int'
string = 'String'
object = 'Any'
array = 'Array'
boolean = 'Bool'
number = 'Double'
def is_array(self) -> boolean:
return self is SwiftType.array
def is_object(self) -> boolean:
return self is SwiftType.object
class KotlinType(Enum):
integer = 'Long'
string = 'String'
object = 'Any'
array = 'Array'
boolean = 'Boolean'
number = 'Double'
def is_array(self) -> boolean:
return self == KotlinType.array
def is_object(self) -> boolean:
return self is KotlinType.object
JsonBagStruct = namedtuple('JsonBagStruct', ('code', 'msg', 'data'))
JsonPath = JsonBagStruct(code=('code',), msg=('msg',), data=('data',))
ArrayDataPath = ('data',)
def find_value(content: dict, keys: Iterable):
for key in keys:
if value := content.get(key, None):
return value
return None