From 5c104b155f074a143f17c837817e79d1099ac2d7 Mon Sep 17 00:00:00 2001 From: Maximilien Rigaut Date: Wed, 15 Jun 2022 20:53:45 +0200 Subject: [PATCH] Hotfix:deploy --- .gitignore | 3 ++- README.md | 7 ++++--- src/bootstraparse/__main__.py | 3 ++- src/bootstraparse/configs/parser_config.yml | 2 +- src/bootstraparse/modules/config.py | 11 ++++++++--- tests/modules/test_config.py | 12 ++++++++---- 6 files changed, 25 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index fbe5e12..1f7e2ed 100644 --- a/.gitignore +++ b/.gitignore @@ -156,4 +156,5 @@ cython_debug/ example_userfiles/output/ example_userfiles/output/* dev_outputs/* -/example_output/* +example_output/* +dics/* diff --git a/README.md b/README.md index 86a2570..3914c63 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,11 @@ bootstraparse aims to be customisable in that regard, but its first iteration an You can refer to the `example_userfiles` for an idea of what the parser expects you to feed it and find an example of our automated generation at https://idle-org.github.io/bootstraparse/ for this particular folder. Or you can run the program yourself for the same result! - Main - - [![Python Main](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml) + - [![Python Tests and Lint](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml/badge.svg?branch=main)](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml) - Releases - - [![Python Release](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml/badge.svg?branch=release)](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml) - + - [![Python Tests and Lint](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml/badge.svg?branch=develop)](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml) +- Deploy + - [![Python Deployment](https://github.com/idle-org/bootstraparse/actions/workflows/python-deploy.yml/badge.svg)](https://github.com/idle-org/bootstraparse/actions/workflows/python-deploy.yml) --- ## Release Notes ### V1.0.1 diff --git a/src/bootstraparse/__main__.py b/src/bootstraparse/__main__.py index 1d7f38d..d4028d3 100755 --- a/src/bootstraparse/__main__.py +++ b/src/bootstraparse/__main__.py @@ -2,7 +2,7 @@ # Main program, use this to start parsing -from bootstraparse.modules import sitecreator +from bootstraparse.modules import sitecreator, error_mngr import argparse import sys @@ -21,5 +21,6 @@ def parse(_args): if __name__ == "__main__": # pragma: no cover args = parse(sys.argv[1:]) + error_mngr.init_logging(filename=None, loglevel="DEBUG", filemode='w', handler=None) if sitecreator.create_website(args.origin, args.destination) == 0: print("Bootstraparse run successful!") diff --git a/src/bootstraparse/configs/parser_config.yml b/src/bootstraparse/configs/parser_config.yml index 0dcc7ae..699352f 100644 --- a/src/bootstraparse/configs/parser_config.yml +++ b/src/bootstraparse/configs/parser_config.yml @@ -21,4 +21,4 @@ export: intermediate_files: true type: "html" force_rewrite: true - copy_unparsable_files: "copy" # "copy" or "ignore" + copy_unparsable_files: copy diff --git a/src/bootstraparse/modules/config.py b/src/bootstraparse/modules/config.py index 49ffaaa..b5eef6d 100644 --- a/src/bootstraparse/modules/config.py +++ b/src/bootstraparse/modules/config.py @@ -74,11 +74,16 @@ class ConfigLoader: if name not in self.loaded_conf: self.loaded_conf[name] = yaml.safe_load(f) else: - self.loaded_conf[name].update(yaml.safe_load(f)) - error_mngr.log_message(f"Warning: {name} is already in {self.loaded_conf}", level='INFO') + new_config = yaml.safe_load(f) + for key in new_config: + if key in self.loaded_conf[name]: + self.loaded_conf[name][key].update(new_config[key]) + else: + self.loaded_conf[name][key] = new_config[key] + error_mngr.log_message(f"Warning: {name} is already in {self.loaded_conf}", level='CRITICAL') except BaseException as e: error_mngr.log_message(f'Error parsing in file {basename} at {filepath}.', level='CRITICAL') - error_mngr.log_exception(str(e), level='CRITICAL') + error_mngr.log_exception(e, level='CRITICAL') def load_from_folder(self, folder): """ diff --git a/tests/modules/test_config.py b/tests/modules/test_config.py index 343f29e..eba2e08 100644 --- a/tests/modules/test_config.py +++ b/tests/modules/test_config.py @@ -1,5 +1,7 @@ import os +from yaml.scanner import ScannerError + import bootstraparse.modules.config as config import pytest import tempfile @@ -10,7 +12,8 @@ configs = { "app/configs/parser_config.yaml": '{"parser": {"name": "test_parser", "type": "test_parser"}}', "app/configs/aliases.yaml": '{"parser": {"name": "test_parser", "type": "test_parser"}}', "user/config/aliases.yaml": '{"aliases": {"test_alias": "test_parser"}}', - "user/config/glossary.yaml": '{"glossary": {"test_glossary": "test_parser"}}', + "app/configs/glossary.yaml": '{"glossary": {"test_glossary": "test_parser"}}', + "user/config/glossary.yaml": '{"glossary": {"test_glossary": "second_parser"}}', "user/config/custom_template.yaml": '{"custom_template": {"test_template": "test_parser"}}', } bad_configs = { @@ -36,7 +39,9 @@ def make_false_configs(): def test_config_load(): usr_c = config.ConfigLoader(user_conf) assert usr_c["aliases"] == {"aliases": {"test_alias": "test_parser"}} - assert usr_c["glossary"] == {"glossary": {"test_glossary": "test_parser"}} + assert usr_c["glossary"] == {"glossary": {"test_glossary": "second_parser"}} + assert usr_c["glossary"]["glossary"] == {"test_glossary": "second_parser"} + assert usr_c["glossary"]["glossary"]["test_glossary"] == "second_parser" assert usr_c["aliases"]["aliases"] == {"test_alias": "test_parser"} assert usr_c["aliases"]["aliases"]["test_alias"] == "test_parser" with pytest.raises(KeyError): @@ -54,7 +59,6 @@ def test_add_to_config(): assert from_list["aliases"] == {"aliases": {"test_alias": "test_parser"}, "parser": {"name": "test_parser", "type": "test_parser"}} assert from_list["parser_config"] == {"parser": {"name": "test_parser", "type": "test_parser"}} - with pytest.raises(KeyError): # Not FileNotFoundError assert from_empty["aliases"] from_empty.add_folder(user_conf) @@ -64,7 +68,7 @@ def test_add_to_config(): assert from_empty["aliases"] == {"aliases": {"test_alias": "test_parser"}, "parser": {"name": "test_parser", "type": "test_parser"}} - with pytest.raises(TypeError): + with pytest.raises(ScannerError): from_empty.load_from_file(os.path.join(bad_conf, "bad_config.yaml"))