iker-python-common 1.0.13__tar.gz → 1.0.15__tar.gz
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.
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/PKG-INFO +1 -1
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/numutils.py +0 -2
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/sequtils.py +2 -4
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/span.py +0 -2
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/strutils.py +49 -10
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/PKG-INFO +1 -1
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/strutils_test.py +45 -5
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/.editorconfig +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/.github/workflows/pr.yml +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/.github/workflows/push.yml +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/.gitignore +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/MANIFEST.in +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/README.md +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/VERSION +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/pyproject.toml +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.baz/file.bar.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.baz/file.foo.bar +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.baz/file.foo.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.bar +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.baz +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.foo +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/setup.cfg +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/setup.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/__init__.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/__init__.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/argutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/config.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/dbutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/dockerutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/dtutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/funcutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/jsonutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/logger.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/randutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/retry.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/s3utils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/shutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/testutils.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/SOURCES.txt +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/dependency_links.txt +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/not-zip-safe +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/requires.txt +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/top_level.txt +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/__init__.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/argutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/config_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/dbutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/dockerutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/dtutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/funcutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/jsonutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/logger_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/numutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/randutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/retry_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/s3utils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/sequtils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/shutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/span_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/testutils_test.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/docker_fixtures.py +0 -0
- {iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/iker_test.py +0 -0
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
import functools
|
|
4
2
|
import itertools
|
|
5
3
|
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence, Sized
|
|
@@ -371,10 +369,10 @@ class Seq(Generic[Tco], Sequence[Tco], Sized):
|
|
|
371
369
|
def intersect(self, other: Self) -> Self:
|
|
372
370
|
return Seq(list(set(self.data).intersection(set(other.data))))
|
|
373
371
|
|
|
374
|
-
def zip(self, other: Seq[U]) -> Seq[tuple[Tco, U]]:
|
|
372
|
+
def zip(self, other: "Seq[U]") -> "Seq[tuple[Tco, U]]":
|
|
375
373
|
return Seq(zip(self.data, other.data))
|
|
376
374
|
|
|
377
|
-
def zip_fill(self, other: Seq[U], fill: Tco | U | None = None) -> Seq[tuple[Tco, U]]:
|
|
375
|
+
def zip_fill(self, other: "Seq[U]", fill: Tco | U | None = None) -> "Seq[tuple[Tco, U]]":
|
|
378
376
|
return Seq(itertools.zip_longest(self.data, other.data, fillvalue=fill))
|
|
379
377
|
|
|
380
378
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
4
5
|
from iker.common.utils.dtutils import dt_parse_iso
|
|
5
|
-
from iker.common.utils.sequtils import head, last
|
|
6
6
|
|
|
7
7
|
__all__ = [
|
|
8
8
|
"is_none",
|
|
@@ -18,6 +18,7 @@ __all__ = [
|
|
|
18
18
|
"str_conv",
|
|
19
19
|
"repr_data",
|
|
20
20
|
"parse_params_string",
|
|
21
|
+
"make_params_string",
|
|
21
22
|
"strip_margin",
|
|
22
23
|
]
|
|
23
24
|
|
|
@@ -125,22 +126,60 @@ def repr_data(o) -> str:
|
|
|
125
126
|
return str(o)
|
|
126
127
|
|
|
127
128
|
|
|
128
|
-
def parse_params_string(
|
|
129
|
+
def parse_params_string(
|
|
130
|
+
s: str,
|
|
131
|
+
*,
|
|
132
|
+
delim: str = ",",
|
|
133
|
+
kv_delim: str = "=",
|
|
134
|
+
neg_prefix: str = "-",
|
|
135
|
+
str_parser: Callable[[str], Any] = str,
|
|
136
|
+
true_value: Any = True,
|
|
137
|
+
false_value: Any = False,
|
|
138
|
+
) -> dict[str, Any]:
|
|
129
139
|
if is_blank(s):
|
|
130
140
|
return {}
|
|
131
141
|
|
|
132
142
|
result = {}
|
|
133
|
-
for param in s.split(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
for param in s.split(delim):
|
|
144
|
+
match param.split(kv_delim, 1):
|
|
145
|
+
case [key]:
|
|
146
|
+
if len(key) == 0 or key == neg_prefix:
|
|
147
|
+
continue
|
|
148
|
+
if key.startswith(neg_prefix):
|
|
149
|
+
result[key[len(neg_prefix):]] = false_value
|
|
150
|
+
else:
|
|
151
|
+
result[key] = true_value
|
|
152
|
+
case [key, value]:
|
|
153
|
+
if len(key) == 0 or key == neg_prefix:
|
|
154
|
+
continue
|
|
155
|
+
result[key] = str_parser(value)
|
|
156
|
+
case _:
|
|
157
|
+
raise ValueError("malformed param <%s>" % param)
|
|
141
158
|
return result
|
|
142
159
|
|
|
143
160
|
|
|
161
|
+
def make_params_string(
|
|
162
|
+
params: dict[str, Any],
|
|
163
|
+
*,
|
|
164
|
+
delim: str = ",",
|
|
165
|
+
kv_delim: str = "=",
|
|
166
|
+
neg_prefix: str = "-",
|
|
167
|
+
str_maker: Callable[[Any], str] = str,
|
|
168
|
+
) -> str:
|
|
169
|
+
if len(params or {}) == 0:
|
|
170
|
+
return ""
|
|
171
|
+
|
|
172
|
+
kv_strs = []
|
|
173
|
+
for key, value in params.items():
|
|
174
|
+
if len(key) == 0 or key == neg_prefix:
|
|
175
|
+
continue
|
|
176
|
+
if isinstance(value, bool):
|
|
177
|
+
kv_strs.append(key if value is True else neg_prefix + key)
|
|
178
|
+
else:
|
|
179
|
+
kv_strs.append(kv_delim.join((key, str_maker(value))))
|
|
180
|
+
return delim.join(kv_strs)
|
|
181
|
+
|
|
182
|
+
|
|
144
183
|
def strip_margin(text: str, margin_char: str = "|") -> str:
|
|
145
184
|
stripped_text = ""
|
|
146
185
|
last_stripped_line = ""
|
|
@@ -4,8 +4,8 @@ import ddt
|
|
|
4
4
|
|
|
5
5
|
from iker.common.utils.dtutils import dt_utc
|
|
6
6
|
from iker.common.utils.strutils import is_blank, is_empty, is_none
|
|
7
|
+
from iker.common.utils.strutils import make_params_string, parse_params_string
|
|
7
8
|
from iker.common.utils.strutils import parse_bool, parse_float_or, parse_int_or
|
|
8
|
-
from iker.common.utils.strutils import parse_params_string
|
|
9
9
|
from iker.common.utils.strutils import str_conv
|
|
10
10
|
from iker.common.utils.strutils import strip_margin
|
|
11
11
|
from iker.common.utils.strutils import trim_to_empty, trim_to_none
|
|
@@ -204,14 +204,20 @@ class StrUtilsTest(unittest.TestCase):
|
|
|
204
204
|
@ddt.data(
|
|
205
205
|
("", {}),
|
|
206
206
|
(" \t", {}),
|
|
207
|
+
(",-,", {}),
|
|
207
208
|
("foo=bar", {"foo": "bar"}),
|
|
208
209
|
(
|
|
209
210
|
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2",
|
|
210
211
|
{"dummy_key_1": "dummy_value_1", "dummy_key_2": "dummy_value_2"},
|
|
211
212
|
),
|
|
212
213
|
(
|
|
213
|
-
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2,dummy_key_3",
|
|
214
|
-
{
|
|
214
|
+
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2,dummy_key_3,-dummy_key_4",
|
|
215
|
+
{
|
|
216
|
+
"dummy_key_1": "dummy_value_1",
|
|
217
|
+
"dummy_key_2": "dummy_value_2",
|
|
218
|
+
"dummy_key_3": True,
|
|
219
|
+
"dummy_key_4": False,
|
|
220
|
+
},
|
|
215
221
|
),
|
|
216
222
|
(
|
|
217
223
|
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2,dummy_key_3=do not use spaces in strings CLI",
|
|
@@ -230,8 +236,42 @@ class StrUtilsTest(unittest.TestCase):
|
|
|
230
236
|
),
|
|
231
237
|
)
|
|
232
238
|
@ddt.unpack
|
|
233
|
-
def test_parse_params_string(self,
|
|
234
|
-
self.assertDictEqual(
|
|
239
|
+
def test_parse_params_string(self, data, expect):
|
|
240
|
+
self.assertDictEqual(expect, parse_params_string(data))
|
|
241
|
+
self.assertDictEqual(expect, parse_params_string(make_params_string(parse_params_string(data))))
|
|
242
|
+
|
|
243
|
+
@ddt.data(
|
|
244
|
+
(None, ""),
|
|
245
|
+
({}, ""),
|
|
246
|
+
({"foo": "bar"}, "foo=bar"),
|
|
247
|
+
(
|
|
248
|
+
{"dummy_key_1": "dummy_value_1", "dummy_key_2": "dummy_value_2"},
|
|
249
|
+
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2",
|
|
250
|
+
),
|
|
251
|
+
(
|
|
252
|
+
{"dummy_key_1": "dummy_value_1", "dummy_key_2": "dummy_value_2", "dummy_key_3": True, "dummy_key_4": False},
|
|
253
|
+
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2,dummy_key_3,-dummy_key_4",
|
|
254
|
+
),
|
|
255
|
+
(
|
|
256
|
+
{
|
|
257
|
+
"dummy_key_1": "dummy_value_1",
|
|
258
|
+
"dummy_key_2": "dummy_value_2",
|
|
259
|
+
"dummy_key_3": "do not use spaces in strings CLI",
|
|
260
|
+
},
|
|
261
|
+
"dummy_key_1=dummy_value_1,dummy_key_2=dummy_value_2,dummy_key_3=do not use spaces in strings CLI",
|
|
262
|
+
),
|
|
263
|
+
(
|
|
264
|
+
{
|
|
265
|
+
"dummy_key_1": "dummy_value_1_key=dummy_value_1_value",
|
|
266
|
+
"dummy_key_2": "dummy_value_2_key=dummy_value_2_value",
|
|
267
|
+
},
|
|
268
|
+
"dummy_key_1=dummy_value_1_key=dummy_value_1_value,dummy_key_2=dummy_value_2_key=dummy_value_2_value",
|
|
269
|
+
),
|
|
270
|
+
)
|
|
271
|
+
@ddt.unpack
|
|
272
|
+
def test_make_params_string(self, data, expect):
|
|
273
|
+
self.assertEqual(expect, make_params_string(data))
|
|
274
|
+
self.assertEqual(expect, make_params_string(parse_params_string(make_params_string(data))))
|
|
235
275
|
|
|
236
276
|
@ddt.data(
|
|
237
277
|
(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.bar
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.baz
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/resources/unittest/shutils/dir.foo/file.foo
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker/common/utils/dockerutils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/src/iker_python_common.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/config_test.py
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/dbutils_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/dtutils_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/logger_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/retry_test.py
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/s3utils_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/shutils_test.py
RENAMED
|
File without changes
|
{iker_python_common-1.0.13 → iker_python_common-1.0.15}/test/iker_tests/common/utils/span_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|