From a5595f47bf4c1bdaba21b9e6b15fedb1e08df15e Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Fri, 9 Feb 2024 20:33:50 +0100 Subject: [PATCH] Fix another issue with data path --- pyhon/__main__.py | 9 +++------ pyhon/hon.py | 4 +++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pyhon/__main__.py b/pyhon/__main__.py index 9e9b25b..28bfcdf 100755 --- a/pyhon/__main__.py +++ b/pyhon/__main__.py @@ -38,9 +38,7 @@ def get_arguments() -> Dict[str, Any]: "translate", help="language (de, en, fr...)", metavar="LANGUAGE" ) translation.add_argument("--json", help="print as json", action="store_true") - parser.add_argument( - "-i", "--import", help="import pyhon data", nargs="?", default=Path().cwd() - ) + parser.add_argument("-i", "--import", help="import pyhon data", nargs="?") return vars(parser.parse_args()) @@ -73,9 +71,8 @@ async def main() -> None: if language := args.get("translate"): await translate(language, json_output=args.get("json", "")) return - async with Hon( - *get_login_data(args), test_data_path=Path(args.get("import", "")) - ) as hon: + test_data_path = Path(path) if (path := args.get("import", "")) else None + async with Hon(*get_login_data(args), test_data_path=test_data_path) as hon: for device in hon.appliances: if args.get("export"): anonymous = args.get("anonymous", False) diff --git a/pyhon/hon.py b/pyhon/hon.py index dfd117e..b8d25e2 100644 --- a/pyhon/hon.py +++ b/pyhon/hon.py @@ -104,7 +104,9 @@ class Hon: await self._create_appliance(appliance, self.api) if ( self._test_data_path - and (test_data := self._test_data_path / "hon-test-data" / "test_data").exists() + and ( + test_data := self._test_data_path / "hon-test-data" / "test_data" + ).exists() or (test_data := test_data / "..").exists() ): api = TestAPI(test_data)