def process_elements(element_list): if element_list is None: return True global verbose global force global schema_path file_list = [] for element in element_list: ovalid = element.get("id") filepath = lib_repo.get_element_repository_path(element) if not filepath or filepath is None: if verbose: print( " ### Unable to determine repository location for '{0}'". format(ovalid)) return False if os.path.isfile(filepath): if verbose: print( " ++ Element '{0}' already exists. Checking for changes..." .format(ovalid)) original = lib_xml.load_standalone_element(filepath) if original is not None: changes = lib_xml.get_element_change_status(element, original) if changes == 2: print(" +++ Changes found: updating") else: if verbose: print(" +++ No meaningful changes: skipping". format(ovalid)) continue elif verbose: print( " ++++ New element '{0}':\n ---> adding to repository as '{1}" .format(ovalid, filepath)) #Write the element to its own file file_list.append(filepath) save_element(element, filepath) print("\n +++ Files added or updated by this submission:") for file in file_list: print(" ---> {0}".format(file)) return True
def process_elements(element_list): if element_list is None: return True global verbose global force global schema_path file_list = [] for element in element_list: ovalid = element.get("id") filepath = lib_repo.get_element_repository_path(element) if not filepath or filepath is None: if verbose: print(" ### Unable to determine repository location for '{0}'".format(ovalid)) return False if os.path.isfile(filepath): if verbose: print(" ++ Element '{0}' already exists. Checking for changes...".format(ovalid)) original = lib_xml.load_standalone_element(filepath) if original is not None: changes = lib_xml.get_element_change_status(element, original) if changes == 2: print(" +++ Changes found: updating") else: if verbose: print(" +++ No meaningful changes: skipping".format(ovalid)) continue elif verbose: print(" ++++ New element '{0}':\n ---> adding to repository as '{1}".format(ovalid, filepath)) #Write the element to its own file file_list.append(filepath) save_element(element, filepath) print("\n +++ Files added or updated by this submission:") for file in file_list: print(" ---> {0}".format(file)) return True
def main(): print("\n--- Starting tests...\n") tree = etree.parse('change_tests.xml') if tree is None: print("ERROR", "Unable to parse test definition file into XML") return root = tree.getroot() if root is None: print("ERROR", "Could not locate document root") return test_cases = list(root) for element in test_cases: # Get the corresponding element from the repository ovalid = element.get('id') path = lib_repo.get_element_repository_path(element) existing = lib_xml.load_standalone_element(path) status = lib_xml.get_element_change_status(element, existing) print(" ++ Status for element {0} = {1}".format(ovalid, status))