MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / inline_decode

Method inline_decode

aura/analyzers/python/rewrite_ast.py:177–206  ·  view source on GitHub ↗
(self, context)

Source from the content-addressed store, hash-verified

175 pass
176
177 def inline_decode(self, context):
178 node = context.node
179 if not type(node) == Call:
180 return
181 elif not (
182 type(node.func) == Attribute
183 and type(node.func.source) in (String, Bytes)
184 and node.func.attr == "decode"
185 ):
186 return
187
188 elif not all(type(x) in (String, str) for x in node.args):
189 return
190
191 if len(node.args) > 0:
192 try:
193 _ = codecs.getdecoder(str(node.args[0]))
194 except LookupError:
195 return
196
197 args = list(map(str, node.args))
198
199 decoded = codecs.decode(bytes(node.func.source), *args)
200 if type(decoded) == str:
201 new_node = String(decoded)
202 else:
203 new_node = Bytes(decoded)
204
205 new_node.enrich_from_previous(node)
206 context.replace(new_node)
207
208 def rewrite_function_call(self, context):
209 if not isinstance(context.node, Call):

Callers

nothing calls this directly

Calls 3

StringClass · 0.85
BytesClass · 0.85
enrich_from_previousMethod · 0.80

Tested by

no test coverage detected