cook-build 0.7.3__py3-none-any.whl → 0.7.4__py3-none-any.whl
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.
- cook/__init__.py +2 -0
- cook/actions.py +1 -0
- cook/util.py +44 -0
- {cook_build-0.7.3.dist-info → cook_build-0.7.4.dist-info}/METADATA +1 -1
- cook_build-0.7.4.dist-info/RECORD +14 -0
- cook_build-0.7.3.dist-info/RECORD +0 -14
- {cook_build-0.7.3.dist-info → cook_build-0.7.4.dist-info}/WHEEL +0 -0
- {cook_build-0.7.3.dist-info → cook_build-0.7.4.dist-info}/entry_points.txt +0 -0
- {cook_build-0.7.3.dist-info → cook_build-0.7.4.dist-info}/licenses/LICENSE +0 -0
- {cook_build-0.7.3.dist-info → cook_build-0.7.4.dist-info}/top_level.txt +0 -0
cook/__init__.py
CHANGED
cook/actions.py
CHANGED
cook/util.py
CHANGED
|
@@ -98,3 +98,47 @@ def format_datetime(dt: datetime) -> str:
|
|
|
98
98
|
Format a date-time.
|
|
99
99
|
"""
|
|
100
100
|
return str(dt).rsplit(".", 2)[0]
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def dict2args(*positional, flags: dict | None = None, **kwargs) -> list[str]:
|
|
104
|
+
"""
|
|
105
|
+
Convert arguments to command-line argument strings.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
*positional: Positional arguments appended after flags.
|
|
109
|
+
flags: Dictionary for flag names that aren't valid Python identifiers
|
|
110
|
+
(e.g., names containing dashes).
|
|
111
|
+
**kwargs: Keyword arguments converted to flags.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
List of command-line argument strings.
|
|
115
|
+
|
|
116
|
+
Example:
|
|
117
|
+
|
|
118
|
+
.. doctest::
|
|
119
|
+
|
|
120
|
+
>>> from cook.util import dict2args
|
|
121
|
+
>>> dict2args(output="file.txt", verbose=True, count=3)
|
|
122
|
+
['--output=file.txt', '--verbose', '--count=3']
|
|
123
|
+
>>> dict2args("input.txt", "output.txt", verbose=True)
|
|
124
|
+
['--verbose', 'input.txt', 'output.txt']
|
|
125
|
+
>>> dict2args(flags={"dry-run": True, "num-workers": 4})
|
|
126
|
+
['--dry-run', '--num-workers=4']
|
|
127
|
+
>>> dict2args(values=[1, 2, 3])
|
|
128
|
+
['--values=1,2,3']
|
|
129
|
+
"""
|
|
130
|
+
if flags is not None:
|
|
131
|
+
kwargs = flags | kwargs
|
|
132
|
+
args = []
|
|
133
|
+
for key, value in kwargs.items():
|
|
134
|
+
if isinstance(value, bool):
|
|
135
|
+
if value:
|
|
136
|
+
args.append(f"--{key}")
|
|
137
|
+
elif isinstance(value, (list, tuple)):
|
|
138
|
+
if not value:
|
|
139
|
+
raise ValueError(f"empty sequence for argument {key!r}")
|
|
140
|
+
args.append(f"--{key}={','.join(map(str, value))}")
|
|
141
|
+
else:
|
|
142
|
+
args.append(f"--{key}={value}")
|
|
143
|
+
args.extend(str(arg) for arg in positional)
|
|
144
|
+
return args
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
cook/__init__.py,sha256=YuVqQywPpdWLw5IWRV_7iXx6-5_eBeoC8c3W8jGpz8Q,224
|
|
2
|
+
cook/__main__.py,sha256=3vnDZOJLTMJGRQzPolqurVzKJ7KCUjosBuuUkW22tKY,13192
|
|
3
|
+
cook/actions.py,sha256=D118eI7DunYbjI51V2NHTwJuf4w5oDdoqsKDh1-0unk,7574
|
|
4
|
+
cook/contexts.py,sha256=-L4o_b_XPNZ_MBuYAgR1LYbptWPankDyj-00Pji7EVg,10710
|
|
5
|
+
cook/controller.py,sha256=vs9wBfvdQzE5RGZxZtKef6hb8rUOKKMp_kuPnmVAf9s,13432
|
|
6
|
+
cook/manager.py,sha256=sLlqPjsi81UTSHNhNj-ZTDilCdVmEF992N94yxWPOlU,6247
|
|
7
|
+
cook/task.py,sha256=-LNMwHdFlTUG45DF_QyWlIHw55_n_u2Xf5beKB7LrdY,2308
|
|
8
|
+
cook/util.py,sha256=ZrHM242Hf27Vqc0v1BqY3KLgLAnQ5L2bdTv-2XQW4ck,3988
|
|
9
|
+
cook_build-0.7.4.dist-info/licenses/LICENSE,sha256=3Nuj_WTTcz7JDg4-9EzNf6vHlKRWpdLUccg-pvoZ3WE,1500
|
|
10
|
+
cook_build-0.7.4.dist-info/METADATA,sha256=fOpF4Zi5qDz4Y0O-kEoAFJ2TW1khObCuctL_hxBtXqk,4586
|
|
11
|
+
cook_build-0.7.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
+
cook_build-0.7.4.dist-info/entry_points.txt,sha256=5UP0ZmmxSNKevTVISUJxmdXEQsKrI4n54OQYkjrdX2c,48
|
|
13
|
+
cook_build-0.7.4.dist-info/top_level.txt,sha256=ewNQIn2oRSYV98vAsUnw88u2Q8XHKhAz70ed2PEdR2c,5
|
|
14
|
+
cook_build-0.7.4.dist-info/RECORD,,
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
cook/__init__.py,sha256=SCa9_i6B84IzSAwq0wnSQqvycyL4dvTO7dRIysJXZj4,179
|
|
2
|
-
cook/__main__.py,sha256=3vnDZOJLTMJGRQzPolqurVzKJ7KCUjosBuuUkW22tKY,13192
|
|
3
|
-
cook/actions.py,sha256=yxo_LQ42iejq0K92OnYs7x2GaTuyNK3ZmqnRikQUgWs,7537
|
|
4
|
-
cook/contexts.py,sha256=-L4o_b_XPNZ_MBuYAgR1LYbptWPankDyj-00Pji7EVg,10710
|
|
5
|
-
cook/controller.py,sha256=vs9wBfvdQzE5RGZxZtKef6hb8rUOKKMp_kuPnmVAf9s,13432
|
|
6
|
-
cook/manager.py,sha256=sLlqPjsi81UTSHNhNj-ZTDilCdVmEF992N94yxWPOlU,6247
|
|
7
|
-
cook/task.py,sha256=-LNMwHdFlTUG45DF_QyWlIHw55_n_u2Xf5beKB7LrdY,2308
|
|
8
|
-
cook/util.py,sha256=Ssk_79cB7tvxEk_I9VAjjzmEp1bJ95ELZHCAx6sybyo,2459
|
|
9
|
-
cook_build-0.7.3.dist-info/licenses/LICENSE,sha256=3Nuj_WTTcz7JDg4-9EzNf6vHlKRWpdLUccg-pvoZ3WE,1500
|
|
10
|
-
cook_build-0.7.3.dist-info/METADATA,sha256=M83L-Uar5tKKLB2OyqQ1IS3wxe-idBZIvH2foLTXxAE,4586
|
|
11
|
-
cook_build-0.7.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
12
|
-
cook_build-0.7.3.dist-info/entry_points.txt,sha256=5UP0ZmmxSNKevTVISUJxmdXEQsKrI4n54OQYkjrdX2c,48
|
|
13
|
-
cook_build-0.7.3.dist-info/top_level.txt,sha256=ewNQIn2oRSYV98vAsUnw88u2Q8XHKhAz70ed2PEdR2c,5
|
|
14
|
-
cook_build-0.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|