From 3201c3ddd3bdfc9fd49102d9a61219d7b9568749 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Sun, 14 Mar 2021 18:00:36 +0100 Subject: [PATCH] Fixup commit --- flatisfy/__main__.py | 12 ++++++++---- flatisfy/fetch.py | 9 ++++++++- flatisfy/models/flat.py | 8 ++++++-- requirements.txt | 3 ++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/flatisfy/__main__.py b/flatisfy/__main__.py index 1ce71f8..c0920f7 100644 --- a/flatisfy/__main__.py +++ b/flatisfy/__main__.py @@ -99,7 +99,7 @@ def parse_args(argv=None): # Test subcommand parser subparsers.add_parser("test", parents=[parent_parser], help="Unit testing.") - return parser.parse_args(argv) + return parser, parser.parse_args(argv) def main(): @@ -108,14 +108,14 @@ def main(): """ # pylint: disable=locally-disabled,too-many-branches # Parse arguments - args = parse_args() + parser, args = parse_args() # Set logger - if args.vv: + if getattr(args, 'vv', False): logging.getLogger("").setLevel(logging.DEBUG) logging.getLogger("titlecase").setLevel(logging.INFO) logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) - elif args.verbose: + elif getattr(args, 'verbose', False): logging.getLogger("").setLevel(logging.INFO) # sqlalchemy INFO level is way too loud, just stick with WARNING logging.getLogger("sqlalchemy.engine").setLevel(logging.WARNING) @@ -128,6 +128,10 @@ def main(): flatisfy.config.init_config(args.output) sys.exit(0) else: + if not args.cmd: + parser.print_help() + sys.exit(0) + # Load config if args.cmd == "build-data": # Data not yet built, do not use it in config checks diff --git a/flatisfy/fetch.py b/flatisfy/fetch.py index 78576d7..a6391d2 100644 --- a/flatisfy/fetch.py +++ b/flatisfy/fetch.py @@ -78,7 +78,14 @@ class WebOOBProxy(object): self.webnip = WebNip(modules_path=config["modules_path"]) # Create backends - self.backends = [self.webnip.load_backend(module, module, params={}) for module in backends] + self.backends = [] + for module in backends: + try: + self.backends.append( + self.webnip.load_backend(module, module, params={}) + ) + except Exception as exc: + raise Exception('Unable to load module ' + module) from exc def __enter__(self): return self diff --git a/flatisfy/models/flat.py b/flatisfy/models/flat.py index f3fedce..dbfb89c 100644 --- a/flatisfy/models/flat.py +++ b/flatisfy/models/flat.py @@ -149,14 +149,18 @@ class Flat(BASE): """ Date validation method """ - return arrow.get(date).naive + if date: + return arrow.get(date).naive + return None @validates("visit_date") def validate_visit_date(self, _, visit_date): """ Visit date validation method """ - return arrow.get(visit_date).naive + if visit_date: + return arrow.get(visit_date).naive + return None @validates("photos") def validate_photos(self, _, photos): diff --git a/requirements.txt b/requirements.txt index 1024983..e35184b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,5 +16,6 @@ titlecase unidecode vobject whoosh -https://git.weboob.org/weboob/weboob/repository/archive.zip?ref=master +git+https://git.weboob.org/weboob/weboob/ +git+https://git.weboob.org/weboob/modules/ money