X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng_ivc%2Futils%2Futils.py;h=1660aba1383469d0f6d289aeab431dc87ceedea0;hb=816f8cc1d499bc6230da6037cea51bc116d63f50;hp=37e09e197226ec1b9c9abf9a5da5f17aaa60ae6a;hpb=35f846b1b372bdb69727c89a7d2c58b826d90250;p=deliverable%2Flttng-ivc.git diff --git a/lttng_ivc/utils/utils.py b/lttng_ivc/utils/utils.py index 37e09e1..1660aba 100644 --- a/lttng_ivc/utils/utils.py +++ b/lttng_ivc/utils/utils.py @@ -84,6 +84,31 @@ def find_dir(root, name): return abs_path +def find_file(root, name): + """ + Returns the absolute path or None. + """ + print(root) + print(name) + abs_path = None + for base, dirs, files in os.walk(root): + for tmp in files: + if tmp.endswith(name): + abs_path = os.path.abspath(os.path.join(base, tmp)) + print(abs_path) + return abs_path + + +def validate(xml_path, xsd_path): + + xmlschema_doc = etree.parse(xsd_path) + xmlschema = etree.XMLSchema(xmlschema_doc) + + xml_doc = etree.parse(xml_path) + result = xmlschema.validate(xml_doc) + + return result + def xpath_query(xml_file, xpath): """ Return a list of xml node corresponding to the xpath. The list can be of lenght