cutekit 0.9.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cutekit-0.9.3/PKG-INFO ADDED
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutekit
3
+ Version: 0.9.3
4
+ Summary: The magical build system and package manager
5
+ Author-email: Keyboard Slayer <joda@cute.engineering>, Sleepy Monax <nivb@cute.engineering>, Cyp <cypb@cute.engineering>, Cute Engineering <contact@cute.engineering>
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: graphviz~=0.20.1
10
+ Requires-Dist: dataclasses-json~=0.6.4
@@ -0,0 +1,97 @@
1
+ import os
2
+ import logging
3
+
4
+ from . import (
5
+ builder, # noqa: F401 this is imported for side effects
6
+ export, # noqa: F401 this is imported for side effects
7
+ fmt, # noqa: F401 this is imported for side effects
8
+ package, # noqa: F401 this is imported for side effects
9
+ cli,
10
+ const,
11
+ model,
12
+ plugins,
13
+ shell,
14
+ vt100,
15
+ )
16
+
17
+
18
+ def ensure(version: tuple[int, int, int]):
19
+ if (
20
+ const.VERSION[0] == version[0]
21
+ and const.VERSION[1] == version[1]
22
+ and const.VERSION[2] >= version[2]
23
+ ):
24
+ return
25
+
26
+ raise RuntimeError(
27
+ f"Expected cutekit version {version[0]}.{version[1]}.{version[2]} but found {const.VERSION_STR}"
28
+ )
29
+
30
+
31
+ class logger:
32
+ class LoggerArgs:
33
+ verbose: bool = cli.arg(None, "verbose", "Enable verbose logging")
34
+
35
+ @staticmethod
36
+ def setup(args: LoggerArgs):
37
+ if args.verbose:
38
+ logging.basicConfig(
39
+ level=logging.DEBUG,
40
+ format=f"{vt100.CYAN}%(asctime)s{vt100.RESET} {vt100.YELLOW}%(levelname)s{vt100.RESET} %(name)s: %(message)s",
41
+ datefmt="%Y-%m-%d %H:%M:%S",
42
+ )
43
+ else:
44
+ projectRoot = model.Project.topmost()
45
+ logFile = const.GLOBAL_LOG_FILE
46
+ if projectRoot is not None:
47
+ logFile = os.path.join(projectRoot.dirname(), const.PROJECT_LOG_FILE)
48
+
49
+ shell.mkdir(os.path.dirname(logFile))
50
+
51
+ logging.basicConfig(
52
+ level=logging.INFO,
53
+ filename=logFile,
54
+ filemode="w",
55
+ format="%(asctime)s %(levelname)s %(name)s: %(message)s",
56
+ datefmt="%Y-%m-%d %H:%M:%S",
57
+ )
58
+
59
+
60
+ class RootArgs(
61
+ plugins.PluginsArgs,
62
+ logger.LoggerArgs,
63
+ ):
64
+ pass
65
+
66
+
67
+ @cli.command("/", const.DESCRIPTION)
68
+ def _(args: RootArgs):
69
+ shell.mkdir(const.GLOBAL_CK_DIR)
70
+ const.setup()
71
+ logger.setup(args)
72
+ plugins.setup(args)
73
+
74
+
75
+ @cli.command("usage", "Show usage information")
76
+ def _():
77
+ cli.usage()
78
+
79
+
80
+ @cli.command("version", "Show current version")
81
+ def _():
82
+ print(f"CuteKit v{const.VERSION_STR}")
83
+
84
+
85
+ def main() -> int:
86
+ try:
87
+ cli.exec()
88
+ return 0
89
+
90
+ except RuntimeError as e:
91
+ logging.exception(e)
92
+ vt100.error(str(e))
93
+ return 1
94
+
95
+ except KeyboardInterrupt:
96
+ print()
97
+ return 1
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from . import main
4
+
5
+ sys.exit(main())