def find_template_file(file_path):
    if not os.path.isabs(file_path):
        abs_file_name = mmutils.find_template_across_common_paths(file_path)
        if abs_file_name != '':
            file_path = abs_file_name
    if os.path.isfile(file_path):
        return file_path, True
    else:
        return file_path, False
예제 #2
0
def load_xml_from_file(file_path):
    plLogger = PLLogger.GetLogger('methodology')
    xml_str = None
    if not os.path.isabs(file_path):
        full_path = mm_utils.find_template_across_common_paths(file_path)
        if full_path != '':
            file_path = full_path
    if os.path.isfile(file_path):
        with open(file_path, "r") as f:
            xml_str = f.read()
    else:
        plLogger.LogError("ERROR: Failed to find file " +
                          file_path)
        return None
    return xml_str
def load_xmlroot_from_file(filename):
    # FIXME: This needs to move into an XML util file...
    plLogger = PLLogger.GetLogger("methodology")
    plLogger.LogDebug("begin.load_xmlroot_from_file.MethodologyGroupCommand")
    file_path = filename
    if not os.path.isabs(file_path):
        abs_file_name = mmutils.find_template_across_common_paths(file_path)
        if abs_file_name != '':
            file_path = abs_file_name

    if not os.path.isfile(file_path):
        plLogger.LogError("ERROR: Failed to find file '" + filename + "'")
        return None

    # return etree.parse(file_path)
    with open(file_path) as f:
        return etree.fromstring(f.read())