From 91c9c2d2b6cf1c1c663b6e35310a448542951205 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 17 Nov 2019 14:22:43 +0000 Subject: [PATCH] handle importing model via configure method --- my/hypothesis.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/my/hypothesis.py b/my/hypothesis.py index 36371de..da3a24b 100644 --- a/my/hypothesis.py +++ b/my/hypothesis.py @@ -2,7 +2,7 @@ from typing import Dict, List, NamedTuple, Optional, Sequence, Any from pathlib import Path from datetime import datetime -from .common import group_by_key, the, cproperty, PathIsh +from .common import group_by_key, the, cproperty, PathIsh, import_file try: @@ -33,7 +33,7 @@ class Config(NamedTuple): def hypexport(self): hp = self.hypexport_path_ if hp is not None: - raise RuntimeError("TODO") + return import_file(Path(hp) / 'model.py', 'hypexport.model') else: global Model global Highlight @@ -57,8 +57,11 @@ def configure(*, export_path: Optional[PathIsh]=None, hypexport_path: Optional[P # TODO check if it works at runtime.. def get_model() -> Model: export_path = config.export_path - sources = list(sorted(export_path.glob('*.json'))) - model = Model(sources) + if export_path.is_file(): + sources = [export_path] + else: + sources = list(sorted(export_path.glob('*.json'))) + model = config.hypexport.Model(sources) return model