encommon 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.
encommon/utils/sample.py CHANGED
@@ -20,11 +20,11 @@ from .. import WORKSPACE
20
20
 
21
21
 
22
22
  def prep_sample(
23
- content: Any, # noqa: ANN401
23
+ content: Any,
24
24
  *,
25
25
  default: Callable[[Any], str] = str,
26
- replace: Optional[dict[str, str]] = None,
27
- ) -> Any: # noqa: ANN401
26
+ replace: Optional[dict[str, str | Path]] = None,
27
+ ) -> Any:
28
28
  """
29
29
  Return the content after processing using JSON functions.
30
30
 
@@ -55,10 +55,14 @@ def prep_sample(
55
55
  replace = replace or {}
56
56
 
57
57
  replace |= {
58
- 'PROJECT': str(PROJECT.resolve()),
59
- 'WORKSPACE': str(WORKSPACE.resolve())}
58
+ 'PROJECT': PROJECT,
59
+ 'WORKSPACE': WORKSPACE}
60
60
 
61
61
  for old, new in replace.items():
62
+
63
+ if isinstance(new, Path):
64
+ new = str(new)
65
+
62
66
  content = content.replace(
63
67
  new, f'_/{prefix}/{old}/_')
64
68
 
@@ -72,8 +76,8 @@ def load_sample(
72
76
  update: bool = False,
73
77
  *,
74
78
  default: Callable[[Any], str] = str,
75
- replace: Optional[dict[str, str]] = None,
76
- ) -> Any: # noqa: ANN401
79
+ replace: Optional[dict[str, str | Path]] = None,
80
+ ) -> Any:
77
81
  """
78
82
  Load the sample file and compare using provided content.
79
83
 
@@ -115,7 +119,7 @@ def load_sample(
115
119
  dumps(content, indent=2))
116
120
 
117
121
 
118
- def _load_sample() -> Any: # noqa: ANN401
122
+ def _load_sample() -> Any:
119
123
  return loads(
120
124
  path.read_text(
121
125
  encoding='utf-8'))
@@ -124,7 +128,7 @@ def load_sample(
124
128
  if path.exists():
125
129
  loaded = _load_sample()
126
130
 
127
- if not path.exists(): # noqa: SIM114
131
+ if not path.exists():
128
132
  _save_sample()
129
133
 
130
134
  elif (update is True
encommon/version.txt CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: encommon
3
- Version: 0.7.3
3
+ Version: 0.7.4
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=eGrr8_ZzyHxfZD5llT_9mzNihLQbKNVMeu7oBvzdjqQ,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=gXz8SZHOtSYKmFF2CzAqB4agy--5Sqc7ePmJKnUXSuA,3136
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.4.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
59
+ encommon-0.7.4.dist-info/METADATA,sha256=rkiclVY-qV7vNMrfCXWknjq2ojZLQ1Gw9JY-Ovj6UME,2671
60
+ encommon-0.7.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
61
+ encommon-0.7.4.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
62
+ encommon-0.7.4.dist-info/RECORD,,