MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _ClassFinder

Class _ClassFinder

tools/python-3.11.9-amd64/Lib/inspect.py:1020–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1018
1019
1020class _ClassFinder(ast.NodeVisitor):
1021
1022 def __init__(self, qualname):
1023 self.stack = []
1024 self.qualname = qualname
1025
1026 def visit_FunctionDef(self, node):
1027 self.stack.append(node.name)
1028 self.stack.append('<locals>')
1029 self.generic_visit(node)
1030 self.stack.pop()
1031 self.stack.pop()
1032
1033 visit_AsyncFunctionDef = visit_FunctionDef
1034
1035 def visit_ClassDef(self, node):
1036 self.stack.append(node.name)
1037 if self.qualname == '.'.join(self.stack):
1038 # Return the decorator for the class if present
1039 if node.decorator_list:
1040 line_number = node.decorator_list[0].lineno
1041 else:
1042 line_number = node.lineno
1043
1044 # decrement by one since lines starts with indexing by zero
1045 line_number -= 1
1046 raise ClassFoundException(line_number)
1047 self.generic_visit(node)
1048 self.stack.pop()
1049
1050
1051def findsource(object):

Callers 1

findsourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected