zrb 0.22.0__py3-none-any.whl → 0.23.1__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.
- zrb/helper/file/copy_tree.py +26 -10
- zrb/helper/string/parse_replacement.py +7 -0
- zrb/task_input/multiline_input.py +1 -1
- {zrb-0.22.0.dist-info → zrb-0.23.1.dist-info}/METADATA +2 -2
- {zrb-0.22.0.dist-info → zrb-0.23.1.dist-info}/RECORD +8 -8
- {zrb-0.22.0.dist-info → zrb-0.23.1.dist-info}/LICENSE +0 -0
- {zrb-0.22.0.dist-info → zrb-0.23.1.dist-info}/WHEEL +0 -0
- {zrb-0.22.0.dist-info → zrb-0.23.1.dist-info}/entry_points.txt +0 -0
zrb/helper/file/copy_tree.py
CHANGED
@@ -26,6 +26,9 @@ async def copy_tree(
|
|
26
26
|
excludes = []
|
27
27
|
if skip_parsing is None:
|
28
28
|
skip_parsing = []
|
29
|
+
if os.path.isfile(src):
|
30
|
+
await _copy_file(src, dst, replacements, excludes, skip_parsing)
|
31
|
+
return
|
29
32
|
names = os.listdir(src)
|
30
33
|
new_dst = parse_replacement(dst, replacements)
|
31
34
|
if not os.path.exists(new_dst):
|
@@ -38,13 +41,26 @@ async def copy_tree(
|
|
38
41
|
if os.path.isdir(src_name):
|
39
42
|
await copy_tree(src_name, dst_name, replacements, excludes, skip_parsing)
|
40
43
|
continue
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
await _copy_file(src_name, dst_name, replacements, excludes, skip_parsing)
|
45
|
+
|
46
|
+
|
47
|
+
async def _copy_file(
|
48
|
+
src: str,
|
49
|
+
dst: str,
|
50
|
+
replacements: Optional[Mapping[str, str]] = None,
|
51
|
+
excludes: Optional[Iterable[str]] = None,
|
52
|
+
skip_parsing: Optional[Iterable[str]] = None,
|
53
|
+
):
|
54
|
+
if any(fnmatch.fnmatch(src, pattern) for pattern in excludes):
|
55
|
+
return
|
56
|
+
new_dst_name = parse_replacement(dst, replacements)
|
57
|
+
if any(fnmatch.fnmatch(new_dst_name, pattern) for pattern in skip_parsing):
|
58
|
+
return
|
59
|
+
if new_dst_name != src:
|
60
|
+
shutil.copy2(src, new_dst_name)
|
61
|
+
try:
|
62
|
+
file_content = await read_text_file_async(new_dst_name)
|
63
|
+
new_file_content = parse_replacement(file_content, replacements)
|
64
|
+
await write_text_file_async(new_dst_name, new_file_content)
|
65
|
+
except Exception:
|
66
|
+
logger.error(f"Cannot parse file: {new_dst_name}")
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import re
|
2
|
+
|
1
3
|
from zrb.helper.accessories.color import colored
|
2
4
|
from zrb.helper.log import logger
|
3
5
|
from zrb.helper.typecheck import typechecked
|
@@ -10,5 +12,10 @@ logger.debug(colored("Loading zrb.helper.string.parse_replacment", attrs=["dark"
|
|
10
12
|
def parse_replacement(text: str, replacement: Mapping[str, str]):
|
11
13
|
new_text = text
|
12
14
|
for old, new in replacement.items():
|
15
|
+
if len(new.strip().split("\n")) > 1:
|
16
|
+
pattern = "".join(["^([ \\t]+)", old])
|
17
|
+
new_replacement = "".join(["\\1", new.replace("\n", "\n\\1")])
|
18
|
+
new_text = re.sub(pattern, new_replacement, new_text, flags=re.MULTILINE)
|
19
|
+
continue
|
13
20
|
new_text = new_text.replace(old, new)
|
14
21
|
return new_text
|
@@ -120,6 +120,6 @@ class MultilineInput(BaseInput):
|
|
120
120
|
|
121
121
|
def _get_mark_comment(self):
|
122
122
|
prompt = self._prompt if isinstance(self._prompt, str) else self.get_name()
|
123
|
-
if self._comment_suffix.strip()
|
123
|
+
if self._comment_suffix.strip() == "":
|
124
124
|
return " ".join([self._comment_prefix, prompt])
|
125
125
|
return " ".join([self._comment_prefix, prompt, self._comment_suffix])
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: zrb
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.23.1
|
4
4
|
Summary: A Framework to Enhance Your Workflow
|
5
5
|
Home-page: https://github.com/state-alchemists/zrb
|
6
6
|
License: AGPL-3.0-or-later
|
@@ -23,7 +23,7 @@ Requires-Dist: jsons (>=1.6.3,<1.7.0)
|
|
23
23
|
Requires-Dist: libcst (>=0.4.9,<0.5.0)
|
24
24
|
Requires-Dist: python-dotenv (>=1.0.1,<1.1.0)
|
25
25
|
Requires-Dist: ruamel.yaml (>=0.18.6,<0.19.0)
|
26
|
-
Requires-Dist: setuptools (>=
|
26
|
+
Requires-Dist: setuptools (>=70.0.0,<70.1.0)
|
27
27
|
Requires-Dist: termcolor (>=2.4.0,<2.5.0)
|
28
28
|
Requires-Dist: tomlkit (>=0.12.4,<0.13.0)
|
29
29
|
Project-URL: Documentation, https://github.com/state-alchemists/zrb
|
@@ -1322,7 +1322,7 @@ zrb/helper/docstring.py,sha256=kU3nZFYtCrrxNsLxmx2UofHav09VB5y0VeY_Blux6FQ,4970
|
|
1322
1322
|
zrb/helper/env_map/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1323
1323
|
zrb/helper/env_map/fetch.py,sha256=wzOO58LmhQsgFVsVrUhdGbQmu6igOE1x6SR2SbRnuTA,2335
|
1324
1324
|
zrb/helper/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
1325
|
-
zrb/helper/file/copy_tree.py,sha256=
|
1325
|
+
zrb/helper/file/copy_tree.py,sha256=tOzM3VJXRTBprgZ-YNfTURlkxm5udFer9Yggtq3CXNU,2312
|
1326
1326
|
zrb/helper/file/match.py,sha256=73uypJq5EnFAhA7kaNodW9vBLZ0MQVwZDh8CD3x52kw,721
|
1327
1327
|
zrb/helper/file/text.py,sha256=7JqNbk8hC7Y4UopEmhiGYkxDAauepvI1tEkbfpzcI84,963
|
1328
1328
|
zrb/helper/git/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -1340,7 +1340,7 @@ zrb/helper/string/constant.py,sha256=kAwuNW9hC3xc24t5NoeUX5tautZMvWNzZdREKMMbXm8
|
|
1340
1340
|
zrb/helper/string/conversion.py,sha256=pnhlhKwvXUR38jvtSo1HZNedl-7KtHoKaWl4OVIaEv0,772
|
1341
1341
|
zrb/helper/string/jinja.py,sha256=FyYtsJjEDqk3atmaU2TdNWtA4qD88x-lmtF5BOa23KY,487
|
1342
1342
|
zrb/helper/string/modification.py,sha256=sYPewGp72l2AhWXr-Wy3FfzO9aTLCULw-JgQzSmXQmI,308
|
1343
|
-
zrb/helper/string/parse_replacement.py,sha256=
|
1343
|
+
zrb/helper/string/parse_replacement.py,sha256=2ulUKRnvoPFpbeoq84jLEbNGaGYRzH2n4tblCMIM0Pk,748
|
1344
1344
|
zrb/helper/string/untyped_conversion.py,sha256=0hxwbyMz4psglAH5KnjfXBmgptJq34P9ltueQntBx4Y,1366
|
1345
1345
|
zrb/helper/task.py,sha256=Z8p2urrTuABCFrsefR3u250Gdi1dtf7bABE4yR3oLZU,394
|
1346
1346
|
zrb/helper/typecheck.py,sha256=Sb5lCiMfxppycj3nqUSxkyRPBdxdTRRnvaCCAb6mGrI,436
|
@@ -1401,12 +1401,12 @@ zrb/task_input/choice_input.py,sha256=qfrEzbs2g0CZeE2TzvfN0IOla_1B8Tikn-eIgMpLuP
|
|
1401
1401
|
zrb/task_input/constant.py,sha256=VEsnrI0BDdCJ1Z58EJgxXUhZBe5CA8TfURo0cNu5CaQ,200
|
1402
1402
|
zrb/task_input/float_input.py,sha256=bf2dhmbpmHMQiJFKYQEfTYmqpwyOEFh6CFM1r1dGTuw,4302
|
1403
1403
|
zrb/task_input/int_input.py,sha256=P7lDQ0-x5lP_ZTfFeyc-aybub9oikBN4J13HZvWuw0A,4355
|
1404
|
-
zrb/task_input/multiline_input.py,sha256=
|
1404
|
+
zrb/task_input/multiline_input.py,sha256=kP2VQ4c42-d6P4RB3AA2eGTrFRLwvFlZxc7vGwjTeZA,5609
|
1405
1405
|
zrb/task_input/password_input.py,sha256=3xxWHKJCDGbyl_5MmyyB2t_yRjwFKpIIbS10aq73ktk,4370
|
1406
1406
|
zrb/task_input/str_input.py,sha256=0BJP3SQ8y0TRYPrwEy5pYv4N7jq8KlmRSVwByIFqIvI,4360
|
1407
1407
|
zrb/task_input/task_input.py,sha256=WTj_qIQyRs-04-VotjNTcVyIuf6b2afInVoCQHoRmr0,2327
|
1408
|
-
zrb-0.
|
1409
|
-
zrb-0.
|
1410
|
-
zrb-0.
|
1411
|
-
zrb-0.
|
1412
|
-
zrb-0.
|
1408
|
+
zrb-0.23.1.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
|
1409
|
+
zrb-0.23.1.dist-info/METADATA,sha256=JrxkQFGJnggG-omBTS1mdwgTYa_1COlzVrNYZF5zh34,17076
|
1410
|
+
zrb-0.23.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
1411
|
+
zrb-0.23.1.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
|
1412
|
+
zrb-0.23.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|