diff --git a/src/sinol_make/commands/export/__init__.py b/src/sinol_make/commands/export/__init__.py index 145ed1c1..af47a037 100644 --- a/src/sinol_make/commands/export/__init__.py +++ b/src/sinol_make/commands/export/__init__.py @@ -132,7 +132,7 @@ def run(self, args: argparse.Namespace): self.args = args self.task_id = package_util.get_task_id() - package_util.validate_files(self.task_id) + package_util.validate_test_names(self.task_id) with open(os.path.join(os.getcwd(), 'config.yml'), 'r') as config_file: config = yaml.load(config_file, Loader=yaml.FullLoader) diff --git a/src/sinol_make/commands/gen/__init__.py b/src/sinol_make/commands/gen/__init__.py index 665a038b..d0ca3a9c 100644 --- a/src/sinol_make/commands/gen/__init__.py +++ b/src/sinol_make/commands/gen/__init__.py @@ -93,7 +93,7 @@ def run(self, args: argparse.Namespace): self.args = args self.task_id = package_util.get_task_id() - package_util.validate_files(self.task_id) + package_util.validate_test_names(self.task_id) self.ingen = gen_util.get_ingen(self.task_id, args.ingen_path) print(util.info(f'Using ingen file {os.path.basename(self.ingen)}')) diff --git a/src/sinol_make/commands/inwer/__init__.py b/src/sinol_make/commands/inwer/__init__.py index 399147f9..41ace8f0 100644 --- a/src/sinol_make/commands/inwer/__init__.py +++ b/src/sinol_make/commands/inwer/__init__.py @@ -123,7 +123,7 @@ def run(self, args: argparse.Namespace): util.exit_if_not_package() self.task_id = package_util.get_task_id() - package_util.validate_files(self.task_id) + package_util.validate_test_names(self.task_id) self.inwer = inwer_util.get_inwer_path(self.task_id, args.inwer_path) if self.inwer is None: if args.inwer_path is None: diff --git a/src/sinol_make/commands/run/__init__.py b/src/sinol_make/commands/run/__init__.py index bed7cbb2..cac69de5 100644 --- a/src/sinol_make/commands/run/__init__.py +++ b/src/sinol_make/commands/run/__init__.py @@ -1105,7 +1105,7 @@ def run(self, args): util.exit_if_not_package() self.set_constants() - package_util.validate_files(self.ID) + package_util.validate_test_names(self.ID) self.args = args with open(os.path.join(os.getcwd(), "config.yml"), 'r') as config: try: diff --git a/src/sinol_make/helpers/package_util.py b/src/sinol_make/helpers/package_util.py index f632884c..0ee3556c 100644 --- a/src/sinol_make/helpers/package_util.py +++ b/src/sinol_make/helpers/package_util.py @@ -154,19 +154,14 @@ def get_memory_limit(test_path, config, lang, args=None): return _get_limit(LimitTypes.MEMORY_LIMIT, test_path, str_config, lang) -def validate_files(task_id): +def validate_test_names(task_id): """ Checks if all files in the package have valid names. """ - def get_invalid_files(path, *patterns): + def get_invalid_files(path, pattern): invalid_files = [] for file in glob.glob(os.path.join(os.getcwd(), path)): - invalid = True - for pattern in patterns: - if pattern.match(os.path.basename(file)): - invalid = False - break - if invalid: + if not pattern.match(os.path.basename(file)): invalid_files.append(os.path.basename(file)) return invalid_files diff --git a/tests/helpers/test_package_util.py b/tests/helpers/test_package_util.py index e02dc5e0..4e993442 100644 --- a/tests/helpers/test_package_util.py +++ b/tests/helpers/test_package_util.py @@ -187,17 +187,17 @@ def test_validate_files(create_package, capsys): util.create_ins_outs(package_path) task_id = package_util.get_task_id() assert task_id == "abc" - package_util.validate_files(task_id) + package_util.validate_test_names(task_id) os.rename(os.path.join(package_path, "in", "abc1a.in"), os.path.join(package_path, "in", "def1a.in")) with pytest.raises(SystemExit): - package_util.validate_files(task_id) + package_util.validate_test_names(task_id) out = capsys.readouterr().out assert "def1a.in" in out os.rename(os.path.join(package_path, "in", "def1a.in"), os.path.join(package_path, "in", "abc1a.in")) os.rename(os.path.join(package_path, "out", "abc1a.out"), os.path.join(package_path, "out", "def1a.out")) with pytest.raises(SystemExit): - package_util.validate_files(task_id) + package_util.validate_test_names(task_id) out = capsys.readouterr().out assert "def1a.out" in out