MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / ModuleStubsGenerator

Class ModuleStubsGenerator

build_scripts/pybind11_stubgen.py:888–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

886
887
888class ModuleStubsGenerator(StubsGenerator):
889 CLASS_NAME_BLACKLIST = ClassStubsGenerator.CLASS_NAME_BLACKLIST
890 ATTRIBUTES_BLACKLIST = (
891 "__file__",
892 "__loader__",
893 "__name__",
894 "__package__",
895 "__spec__",
896 "__path__",
897 "__cached__",
898 "__builtins__",
899 )
900
901 def __init__(
902 self,
903 module_or_module_name,
904 attributes_blacklist=ATTRIBUTES_BLACKLIST,
905 class_name_blacklist=CLASS_NAME_BLACKLIST,
906 ):
907 if isinstance(module_or_module_name, str):
908 self.module = importlib.import_module(module_or_module_name)
909 else:
910 self.module = module_or_module_name
911 assert inspect.ismodule(self.module)
912
913 self.doc_string = None # type: Optional[str]
914 self.classes = [] # type: List[ClassStubsGenerator]
915 self.free_functions = [] # type: List[FreeFunctionStubsGenerator]
916 self.submodules = [] # type: List[ModuleStubsGenerator]
917 self.imported_modules = [] # type: List[str]
918 self.imported_classes = {} # type: Dict[str, type]
919 self.attributes = [] # type: List[AttributeStubsGenerator]
920 self.alias = []
921 self.stub_suffix = ""
922 self.write_setup_py = False
923
924 self.attributes_blacklist = attributes_blacklist
925 self.class_name_blacklist = class_name_blacklist
926
927 def parse(self):
928 if self.module in _visited_objects:
929 return
930 _visited_objects.append(self.module)
931 logger.debug("Parsing '%s' module" % self.module.__name__)
932 for name, member in inspect.getmembers(self.module):
933 if (inspect.isfunction(member) or inspect.isclass(member)) and name != member.__name__:
934 self.alias.append(AliasStubsGenerator(name, member))
935 elif inspect.ismodule(member):
936 m = ModuleStubsGenerator(member)
937 if m.module.__name__.split(".")[:-1] == self.module.__name__.split("."):
938 self.submodules.append(m)
939 else:
940 self.imported_modules += [m.module.__name__]
941 logger.debug(
942 "Skip '%s' module while parsing '%s' "
943 % (m.module.__name__, self.module.__name__)
944 )
945 elif inspect.isbuiltin(member) or inspect.isfunction(member):

Callers 2

parseMethod · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected