Skip to content

Commit 5a6b760

Browse files
committed
chore: fix examples linting errors
1 parent 69a46cf commit 5a6b760

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

examples/__main__.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import imp
1+
import importlib
22
import logging
33
import os
4-
import sys
54
from collections.abc import Generator
65
from contextlib import contextmanager
76
from pathlib import Path
@@ -21,23 +20,18 @@ def cwd(path: Path) -> Generator[None, None, None]:
2120
os.chdir(old_pwd)
2221

2322

24-
def main(action: str) -> None:
25-
match action:
26-
case "build":
27-
example_dirs = filter(lambda file: file.is_dir() and "__" not in file.name, root_path.glob("*"))
28-
for example in example_dirs:
29-
logger.info(f"Building example {example.name}")
30-
with cwd(root_path):
31-
evaluated_file = imp.load_source(example.name, f"./{example.name}/{example.name}.py")
32-
app = evaluated_file.app
33-
logger.info(f" Building app {app.name}")
34-
appspec = app.build()
35-
logger.info(f" Writing {example.name}/application.json")
36-
(example / "application.json").write_text(appspec.to_json())
23+
def main() -> None:
24+
example_dirs = filter(lambda file: file.is_dir() and "__" not in file.name, root_path.glob("*"))
25+
for example in example_dirs:
26+
logger.info(f"Building example {example.name}")
27+
with cwd(root_path):
28+
evaluated_file = importlib.import_module(f"examples.{example.name}.{example.name}")
29+
app = evaluated_file.app
30+
logger.info(f" Building app {app.name}")
31+
app_spec = app.build()
32+
logger.info(f" Writing {example.name}/application.json")
33+
(example / "application.json").write_text(app_spec.to_json())
3734

3835

3936
if __name__ == "__main__":
40-
if len(sys.argv) > 1:
41-
main(sys.argv[1])
42-
else:
43-
main("build")
37+
main()

examples/config.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)