Browse Source

Fixup commit

master
Lucas Verney 1 year ago
parent
commit
3201c3ddd3
  1. 12
      flatisfy/__main__.py
  2. 9
      flatisfy/fetch.py
  3. 8
      flatisfy/models/flat.py
  4. 3
      requirements.txt

12
flatisfy/__main__.py

@ -99,7 +99,7 @@ def parse_args(argv=None): @@ -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(): @@ -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(): @@ -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

9
flatisfy/fetch.py

@ -78,7 +78,14 @@ class WebOOBProxy(object): @@ -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

8
flatisfy/models/flat.py

@ -149,14 +149,18 @@ class Flat(BASE): @@ -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):

3
requirements.txt

@ -16,5 +16,6 @@ titlecase @@ -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

Loading…
Cancel
Save