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

Class Dictionary

aura/analyzers/python/nodes.py:362–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360
361@dataclass
362class Dictionary(ASTNode): # TODO: implement methods from ASTNode
363 keys: list
364 values: list
365
366 def _visit_node(self, context):
367 for idx, key in enumerate(self.keys):
368 context.visit_child(
369 node=key,
370 replace=partial(self.__replace_key, idx=idx, visitor=context.visitor),
371 )
372
373 for idx, value in enumerate(self.values):
374 if isinstance(value, str) and value in context.stack:
375 value = context.stack[value]
376 self.values[idx] = value
377
378 context.visit_child(
379 node=value,
380 replace=partial(self.__replace_value, idx=idx, visitor=context.visitor),
381 )
382
383 def __replace_key(self, value, idx, visitor):
384 visitor.modified = True
385 self.keys[idx] = value
386
387 def __replace_value(self, value, idx, visitor):
388 visitor.modified = True
389 self.values[idx] = value
390
391 @property
392 def json(self):
393 d = super().json
394 d["items"] = list(zip(self.keys, self.values))
395 return d
396
397 def to_dict(self):
398 return dict(zip(self.keys, self.values))
399
400 def __str__(self):
401 return str(self.to_dict())
402
403
404@dataclass

Callers 1

visit_DictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected