diff --git a/lib/aslint/python/diagr_import.py b/lib/aslint/python/diagr_import.py index 0ca4cf8128e08cf8656cf95788114bdfa2840de6..d4c6904d715793ee67aaa528cfff133e4959dba0 100755 --- a/lib/aslint/python/diagr_import.py +++ b/lib/aslint/python/diagr_import.py @@ -15,9 +15,9 @@ from subprocess import Popen BIBPYT = """ -aster_pkginfo aster_settings -Calc_essai Cata_Utils Comportement Contrib Internal Mac3coeur Macro Messages -Miss Modal SD Templates Utilitai +Applications Cata Coupling LinearAlgebra Objects SD Utilities +Behaviours CodeCommands Helpers MacroCommands ObjectsExt Solvers +CA Commands Messages Supervis """.split() ASTERPKG = """ @@ -41,6 +41,7 @@ def file2module(filename): # name = re.sub("^%s" % re.escape(prefix + "."), "", name) return name.strip().strip(".") + def is_generated(path): """Tell if a filename will be generated during build phase and not yet exists. @@ -77,7 +78,8 @@ class Module: mod = module.split(".") mod = mod[:-1] if mod[-1] == "*" else mod if mod[0] in BIBPYT: - mod.insert(0, "bibpyt") + mod.insert(0, "code_aster") + raise ValueError(f"{self.name}: {module}") # is pkg1.pkg2.object? path = osp.join(*mod) if not (osp.isdir(path) or osp.isfile(path + ".py")) and len(mod) > 1: @@ -96,10 +98,8 @@ class Module: """Tell if it's a pure module (a file).""" path = osp.join(*module.split(".")) fname = path + ".py" - if not (osp.isdir(path) or osp.isfile(fname) or is_generated(path) - or path in ASTERPKG): - raise IOError("no such file or directory: {0} (from {1})" - .format(path, self.name)) + if not (osp.isdir(path) or osp.isfile(fname) or is_generated(path) or path in ASTERPKG): + raise IOError("no such file or directory: {0} (from {1})".format(path, self.name)) return osp.isfile(fname) def group(self, module): @@ -122,10 +122,13 @@ class Module: raise SyntaxError(exc) for mod in imp: mod0 = mod.split(".")[0] - if mod0 in ("code_aster", "bibpyt") or mod0 in NOSTD: + if mod0 in NOSTD: mod = self.abs_path(mod) if self.pkg_only: - mod = self.parent_pkg(mod) + parent = self.parent_pkg(mod) + if parent == "code_aster": + print("Warning:", self.name, "::", mod, "-->", parent) + mod = parent mod = self.group(mod) self.mods.append(mod) else: @@ -220,6 +223,7 @@ def plot(imports, filename): imports (dict): Dict of imports. filename (str): Output filename. """ + def _label(mod): key = mod.replace(".", "_X_") if key[0].isdigit(): @@ -235,8 +239,7 @@ def plot(imports, filename): edges.append(" {0} -> {1};".format(labels[src], labels[mod])) lines = ["digraph G {"] - lines.extend([""" {1} [label="{0}"];""".format(i, j) - for i, j in labels.items()]) + lines.extend([""" {1} [label="{0}"];""".format(i, j) for i, j in labels.items()]) lines.extend(edges) lines.append("}") @@ -256,24 +259,26 @@ def plot(imports, filename): def main(): # command arguments parser parser = argparse.ArgumentParser( - usage=__doc__, - formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument('-v', dest='verb', action='store_true', default=False, - help="add comments") - parser.add_argument('-s', dest='std', action='store_true', default=False, - help="show standard (and external) modules") - parser.add_argument('-p', '--pkg', action='store_true', default=False, - help="keep packages only") - parser.add_argument('--grp', action='store_true', default=False, - help="group sub-packages") - parser.add_argument('-g', '--graph', action='store', - help="create a dot graph") - parser.add_argument('files', nargs="*", - help="file names") + usage=__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter + ) + parser.add_argument("-v", dest="verb", action="store_true", default=False, help="add comments") + parser.add_argument( + "-s", + dest="std", + action="store_true", + default=False, + help="show standard (and external) modules", + ) + parser.add_argument( + "-p", "--pkg", action="store_true", default=False, help="keep packages only" + ) + parser.add_argument("--grp", action="store_true", default=False, help="group sub-packages") + parser.add_argument("-g", "--graph", action="store", help="create a dot graph") + parser.add_argument("files", nargs="*", help="file names") args = parser.parse_args() if len(args.files) == 0: - parser.error('files ?') + parser.error("files ?") imports = get_all_imports(**(args.__dict__)) if not args.graph: @@ -284,6 +289,6 @@ def main(): plot(imports, args.graph) -if __name__ == '__main__': - # m = Module("bibpyt/Comportement/zirc.py") +if __name__ == "__main__": + # m = Module("code_aster/Behaviours/zirc.py") main() diff --git a/lib/aslint/python/python_checkers.py b/lib/aslint/python/python_checkers.py index 50e1b9f3eb372a3183227385a0d11f5753523c29..8d7a8304e834e14a194f654ef5e83955bc5a22cd 100644 --- a/lib/aslint/python/python_checkers.py +++ b/lib/aslint/python/python_checkers.py @@ -24,7 +24,6 @@ from .python_tools import get_masked_imports class LineTooLong(FileContentCat, COMM.LineTooLong): - """Line too long Lines must not be too long for readability and convention. Maximum line length is 80 columns in python @@ -35,7 +34,6 @@ class LineTooLong(FileContentCat, COMM.LineTooLong): class LicenseNotFound(FileContentCat, COMM.LicenseNotFound): - """Summary with GPL is required The copyright and GPL summary are required. Even if there is an external copyright, it must mention www.code-aster.org @@ -46,28 +44,25 @@ class LicenseNotFound(FileContentCat, COMM.LicenseNotFound): class EDFCopyright(FileContentCat, COMM.EDFCopyright): - """EDF R&D Copyright not found Even if there is a copyright to another company than EDF R&D, the source has been changed for Code_Aster conformance and/or version management. Example: - Copyright 2008 Company ABC - - Copyright 2008-2024 EDF R&D www.code-aster.org + - Copyright 2008-2025 EDF R&D www.code-aster.org """ id = "C4003" class ExternalCopyright(FileContentCat, COMM.ExternalCopyright): - """Another Copyright than EDF""" id = "W4004" class EncodingDeclNotFound(FileContentCat, COMM.EncodingDeclNotFound): - """Encoding definition is required in the first or second line Conforming to PEP0263, the encoding of the source file must be defined by placing a magic comment as first or second line of the file @@ -79,11 +74,11 @@ class EncodingDeclNotFound(FileContentCat, COMM.EncodingDeclNotFound): class InvalidCharacter(FileContentCat, COMM.InvalidCharacter): r"""Invalid character, unexpected tabulation '\t' Tabulation character is not allowed.""" + id = "C4006" class ExecUsed(FileContentCat, TextMsg): - """Using 'exec()' is discouraged""" id = "C4007" @@ -91,7 +86,6 @@ class ExecUsed(FileContentCat, TextMsg): class TopLevelImport(FileContentCat, GenericMsg): - """Imports should always be written at the top of the file, after any module comments and docstrings.""" @@ -196,6 +190,13 @@ class ObsoletePath(FilenameCat, GenericMsg): return err +class ObsoleteSdj(FileContentCat, TextMsg): + """Obsolete use of '.sdj.XXX'""" + + id = "C4014" + search = search_msg(r"(?P<main>\w+\.sdj(?:\.\w+)?)", ignore_case=False) + + class ReformatSource(FilenameCat, COMM.ReformatPy): """Reformat Python source""" diff --git a/lib/hgaster/maintenance.py b/lib/hgaster/maintenance.py index 11e5efaf1153ae536df1d5d718834a3f27fe298b..bcc89017f365780765932d2f57f8caa453b2499c 100644 --- a/lib/hgaster/maintenance.py +++ b/lib/hgaster/maintenance.py @@ -542,6 +542,7 @@ class BaseMaintenance(object): logger.stop_important() add_restart = getattr(self.opts, "add_restart", False) no_retry = getattr(self.opts, "no_retry", False) + errcode, result = run_testcase( params, is_success=is_success, @@ -550,7 +551,7 @@ class BaseMaintenance(object): no_retry=no_retry, resu_init=prev, ) - logger.debug("TestResult summary:".format(result.repr())) + logger.debug("TestResult summary: {}".format(result.repr())) list_err = result.get_error() if use_tmp: clean_dir(resudir)