Fix another issue with data path

This commit is contained in:
Andre Basche 2024-02-09 20:33:50 +01:00
parent 29c936b045
commit a5595f47bf
2 changed files with 6 additions and 7 deletions

View File

@ -38,9 +38,7 @@ def get_arguments() -> Dict[str, Any]:
"translate", help="language (de, en, fr...)", metavar="LANGUAGE" "translate", help="language (de, en, fr...)", metavar="LANGUAGE"
) )
translation.add_argument("--json", help="print as json", action="store_true") translation.add_argument("--json", help="print as json", action="store_true")
parser.add_argument( parser.add_argument("-i", "--import", help="import pyhon data", nargs="?")
"-i", "--import", help="import pyhon data", nargs="?", default=Path().cwd()
)
return vars(parser.parse_args()) return vars(parser.parse_args())
@ -73,9 +71,8 @@ async def main() -> None:
if language := args.get("translate"): if language := args.get("translate"):
await translate(language, json_output=args.get("json", "")) await translate(language, json_output=args.get("json", ""))
return return
async with Hon( test_data_path = Path(path) if (path := args.get("import", "")) else None
*get_login_data(args), test_data_path=Path(args.get("import", "")) async with Hon(*get_login_data(args), test_data_path=test_data_path) as hon:
) as hon:
for device in hon.appliances: for device in hon.appliances:
if args.get("export"): if args.get("export"):
anonymous = args.get("anonymous", False) anonymous = args.get("anonymous", False)

View File

@ -104,7 +104,9 @@ class Hon:
await self._create_appliance(appliance, self.api) await self._create_appliance(appliance, self.api)
if ( if (
self._test_data_path 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() or (test_data := test_data / "..").exists()
): ):
api = TestAPI(test_data) api = TestAPI(test_data)