commit
f7a9d38298
|
|
@ -156,4 +156,5 @@ cython_debug/
|
|||
example_userfiles/output/
|
||||
example_userfiles/output/*
|
||||
dev_outputs/*
|
||||
/example_output/*
|
||||
example_output/*
|
||||
dics/*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
- [](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml)
|
||||
- [](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml)
|
||||
- Releases
|
||||
- [](https://github.com/idle-org/bootstraparse/actions/workflows/python-app.yml)
|
||||
|
||||
- [](https://github.com/idle-org/bootstraparse/actions/workflows/python-tests.yml)
|
||||
- Deploy
|
||||
- [](https://github.com/idle-org/bootstraparse/actions/workflows/python-deploy.yml)
|
||||
---
|
||||
## Release Notes
|
||||
### V1.0.1
|
||||
|
|
|
|||
|
|
@ -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!")
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ export:
|
|||
intermediate_files: true
|
||||
type: "html"
|
||||
force_rewrite: true
|
||||
copy_unparsable_files: "copy" # "copy" or "ignore"
|
||||
copy_unparsable_files: copy
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue