MCPcopy Index your code
hub / github.com/aboutcode-org/vulnerablecode / fromStandaloneFile

Method fromStandaloneFile

vulnerabilities/lib_oval.py:956–978  ·  view source on GitHub ↗

For a file that contains a single OVAL XML element as the root element, instantiate the appropriate OvalElement sublcass for that element @type path: string @param path: the path to the file @rtype OvalElement @return None on error, or an object of the appropriate Ov

(path)

Source from the content-addressed store, hash-verified

954
955 @staticmethod
956 def fromStandaloneFile(path):
957 """For a file that contains a single OVAL XML element as the root element, instantiate the appropriate OvalElement sublcass for that element
958 @type path: string
959 @param path: the path to the file
960
961 @rtype OvalElement
962 @return None on error, or an object of the appropriate OvalElement subclass
963 """
964
965 if not path or path is None:
966 return None
967
968 if not os.path.exists(path):
969 return None
970
971 try:
972 tree = ElementTree.ElementTree()
973 tree.parse(path)
974 root = tree.getroot()
975 return OvalElement.asOvalElement(root)
976
977 except Exception:
978 return None
979
980 @staticmethod
981 def getElementTypeFromOvalID(ovalid):

Callers

nothing calls this directly

Calls 2

asOvalElementMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected