MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / parse_multiple_files

Method parse_multiple_files

tools/PythonExtensionChecker.py:746–790  ·  view source on GitHub ↗
(pxdfiles, comp_name)

Source from the content-addressed store, hash-verified

744
745 @staticmethod
746 def parse_multiple_files(pxdfiles, comp_name):
747
748 def cimport(b, _, __):
749 print ("cimport", b.module_name, "as", b.as_name)
750
751 handlers = { CEnumDefNode : EnumDecl.parseTree,
752 CppClassNode : CppClassDecl.parseTree,
753 CTypeDefNode : CTypeDefDecl.parseTree,
754 CVarDefNode : MethodOrAttributeDecl.parseTree,
755 CImportStatNode : cimport,
756 }
757
758 found = False
759 # Go through all files and all classes in those files, trying to find
760 # the class whose C/C++ name matches the current compound name
761 for pxdfile in pxdfiles:
762 cython_file = parse_pxd_file(pxdfile)
763 for klass in cython_file:
764 if hasattr(klass[0], "cname"):
765 if klass[0].cname == comp_name:
766 found = True
767 if found: break
768 if found: break
769
770 if not found:
771 error_str = "Could not find a match for class %s in file %s" % (comp_name, pxdfile)
772 raise PXDFileParseError(error_str)
773
774 # Check if we really have a class, then initialize it
775 if isinstance(klass[0], CppClassNode):
776 cl = CppClassDecl.parseTree(klass[0], klass[1], klass[2])
777 else:
778 print ("Something is wrong, not a class")
779 raise PXDFileParseError("wrong")
780
781 cl.pxdfile = pxdfile
782 for klass in cython_file:
783 handler = handlers.get(type(klass[0]))
784 res = handler(klass[0], klass[1], klass[2])
785 if "wrap-attach" in res.annotations:
786 if res.annotations["wrap-attach"] == cl.name:
787 ## attach this to the above class
788 cl.methods[res.name] = res
789
790 return cl
791
792class TestResult:
793 """ A Result from a single test which either passed or failed.

Callers 1

checkPythonPxdHeaderFunction · 0.80

Calls 4

parse_pxd_fileFunction · 0.90
PXDFileParseErrorClass · 0.85
typeEnum · 0.50
getMethod · 0.45

Tested by

no test coverage detected