From e75965fad279b615db13492cd86e8b077f5cf6e4 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 13 Sep 2021 11:26:38 +0200 Subject: [PATCH] do not allow empty XML directory --- src/rougail/xmlreflector.py | 2 ++ tests/dictionaries/80empty_dir/__init__.py | 0 tests/dictionaries/80empty_dir/errno_77 | 0 tests/test_upgrade.py | 2 +- 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/dictionaries/80empty_dir/__init__.py create mode 100644 tests/dictionaries/80empty_dir/errno_77 diff --git a/src/rougail/xmlreflector.py b/src/rougail/xmlreflector.py index 48bf50bb..19e7831d 100644 --- a/src/rougail/xmlreflector.py +++ b/src/rougail/xmlreflector.py @@ -65,6 +65,8 @@ class XMLReflector: filenames = [join(xmlfolder, filename) for filename in listdir(xmlfolder) if \ filename.endswith('.xml')] filenames.sort() + if not filenames: + raise DictConsistencyError(_('there is no XML file'), 77, [xmlfolder]) for xmlfile in filenames: try: document = parse(xmlfile) diff --git a/tests/dictionaries/80empty_dir/__init__.py b/tests/dictionaries/80empty_dir/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/80empty_dir/errno_77 b/tests/dictionaries/80empty_dir/errno_77 new file mode 100644 index 00000000..e69de29b diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py index 629261bc..5cd5aa11 100644 --- a/tests/test_upgrade.py +++ b/tests/test_upgrade.py @@ -54,7 +54,7 @@ def launch_test(test_dir): except Exception as err: # import traceback # traceback.print_exc() - print(f'cannot convert {test_dir}: {err}') + # print(f'cannot convert {test_dir}: {err}') rmtree(new_dest_dir) copytree(test_dir, new_dest_dir) return