iker-python-common 1.0.31__tar.gz → 1.0.33__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.31 → iker_python_common-1.0.33}/PKG-INFO +3 -2
  2. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/pyproject.toml +2 -1
  3. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/dbutils.py +19 -8
  4. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/PKG-INFO +3 -2
  5. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/requires.txt +2 -1
  6. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/dtutils_test.py +33 -1
  7. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/.editorconfig +0 -0
  8. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/.github/workflows/pr.yml +0 -0
  9. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/.github/workflows/push.yml +0 -0
  10. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/.gitignore +0 -0
  11. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/MANIFEST.in +0 -0
  12. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/README.md +0 -0
  13. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/VERSION +0 -0
  14. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/config/config.cfg +0 -0
  15. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/csv/data.csv +0 -0
  16. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/csv/data.tsv +0 -0
  17. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.baz/file.bar.baz +0 -0
  18. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.baz/file.foo.bar +0 -0
  19. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.baz/file.foo.baz +0 -0
  20. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/dir.foo.bar/dir.foo.bar.baz/file.foo.bar.baz +0 -0
  21. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.bar.baz +0 -0
  22. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.bar +0 -0
  23. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/dir.foo.bar/file.foo.baz +0 -0
  24. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/file.bar +0 -0
  25. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/file.baz +0 -0
  26. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/resources/unittest/shutils/dir.foo/file.foo +0 -0
  27. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/setup.cfg +0 -0
  28. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/setup.py +0 -0
  29. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/__init__.py +0 -0
  30. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/__init__.py +0 -0
  31. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/argutils.py +0 -0
  32. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/config.py +0 -0
  33. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/csv.py +0 -0
  34. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/dockerutils.py +0 -0
  35. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/dtutils.py +0 -0
  36. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/funcutils.py +0 -0
  37. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/jsonutils.py +0 -0
  38. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/logger.py +0 -0
  39. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/numutils.py +0 -0
  40. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/randutils.py +0 -0
  41. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/retry.py +0 -0
  42. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/s3utils.py +0 -0
  43. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/sequtils.py +0 -0
  44. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/shutils.py +0 -0
  45. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/span.py +0 -0
  46. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/strutils.py +0 -0
  47. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker/common/utils/testutils.py +0 -0
  48. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/SOURCES.txt +0 -0
  49. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/dependency_links.txt +0 -0
  50. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/not-zip-safe +0 -0
  51. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/src/iker_python_common.egg-info/top_level.txt +0 -0
  52. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_test.py +0 -0
  53. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/__init__.py +0 -0
  54. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/argutils_test.py +0 -0
  55. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/config_test.py +0 -0
  56. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/csv_test.py +0 -0
  57. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/dbutils_test.py +0 -0
  58. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/dockerutils_test.py +0 -0
  59. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/funcutils_test.py +0 -0
  60. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/jsonutils_test.py +0 -0
  61. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/logger_test.py +0 -0
  62. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/numutils_test.py +0 -0
  63. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/randutils_test.py +0 -0
  64. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/retry_test.py +0 -0
  65. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/s3utils_test.py +0 -0
  66. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/sequtils_test.py +0 -0
  67. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/shutils_test.py +0 -0
  68. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/span_test.py +0 -0
  69. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/strutils_test.py +0 -0
  70. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/common/utils/testutils_test.py +0 -0
  71. {iker_python_common-1.0.31 → iker_python_common-1.0.33}/test/iker_tests/docker_fixtures.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iker-python-common
3
- Version: 1.0.31
3
+ Version: 1.0.33
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -11,7 +11,7 @@ Requires-Dist: docker>=7.1
11
11
  Requires-Dist: numpy>=1.26
12
12
  Requires-Dist: psycopg>=3.2
13
13
  Requires-Dist: pymysql>=1.1
14
- Requires-Dist: sqlalchemy>=2.0
14
+ Requires-Dist: sqlalchemy>=1.4
15
15
  Provides-Extra: test
16
16
  Requires-Dist: ddt>=1.7; extra == "test"
17
17
  Requires-Dist: moto[all,ec2,s3]>=5.0; extra == "test"
@@ -20,3 +20,4 @@ Requires-Dist: pytest-mysql>=3.0; extra == "test"
20
20
  Requires-Dist: pytest-order>=1.3; extra == "test"
21
21
  Requires-Dist: pytest-postgresql>=6.1; extra == "test"
22
22
  Requires-Dist: pytest>=8.3; extra == "test"
23
+ Requires-Dist: sqlalchemy>=2.0; extra == "test"
@@ -22,7 +22,7 @@ dependencies = [
22
22
  "numpy>=1.26",
23
23
  "psycopg>=3.2",
24
24
  "pymysql>=1.1",
25
- "sqlalchemy>=2.0",
25
+ "sqlalchemy>=1.4",
26
26
  ]
27
27
 
28
28
  [project.optional-dependencies]
@@ -34,6 +34,7 @@ test = [
34
34
  "pytest-order>=1.3",
35
35
  "pytest-postgresql>=6.1",
36
36
  "pytest>=8.3",
37
+ "sqlalchemy>=2.0",
37
38
  ]
38
39
 
39
40
  [tool.setuptools]
@@ -3,6 +3,7 @@ import dataclasses
3
3
  import urllib.parse
4
4
  from typing import Any
5
5
 
6
+ import packaging.version
6
7
  import psycopg
7
8
  import pymysql
8
9
  import sqlalchemy
@@ -90,10 +91,18 @@ class ConnectionMaker(object):
90
91
  def make_session(self, **kwargs) -> contextlib.AbstractContextManager[sqlalchemy.orm.Session]:
91
92
  return contextlib.closing(sqlalchemy.orm.sessionmaker(self.engine, **{**self.session_opts, **kwargs})())
92
93
 
93
- def create_model(self, orm_base: type[sqlalchemy.orm.DeclarativeBase]):
94
+ def create_model(self, orm_base):
95
+ if packaging.version.parse(sqlalchemy.__version__) >= packaging.version.parse("2"):
96
+ if not isinstance(orm_base, type) or not issubclass(orm_base, sqlalchemy.orm.DeclarativeBase):
97
+ raise TypeError("not a subclass of 'sqlalchemy.orm.DeclarativeBase'")
98
+
94
99
  orm_base.metadata.create_all(self.engine)
95
100
 
96
- def drop_model(self, orm_base: type[sqlalchemy.orm.DeclarativeBase]):
101
+ def drop_model(self, orm_base):
102
+ if packaging.version.parse(sqlalchemy.__version__) >= packaging.version.parse("2"):
103
+ if not isinstance(orm_base, type) or not issubclass(orm_base, sqlalchemy.orm.DeclarativeBase):
104
+ raise TypeError("not a subclass of 'sqlalchemy.orm.DeclarativeBase'")
105
+
97
106
  orm_base.metadata.drop_all(self.engine)
98
107
 
99
108
  def execute(self, sql: str, **params):
@@ -133,17 +142,19 @@ class ConnectionMaker(object):
133
142
  DBAdapter = ConnectionMaker
134
143
 
135
144
 
136
- def orm_to_dict(orm: sqlalchemy.orm.DeclarativeBase, exclude: set[str] = None) -> dict[str, Any]:
137
- if not isinstance(orm, sqlalchemy.orm.DeclarativeBase):
138
- raise TypeError('not a SQLAlchemy ORM declarative base')
145
+ def orm_to_dict(orm, exclude: set[str] = None) -> dict[str, Any]:
146
+ if packaging.version.parse(sqlalchemy.__version__) >= packaging.version.parse("2"):
147
+ if not isinstance(orm, sqlalchemy.orm.DeclarativeBase):
148
+ raise TypeError("not an instance of 'sqlalchemy.orm.DeclarativeBase'")
139
149
 
140
150
  mapper = sqlalchemy.inspect(type(orm))
141
151
  return dict((c.key, getattr(orm, c.key)) for c in mapper.columns if c.key not in (exclude or set()))
142
152
 
143
153
 
144
- def orm_clone(orm: sqlalchemy.orm.DeclarativeBase, exclude: set[str] = None, no_autoincrement: bool = False):
145
- if not isinstance(orm, sqlalchemy.orm.DeclarativeBase):
146
- raise TypeError('not a SQLAlchemy ORM declarative base')
154
+ def orm_clone(orm, exclude: set[str] = None, no_autoincrement: bool = False):
155
+ if packaging.version.parse(sqlalchemy.__version__) >= packaging.version.parse("2"):
156
+ if not isinstance(orm, sqlalchemy.orm.DeclarativeBase):
157
+ raise TypeError("not an instance of 'sqlalchemy.orm.DeclarativeBase'")
147
158
 
148
159
  mapper = sqlalchemy.inspect(type(orm))
149
160
  exclude = exclude or (set(c.key for c in mapper.columns if c.autoincrement is True) if no_autoincrement else set())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iker-python-common
3
- Version: 1.0.31
3
+ Version: 1.0.33
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: 3.11
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -11,7 +11,7 @@ Requires-Dist: docker>=7.1
11
11
  Requires-Dist: numpy>=1.26
12
12
  Requires-Dist: psycopg>=3.2
13
13
  Requires-Dist: pymysql>=1.1
14
- Requires-Dist: sqlalchemy>=2.0
14
+ Requires-Dist: sqlalchemy>=1.4
15
15
  Provides-Extra: test
16
16
  Requires-Dist: ddt>=1.7; extra == "test"
17
17
  Requires-Dist: moto[all,ec2,s3]>=5.0; extra == "test"
@@ -20,3 +20,4 @@ Requires-Dist: pytest-mysql>=3.0; extra == "test"
20
20
  Requires-Dist: pytest-order>=1.3; extra == "test"
21
21
  Requires-Dist: pytest-postgresql>=6.1; extra == "test"
22
22
  Requires-Dist: pytest>=8.3; extra == "test"
23
+ Requires-Dist: sqlalchemy>=2.0; extra == "test"
@@ -3,7 +3,7 @@ docker>=7.1
3
3
  numpy>=1.26
4
4
  psycopg>=3.2
5
5
  pymysql>=1.1
6
- sqlalchemy>=2.0
6
+ sqlalchemy>=1.4
7
7
 
8
8
  [test]
9
9
  ddt>=1.7
@@ -13,3 +13,4 @@ pytest-mysql>=3.0
13
13
  pytest-order>=1.3
14
14
  pytest-postgresql>=6.1
15
15
  pytest>=8.3
16
+ sqlalchemy>=2.0
@@ -38,8 +38,24 @@ class DtUtilsTest(unittest.TestCase):
38
38
  @ddt.data(
39
39
  (dt_utc(1970, 1, 1), 0.0),
40
40
  (dt_utc(1969, 12, 31, 23, 59, 59), -1.0),
41
+ (dt_utc(1969, 12, 31, 23, 59, 59, 1), -0.999999),
42
+ (dt_utc(1969, 12, 31, 23, 59, 59, 1000), -0.999),
43
+ (dt_utc(1969, 12, 31, 23, 59, 59, 999999), -0.000001),
41
44
  (dt_utc(1970, 1, 1, 0, 0, 1), 1.0),
45
+ (dt_utc(1970, 1, 1, 0, 0, 1, 1), 1.000001),
46
+ (dt_utc(1970, 1, 1, 0, 0, 1, 1000), 1.001),
47
+ (dt_utc(1970, 1, 1, 0, 0, 1, 999999), 1.999999),
48
+ (dt_utc(1970, 1, 1, 0, 0, 0, 1), 0.000001),
42
49
  (dt_utc(1970, 1, 1, 0, 0, 0, 1000), 0.001),
50
+ (dt_utc(1970, 1, 1, 0, 0, 0, 999999), 0.999999),
51
+ (dt_utc(2025, 1, 1, 0, 0, 0), 1735689600.0),
52
+ (dt_utc(2025, 1, 1, 0, 0, 0, 1), 1735689600.000001),
53
+ (dt_utc(2025, 1, 1, 0, 0, 0, 1000), 1735689600.001),
54
+ (dt_utc(2025, 1, 1, 0, 0, 0, 999999), 1735689600.999999),
55
+ (dt_utc(2100, 1, 1, 0, 0, 0), 4102444800.0),
56
+ (dt_utc(2100, 1, 1, 0, 0, 0, 1), 4102444800.000001),
57
+ (dt_utc(2100, 1, 1, 0, 0, 0, 1000), 4102444800.001),
58
+ (dt_utc(2100, 1, 1, 0, 0, 0, 999999), 4102444800.999999),
43
59
  )
44
60
  @ddt.unpack
45
61
  def test_dt_to_ts(self, data, expect):
@@ -48,11 +64,27 @@ class DtUtilsTest(unittest.TestCase):
48
64
  @ddt.data(
49
65
  (0.0, dt_utc(1970, 1, 1)),
50
66
  (-1.0, dt_utc(1969, 12, 31, 23, 59, 59)),
67
+ (-0.999999, dt_utc(1969, 12, 31, 23, 59, 59, 1)),
68
+ (-0.999, dt_utc(1969, 12, 31, 23, 59, 59, 1000)),
69
+ (-0.000001, dt_utc(1969, 12, 31, 23, 59, 59, 999999)),
51
70
  (1.0, dt_utc(1970, 1, 1, 0, 0, 1)),
71
+ (1.000001, dt_utc(1970, 1, 1, 0, 0, 1, 1)),
72
+ (1.001, dt_utc(1970, 1, 1, 0, 0, 1, 1000)),
73
+ (1.999999, dt_utc(1970, 1, 1, 0, 0, 1, 999999)),
74
+ (0.000001, dt_utc(1970, 1, 1, 0, 0, 0, 1)),
52
75
  (0.001, dt_utc(1970, 1, 1, 0, 0, 0, 1000)),
76
+ (0.999999, dt_utc(1970, 1, 1, 0, 0, 0, 999999)),
77
+ (1735689600.0, dt_utc(2025, 1, 1, 0, 0, 0)),
78
+ (1735689600.000001, dt_utc(2025, 1, 1, 0, 0, 0, 1)),
79
+ (1735689600.001, dt_utc(2025, 1, 1, 0, 0, 0, 1000)),
80
+ (1735689600.999999, dt_utc(2025, 1, 1, 0, 0, 0, 999999)),
81
+ (4102444800.0, dt_utc(2100, 1, 1, 0, 0, 0)),
82
+ (4102444800.000001, dt_utc(2100, 1, 1, 0, 0, 0, 1)),
83
+ (4102444800.001, dt_utc(2100, 1, 1, 0, 0, 0, 1000)),
84
+ (4102444800.999999, dt_utc(2100, 1, 1, 0, 0, 0, 999999)),
53
85
  )
54
86
  @ddt.unpack
55
- def test_dt_to_from(self, data, expect):
87
+ def test_dt_from_ts(self, data, expect):
56
88
  self.assertEqual(expect, dt_from_ts(data))
57
89
 
58
90
  @ddt.data(