encommon 0.7.3__py3-none-any.whl → 0.7.5__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.
encommon/utils/sample.py CHANGED
@@ -13,18 +13,26 @@ from pathlib import Path
13
13
  from typing import Any
14
14
  from typing import Callable
15
15
  from typing import Optional
16
+ from typing import Union
16
17
 
17
18
  from .. import PROJECT
18
19
  from .. import WORKSPACE
19
20
 
20
21
 
21
22
 
23
+ _REPLACE = Union[
24
+ dict[str, str],
25
+ dict[str, str | Path],
26
+ dict[str, Path]]
27
+
28
+
29
+
22
30
  def prep_sample(
23
- content: Any, # noqa: ANN401
31
+ content: Any,
24
32
  *,
25
33
  default: Callable[[Any], str] = str,
26
- replace: Optional[dict[str, str]] = None,
27
- ) -> Any: # noqa: ANN401
34
+ replace: Optional[_REPLACE] = None,
35
+ ) -> Any:
28
36
  """
29
37
  Return the content after processing using JSON functions.
30
38
 
@@ -55,10 +63,14 @@ def prep_sample(
55
63
  replace = replace or {}
56
64
 
57
65
  replace |= {
58
- 'PROJECT': str(PROJECT.resolve()),
59
- 'WORKSPACE': str(WORKSPACE.resolve())}
66
+ 'PROJECT': PROJECT,
67
+ 'WORKSPACE': WORKSPACE}
60
68
 
61
69
  for old, new in replace.items():
70
+
71
+ if isinstance(new, Path):
72
+ new = str(new)
73
+
62
74
  content = content.replace(
63
75
  new, f'_/{prefix}/{old}/_')
64
76
 
@@ -72,8 +84,8 @@ def load_sample(
72
84
  update: bool = False,
73
85
  *,
74
86
  default: Callable[[Any], str] = str,
75
- replace: Optional[dict[str, str]] = None,
76
- ) -> Any: # noqa: ANN401
87
+ replace: Optional[_REPLACE] = None,
88
+ ) -> Any:
77
89
  """
78
90
  Load the sample file and compare using provided content.
79
91
 
@@ -115,7 +127,7 @@ def load_sample(
115
127
  dumps(content, indent=2))
116
128
 
117
129
 
118
- def _load_sample() -> Any: # noqa: ANN401
130
+ def _load_sample() -> Any:
119
131
  return loads(
120
132
  path.read_text(
121
133
  encoding='utf-8'))
@@ -124,7 +136,7 @@ def load_sample(
124
136
  if path.exists():
125
137
  loaded = _load_sample()
126
138
 
127
- if not path.exists(): # noqa: SIM114
139
+ if not path.exists():
128
140
  _save_sample()
129
141
 
130
142
  elif (update is True
encommon/version.txt CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.5
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: encommon
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,7 +1,7 @@
1
1
  encommon/__init__.py,sha256=VoXUcphq-gcXCraaU47EtXBftF6UVuQPMGr0fuCTt9A,525
2
2
  encommon/conftest.py,sha256=z5BMi6KjNuactDRgbh8J8w81V08Ptf6QK2o_bJANRs4,880
3
3
  encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- encommon/version.txt,sha256=nHiKg43B9r_YD6OXV6lflCYAccNQEcmgUwHaHHNQdlc,6
4
+ encommon/version.txt,sha256=lm8vhpW1wH3j83xoKxQJ2hrIS1x84EonBou0wBesDLg,6
5
5
  encommon/config/__init__.py,sha256=2ic7tK2lOQvqWmmQnMozqxCJcbyQ_sSEHmOUDUFan2U,710
6
6
  encommon/config/common.py,sha256=gaKBgkF7b7UIAhd0ESio0KpG8JfdRpz5BxNgKRptd6A,2041
7
7
  encommon/config/config.py,sha256=BXX2crZPhnI26LpBoXzXO-McRwLRTWnymNBTY14FR80,4743
@@ -48,15 +48,15 @@ encommon/utils/__init__.py,sha256=bBiDsBz8j-fHJ-P-AM4rZKqfiLNv5Q8KID8GfcvpWLA,83
48
48
  encommon/utils/common.py,sha256=UrowELh3PtDzpSS48nGhsAxTS_QUk96-KEJa4MlxiMA,466
49
49
  encommon/utils/match.py,sha256=4L2d2Cvr7vp3odkRCdNQ10OIW8DkEP55_NbQ6bdsReo,2462
50
50
  encommon/utils/paths.py,sha256=4EeaPsVwpv3pzoHeWmiSSGYZEud6hkD27kvbvgSpOPs,3236
51
- encommon/utils/sample.py,sha256=hOhS6A2aB9a5kXfrst7gUSQkxuqEo2J1AFyBsJZQhHE,3169
51
+ encommon/utils/sample.py,sha256=iN7cKOcu8XnNgJ81aEqXpGlB12tPL4grveU6ZxIShEc,3224
52
52
  encommon/utils/stdout.py,sha256=rmesIjpmzpMdV660qZWzVqToPCs4IZNpvPHaTi6i73Y,7360
53
53
  encommon/utils/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
54
54
  encommon/utils/test/test_match.py,sha256=QagKpTFdRo23-Y55fSaJrSMpt5jIebScKbz0h8tivrI,1124
55
55
  encommon/utils/test/test_paths.py,sha256=0ls9gWJ2B487Dr1fHDDFCZPA7gxtv56nFEYHrTkNX-U,1892
56
56
  encommon/utils/test/test_sample.py,sha256=iNV9IxXmA5KJat3jKRiZH3iutHrT6bsibwti60AhICk,1464
57
57
  encommon/utils/test/test_stdout.py,sha256=TA7xQuFoPZUYW2l00e04MGp4P9gHkkVxVflvPlhpQXg,4878
58
- encommon-0.7.3.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
59
- encommon-0.7.3.dist-info/METADATA,sha256=YTriStSWYTQIg_HAcH78ii6Ge8PRGzs73Z7UU18HWio,2671
60
- encommon-0.7.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
61
- encommon-0.7.3.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
62
- encommon-0.7.3.dist-info/RECORD,,
58
+ encommon-0.7.5.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
59
+ encommon-0.7.5.dist-info/METADATA,sha256=j1abQ__Z4hOmnuOBmxnZYhKC-MRhuW2NPt_KkqZz6P4,2671
60
+ encommon-0.7.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
61
+ encommon-0.7.5.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
62
+ encommon-0.7.5.dist-info/RECORD,,