Mercurial > repos > metexplore > met4j
view findToolsWithoutTests.py @ 10:6a112eaf8f38 draft
planemo upload for repository https://forgemia.inra.fr/metexplore/met4j-galaxy commit 71071300dd662ad01bd064abcf6866a192eeea95
| author | metexplore |
|---|---|
| date | Mon, 03 Feb 2025 15:59:46 +0000 |
| parents | 7a6f2380fc1d |
| children |
line wrap: on
line source
import os import xml.etree.ElementTree as ET def find_xml_files_without_tests(directory): for filename in os.listdir(directory): filepath = os.path.join(directory, filename) if os.path.isdir(filepath): # Récursivement, recherche dans les sous-répertoires yield from find_xml_files_without_tests(filepath) elif filename.endswith(".xml"): # Traitement du fichier XML tree = ET.parse(filepath) root = tree.getroot() tool_elements = root.findall(".//tool") tests_elements = root.findall(".//tests") if tool_elements and not tests_elements: yield filepath elif tests_elements: # On vérifie qu'il n'y a rien à l'intérieur de <tests> tests_children = list(tests_elements[0]) if len(tests_children) == 0: yield filepath if __name__ == "__main__": import argparse parser = argparse.ArgumentParser(description="Trouve les fichiers XML sans élément <tests>") parser.add_argument("directory", metavar="DIRECTORY", type=str, help="Le répertoire à explorer") args = parser.parse_args() for filepath in find_xml_files_without_tests(args.directory): print(filepath)
