@@ -50,27 +50,15 @@ def unhead(string):
50
50
"ActionList" : lambda x : parselist (x ),
51
51
}
52
52
str2refgetpacker = {
53
- "default" : lambda x : ReferenceKey (
54
- unhead (x ["DesiredClass" ]), unhead (x ["Value" ])
55
- ),
53
+ "default" : lambda x : ReferenceKey (unhead (x ["DesiredClass" ]), unhead (x ["Value" ])),
56
54
"Enumerated" : lambda x : ReferenceKey (
57
55
unhead (x ["DesiredClass" ]),
58
- Enumerated (
59
- unhead (x ["Value" ]["enumtype" ]), unhead (x ["Value" ]["enumval" ])
60
- ), # noqa
61
- ),
62
- "Identifier" : lambda x : ReferenceKey (
63
- unhead (x ["DesiredClass" ]), Identifier + int (x ["Value" ])
64
- ),
65
- "Index" : lambda x : ReferenceKey (
66
- unhead (x ["DesiredClass" ]), Index + int (x ["Value" ])
67
- ),
68
- "Offset" : lambda x : ReferenceKey (
69
- unhead (x ["DesiredClass" ]), Offset + int (x ["Value" ])
70
- ),
71
- "Property" : lambda x : ReferenceKey (
72
- unhead (x ["DesiredClass" ]), toid (x ["Value" ])
56
+ Enumerated (unhead (x ["Value" ]["enumtype" ]), unhead (x ["Value" ]["enumval" ])), # noqa
73
57
),
58
+ "Identifier" : lambda x : ReferenceKey (unhead (x ["DesiredClass" ]), Identifier + int (x ["Value" ])),
59
+ "Index" : lambda x : ReferenceKey (unhead (x ["DesiredClass" ]), Index + int (x ["Value" ])),
60
+ "Offset" : lambda x : ReferenceKey (unhead (x ["DesiredClass" ]), Offset + int (x ["Value" ])),
61
+ "Property" : lambda x : ReferenceKey (unhead (x ["DesiredClass" ]), toid (x ["Value" ])),
74
62
}
75
63
76
64
@@ -79,19 +67,14 @@ def parsedict(tdict):
79
67
tdict ["_classID" ] = None
80
68
else :
81
69
tdict ["_classID" ] = unhead (tdict ["_classID" ])
82
- pdict = {
83
- unhead (k ): (str2getpacker [v ["type" ]](v ) if type (v ) == dict else v )
84
- for k , v in tdict .items ()
85
- }
70
+ pdict = {unhead (k ): (str2getpacker [v ["type" ]](v ) if type (v ) == dict else v ) for k , v in tdict .items ()}
86
71
del pdict ["type" ]
87
72
return pdict
88
73
89
74
90
75
def parselist (tdict ):
91
76
d2l = [tdict [str (i )] for i in range (tdict ["len" ])]
92
- plist = [
93
- (str2getpacker [e ["type" ]](e ) if type (e ) == dict else e ) for e in d2l
94
- ]
77
+ plist = [(str2getpacker [e ["type" ]](e ) if type (e ) == dict else e ) for e in d2l ]
95
78
return plist
96
79
97
80
@@ -101,17 +84,13 @@ def parseref(tdict):
101
84
# py37 compat
102
85
try :
103
86
exec (
104
- """ext = [(str2refgetpacker[val["type"]](e) """ +
105
- """if type(val := e["Value"]) == dict """ +
106
- """else str2refgetpacker["default"](e)) for e in d2l]"""
87
+ """ext = [(str2refgetpacker[val["type"]](e) """
88
+ + """if type(val := e["Value"]) == dict """
89
+ + """else str2refgetpacker["default"](e)) for e in d2l]"""
107
90
)
108
91
except SyntaxError :
109
92
ext = [
110
- (
111
- str2refgetpacker [e ["Value" ]["type" ]](e )
112
- if type (e ["Value" ]) == dict
113
- else str2refgetpacker ["default" ](e )
114
- )
93
+ (str2refgetpacker [e ["Value" ]["type" ]](e ) if type (e ["Value" ]) == dict else str2refgetpacker ["default" ](e ))
115
94
for e in d2l
116
95
]
117
96
plist .extend (ext )
@@ -120,11 +99,7 @@ def parseref(tdict):
120
99
121
100
def json2obj (jsont ):
122
101
obj_init = json .loads (jsont )
123
- obj_desc = (
124
- parsedict (obj_init ["ActionDescriptor" ])
125
- if "ActionDescriptor" in obj_init
126
- else None
127
- )
102
+ obj_desc = parsedict (obj_init ["ActionDescriptor" ]) if "ActionDescriptor" in obj_init else None
128
103
obj_operation = unhead (obj_init ["Operation" ])
129
104
obj_option = obj_init ["Option" ]
130
105
return (obj_operation , obj_desc , obj_option )
0 commit comments