iker-python-common 1.0.26__tar.gz → 1.0.28__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.
Files changed (71) hide show
  1. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/PKG-INFO +1 -1
  2. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/argutils.py +1 -1
  3. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/dockerutils.py +13 -14
  4. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/dtutils.py +1 -1
  5. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/randutils.py +11 -9
  6. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/strutils.py +3 -3
  7. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/testutils.py +8 -8
  8. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/PKG-INFO +1 -1
  9. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/dockerutils_test.py +3 -3
  10. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/.editorconfig +0 -0
  11. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/.github/workflows/pr.yml +0 -0
  12. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/.github/workflows/push.yml +0 -0
  13. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/.gitignore +0 -0
  14. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/MANIFEST.in +0 -0
  15. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/README.md +0 -0
  16. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/VERSION +0 -0
  17. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/pyproject.toml +0 -0
  18. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/config/config.cfg +0 -0
  19. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/csv/data.csv +0 -0
  20. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/csv/data.tsv +0 -0
  21. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.baz/file.bar.baz +0 -0
  22. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.baz/file.foo.bar +0 -0
  23. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.baz/file.foo.baz +0 -0
  24. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  25. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  26. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  27. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  28. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/file.bar +0 -0
  29. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/file.baz +0 -0
  30. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/resources/unittest/shutils/dir.foo/file.foo +0 -0
  31. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/setup.cfg +0 -0
  32. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/setup.py +0 -0
  33. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/__init__.py +0 -0
  34. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/__init__.py +0 -0
  35. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/config.py +0 -0
  36. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/csv.py +0 -0
  37. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/dbutils.py +0 -0
  38. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/funcutils.py +0 -0
  39. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/jsonutils.py +0 -0
  40. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/logger.py +0 -0
  41. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/numutils.py +0 -0
  42. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/retry.py +0 -0
  43. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/s3utils.py +0 -0
  44. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/sequtils.py +0 -0
  45. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/shutils.py +0 -0
  46. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker/common/utils/span.py +0 -0
  47. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/SOURCES.txt +0 -0
  48. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/dependency_links.txt +0 -0
  49. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/not-zip-safe +0 -0
  50. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/requires.txt +0 -0
  51. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/src/iker_python_common.egg-info/top_level.txt +0 -0
  52. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_test.py +0 -0
  53. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/__init__.py +0 -0
  54. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/argutils_test.py +0 -0
  55. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/config_test.py +0 -0
  56. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/csv_test.py +0 -0
  57. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/dbutils_test.py +0 -0
  58. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/dtutils_test.py +0 -0
  59. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/funcutils_test.py +0 -0
  60. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/jsonutils_test.py +0 -0
  61. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/logger_test.py +0 -0
  62. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/numutils_test.py +0 -0
  63. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/randutils_test.py +0 -0
  64. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/retry_test.py +0 -0
  65. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/s3utils_test.py +0 -0
  66. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/sequtils_test.py +0 -0
  67. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/shutils_test.py +0 -0
  68. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/span_test.py +0 -0
  69. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/strutils_test.py +0 -0
  70. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/common/utils/testutils_test.py +0 -0
  71. {iker_python_common-1.0.26 → iker_python_common-1.0.28}/test/iker_tests/docker_fixtures.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: iker-python-common
3
- Version: 1.0.26
3
+ Version: 1.0.28
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -63,7 +63,7 @@ class ParserTree(object):
63
63
  else:
64
64
  known_args_namespace, unknown_args = self.root_node.parser.parse_known_args(args)
65
65
  if len(unknown_args or []) > 0:
66
- raise argparse.ArgumentError(None, "unrecognized arguments: %s" % " ".join(unknown_args))
66
+ raise argparse.ArgumentError(None, f"unrecognized arguments '{unknown_args}'")
67
67
 
68
68
  command_pairs = []
69
69
  namespace = argparse.Namespace()
@@ -1,6 +1,6 @@
1
1
  import contextlib
2
2
  import re
3
- from collections.abc import Generator, Iterable
3
+ from collections.abc import Generator, Iterator
4
4
  from dataclasses import dataclass
5
5
  from typing import Any
6
6
 
@@ -89,7 +89,7 @@ def docker_build_image(
89
89
  path: str,
90
90
  dockerfile: str,
91
91
  build_args: dict[str, str],
92
- ) -> tuple[docker.models.images.Image, Iterable[Any]]:
92
+ ) -> tuple[docker.models.images.Image, Iterator[dict[str, str]]]:
93
93
  try:
94
94
  return client.images.build(tag=tag,
95
95
  path=path,
@@ -188,21 +188,20 @@ def docker_run_detached(
188
188
  except docker.errors.DockerException:
189
189
  raise
190
190
  finally:
191
- if container_model is None:
192
- return
193
- try:
194
- if container_model.status != "exited":
191
+ if container_model is not None:
192
+ try:
193
+ if container_model.status != "exited":
194
+ try:
195
+ container_model.stop()
196
+ except docker.errors.DockerException:
197
+ pass
198
+ container_model.wait()
195
199
  try:
196
- container_model.stop()
200
+ container_model.remove()
197
201
  except docker.errors.DockerException:
198
202
  pass
199
- container_model.wait()
200
- try:
201
- container_model.remove()
202
- except docker.errors.DockerException:
203
- pass
204
- except Exception:
205
- raise
203
+ except Exception:
204
+ raise
206
205
 
207
206
  try:
208
207
  run_args = kwargs.copy()
@@ -151,7 +151,7 @@ def dt_parse(dt_str: str, fmt_str: str | list[str] | tuple[str, ...]) -> datetim
151
151
  return dt_parse(dt_str, s)
152
152
  except ValueError:
153
153
  pass
154
- raise ValueError("time data <%s> does not match the given formats" % dt_str)
154
+ raise ValueError(f"time data '{dt_str}' does not match the given formats")
155
155
  else:
156
156
  raise ValueError("malformed format")
157
157
 
@@ -8,6 +8,7 @@ from typing import TypeVar
8
8
 
9
9
  from iker.common.utils.dtutils import dt_utc_max, dt_utc_min
10
10
  from iker.common.utils.funcutils import memorized, singleton
11
+ from iker.common.utils.jsonutils import JsonType
11
12
  from iker.common.utils.sequtils import head_or_none
12
13
 
13
14
  __all__ = [
@@ -39,16 +40,16 @@ class Randomizer(object):
39
40
  return self.random.getrandbits(1) == 1
40
41
 
41
42
  def next_int(self, lo: int = 0, hi: int = max_int()) -> int:
42
- assert lo < hi, "The lower bound must be smaller than the upper bound"
43
+ assert lo < hi, "the lower bound must be smaller than the upper bound"
43
44
  return self.random.randrange(lo, hi)
44
45
 
45
46
  def next_float(self, lo: float = 0.0, hi: float = 1.0) -> float:
46
- assert lo <= hi, "The lower bound must be not greater than the upper bound"
47
- assert not math.isinf(hi - lo), "The range between the lower bound and the upper bound exceeded the float range"
47
+ assert lo <= hi, "the lower bound must be not greater than the upper bound"
48
+ assert not math.isinf(hi - lo), "the range between the lower bound and the upper bound exceeded the float range"
48
49
  return lo + (hi - lo) * self.random.random()
49
50
 
50
51
  def next_fixed(self, precision: int = 7) -> float:
51
- assert precision >= 0, "The precision must be non-negative"
52
+ assert precision >= 0, "the precision must be non-negative"
52
53
  width = 2 ** precision
53
54
  return self.next_int(0, width) / width
54
55
 
@@ -56,7 +57,7 @@ class Randomizer(object):
56
57
  return self.random.gauss(mu, sigma)
57
58
 
58
59
  def random_string(self, chars: str, length: int) -> str:
59
- assert length >= 0, "Length of the random string must be non-negative"
60
+ assert length >= 0, "length of the random string must be non-negative"
60
61
  if length == 0:
61
62
  return ""
62
63
  return "".join(self.random.choices(chars, k=length))
@@ -75,14 +76,15 @@ class Randomizer(object):
75
76
  def random_oct(self, length: int) -> str:
76
77
  return self.random_string(string.octdigits, length).upper()
77
78
 
78
- def random_unit_vector(self, dim: int) -> list[float]:
79
- assert dim > 0, "Dimension of the random unit vector must be positive"
79
+ def random_unit_vector(self, length: int) -> list[float]:
80
+ assert length > 0, "length of the random unit vector must be positive"
80
81
  while True:
81
- v = [self.next_gaussian() for _ in range(dim)]
82
+ v = [self.next_gaussian() for _ in range(length)]
82
83
  n = sum(x * x for x in v) ** 0.5
83
84
  if n < 1.0e-9:
84
85
  continue
85
86
  return [x / n for x in v]
87
+ return [1.0]
86
88
 
87
89
  def random_datetime(
88
90
  self,
@@ -117,7 +119,7 @@ class Randomizer(object):
117
119
  key_length: int = 5,
118
120
  value_chars: str = string.ascii_letters,
119
121
  value_length: int = 5,
120
- ) -> object:
122
+ ) -> JsonType:
121
123
  choices = [list, dict, int, float, bool, str, None]
122
124
  root_choices = [list, dict]
123
125
  leaf_choices = [int, float, bool, str, None]
@@ -62,11 +62,11 @@ def parse_bool(v: Any) -> bool:
62
62
  return True
63
63
  if v.lower() in ["false", "no", "off", "0", "n"]:
64
64
  return False
65
- raise ValueError("not a valid boolean literal <%s>" % v)
65
+ raise ValueError(f"not a valid boolean literal '{v}'")
66
66
  elif isinstance(v, bool):
67
67
  return v
68
68
  else:
69
- raise ValueError("type <%s> is not convertible to bool" % type(v))
69
+ raise ValueError(f"type '{type(v)}' is not convertible to bool")
70
70
 
71
71
 
72
72
  def parse_bool_or(v: Any, default: bool | None = False) -> bool | None:
@@ -154,7 +154,7 @@ def parse_params_string(
154
154
  continue
155
155
  result[key] = str_parser(value)
156
156
  case _:
157
- raise ValueError("malformed param <%s>" % param)
157
+ raise ValueError(f"malformed param '{param}'")
158
158
  return result
159
159
 
160
160
 
@@ -113,42 +113,42 @@ class CalleeMock(ABC):
113
113
  return list(index for index, c in enumerate(self.calls) if c == call)
114
114
 
115
115
  def assert_not_called(self):
116
- assert self.count_calls() == 0, "Failed not called"
116
+ assert self.count_calls() == 0, "failed not called"
117
117
 
118
118
  def assert_called(self):
119
- assert self.count_calls() > 0, "Failed called"
119
+ assert self.count_calls() > 0, "failed called"
120
120
 
121
121
  def assert_called_once(self):
122
- assert self.count_calls() == 1, "Failed called once"
122
+ assert self.count_calls() == 1, "failed called once"
123
123
 
124
124
  def assert_called_times(self, count: int):
125
- assert self.count_calls() == count, "Failed called {} times".format(count)
125
+ assert self.count_calls() == count, f"failed called {count} times"
126
126
 
127
127
  def assert_not_called_with(self):
128
128
  def assertion(*args, **kwargs):
129
129
  call = (args, kwargs)
130
- assert self.count_calls_with(call) == 0, "Failed not called with {}".format(call)
130
+ assert self.count_calls_with(call) == 0, f"failed not called with {call}"
131
131
 
132
132
  return assertion
133
133
 
134
134
  def assert_called_with(self):
135
135
  def assertion(*args, **kwargs):
136
136
  call = (args, kwargs)
137
- assert self.count_calls_with(call) > 0, "Failed called with {}".format(call)
137
+ assert self.count_calls_with(call) > 0, f"failed called with {call}"
138
138
 
139
139
  return assertion
140
140
 
141
141
  def assert_called_once_with(self):
142
142
  def assertion(*args, **kwargs):
143
143
  call = (args, kwargs)
144
- assert self.count_calls_with(call) == 1, "Failed called once with {}".format(call)
144
+ assert self.count_calls_with(call) == 1, f"failed called once with {call}"
145
145
 
146
146
  return assertion
147
147
 
148
148
  def assert_called_times_with(self, count: int):
149
149
  def assertion(*args, **kwargs):
150
150
  call = (args, kwargs)
151
- assert self.count_calls_with(call) == count, "Failed called {} times with {}".format(count, call)
151
+ assert self.count_calls_with(call) == count, f"failed called {count} times with {call}"
152
152
 
153
153
  return assertion
154
154
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: iker-python-common
3
- Version: 1.0.26
3
+ Version: 1.0.28
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -189,7 +189,7 @@ class DockerUtilsTest(unittest.TestCase):
189
189
  labels_callee=return_callee("dummy_labels"))
190
190
  mock_docker_client.return_value.images.build.return_value = (
191
191
  mock_docker_image,
192
- {"dummy_key": "dummy_value"},
192
+ [{"dummy-log-key": "dummy-log-value"}],
193
193
  )
194
194
 
195
195
  image_model, build_logs = docker_build_image(mock_docker_client.return_value,
@@ -201,7 +201,7 @@ class DockerUtilsTest(unittest.TestCase):
201
201
  self.assertEqual(image_model.id, "dummy_image")
202
202
  self.assertEqual(image_model.tags, "dummy_tags")
203
203
  self.assertEqual(image_model.labels, "dummy_labels")
204
- self.assertEqual(build_logs, {"dummy_key": "dummy_value"})
204
+ self.assertEqual(build_logs, [{"dummy-log-key": "dummy-log-value"}])
205
205
 
206
206
  mock_docker_client.return_value.images.build.assert_called_with(tag="dummy_tag",
207
207
  path="dummy_path",
@@ -212,7 +212,7 @@ class DockerUtilsTest(unittest.TestCase):
212
212
  nocache=True)
213
213
 
214
214
  @ddt.data(
215
- (docker.errors.BuildError("dummy reason", iter([{"dummy-log-key": "dummy log"}])),),
215
+ (docker.errors.BuildError("dummy reason", iter([{"dummy-log-key": "dummy-log-value"}])),),
216
216
  (docker.errors.APIError("dummy message"),),
217
217
  (Exception(),),
218
218
  )