zrb 0.23.0__py3-none-any.whl → 0.23.2__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 +1 -1
- {zrb-0.23.0.dist-info → zrb-0.23.2.dist-info}/METADATA +1 -1
- {zrb-0.23.0.dist-info → zrb-0.23.2.dist-info}/RECORD +7 -7
- {zrb-0.23.0.dist-info → zrb-0.23.2.dist-info}/LICENSE +0 -0
- {zrb-0.23.0.dist-info → zrb-0.23.2.dist-info}/WHEEL +0 -0
- {zrb-0.23.0.dist-info → zrb-0.23.2.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}")
|
@@ -13,7 +13,7 @@ def parse_replacement(text: str, replacement: Mapping[str, str]):
|
|
13
13
|
new_text = text
|
14
14
|
for old, new in replacement.items():
|
15
15
|
if len(new.strip().split("\n")) > 1:
|
16
|
-
pattern = "".join(["^([ \\t]+)", old])
|
16
|
+
pattern = "".join(["^([ \\t]+)", re.escape(old)])
|
17
17
|
new_replacement = "".join(["\\1", new.replace("\n", "\n\\1")])
|
18
18
|
new_text = re.sub(pattern, new_replacement, new_text, flags=re.MULTILINE)
|
19
19
|
continue
|
@@ -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=SJxarINfXgeGeimsM3KC-bKRYS-87XF2WF3ewPPX4is,759
|
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
|
@@ -1405,8 +1405,8 @@ zrb/task_input/multiline_input.py,sha256=kP2VQ4c42-d6P4RB3AA2eGTrFRLwvFlZxc7vGwj
|
|
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.23.
|
1409
|
-
zrb-0.23.
|
1410
|
-
zrb-0.23.
|
1411
|
-
zrb-0.23.
|
1412
|
-
zrb-0.23.
|
1408
|
+
zrb-0.23.2.dist-info/LICENSE,sha256=WfnGCl8G60EYOPAEkuc8C9m9pdXWDe08NsKj3TBbxsM,728
|
1409
|
+
zrb-0.23.2.dist-info/METADATA,sha256=LuliAhkw8fHOUTE86WE_cLasUzVJhWKMV-aIaxrjYlc,17076
|
1410
|
+
zrb-0.23.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
1411
|
+
zrb-0.23.2.dist-info/entry_points.txt,sha256=xTgXc1kBKYhJHEujdaSPHUcJT3-hbyP1mLgwkv-5sSk,40
|
1412
|
+
zrb-0.23.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|