cloe-nessy 0.3.10__py3-none-any.whl → 0.3.11.1b0__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.
- cloe_nessy/models/table.py +25 -7
- cloe_nessy/models/volume.py +25 -7
- {cloe_nessy-0.3.10.dist-info → cloe_nessy-0.3.11.1b0.dist-info}/METADATA +1 -1
- {cloe_nessy-0.3.10.dist-info → cloe_nessy-0.3.11.1b0.dist-info}/RECORD +6 -6
- {cloe_nessy-0.3.10.dist-info → cloe_nessy-0.3.11.1b0.dist-info}/WHEEL +0 -0
- {cloe_nessy-0.3.10.dist-info → cloe_nessy-0.3.11.1b0.dist-info}/top_level.txt +0 -0
cloe_nessy/models/table.py
CHANGED
|
@@ -12,6 +12,11 @@ from pydantic import (
|
|
|
12
12
|
model_validator,
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
try:
|
|
16
|
+
from importlib.resources import files
|
|
17
|
+
except ImportError:
|
|
18
|
+
from importlib_resources import files # Python < 3.9 fallback
|
|
19
|
+
|
|
15
20
|
from ..logging import LoggerMixin
|
|
16
21
|
from ..utils.file_and_directory_handler import process_path
|
|
17
22
|
from .column import Column
|
|
@@ -247,14 +252,27 @@ class Table(TemplateLoaderMixin, ReadInstancesMixin, LoggerMixin):
|
|
|
247
252
|
Raises:
|
|
248
253
|
TemplateNotFound: If the template file is not found.
|
|
249
254
|
"""
|
|
250
|
-
|
|
251
|
-
template_name = "create_table.sql.j2"
|
|
252
|
-
|
|
255
|
+
# Use importlib.resources for robust template loading
|
|
253
256
|
try:
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
template_files = files("cloe_nessy.models") / "templates"
|
|
258
|
+
template_content = (template_files / "create_table.sql.j2").read_text()
|
|
259
|
+
|
|
260
|
+
# Create template directly from string content
|
|
261
|
+
from jinja2 import BaseLoader, Environment
|
|
262
|
+
|
|
263
|
+
env = Environment(loader=BaseLoader(), keep_trailing_newline=True)
|
|
264
|
+
template = env.from_string(template_content)
|
|
265
|
+
|
|
266
|
+
except (FileNotFoundError, AttributeError):
|
|
267
|
+
# Fallback to the old method if importlib.resources fails
|
|
268
|
+
templates = Path(__file__).parent / "templates"
|
|
269
|
+
template_name = "create_table.sql.j2"
|
|
270
|
+
try:
|
|
271
|
+
template = self.get_template(templates, template_name)
|
|
272
|
+
except TemplateNotFound as template_err:
|
|
273
|
+
self._console_logger.error(f"Template [ {template_name} ] not found.")
|
|
274
|
+
raise template_err
|
|
275
|
+
|
|
258
276
|
render = template.render(table=self, replace=replace)
|
|
259
277
|
return render
|
|
260
278
|
|
cloe_nessy/models/volume.py
CHANGED
|
@@ -4,6 +4,11 @@ from typing import Any
|
|
|
4
4
|
from jinja2 import TemplateNotFound
|
|
5
5
|
from pydantic import BaseModel, field_validator
|
|
6
6
|
|
|
7
|
+
try:
|
|
8
|
+
from importlib.resources import files
|
|
9
|
+
except ImportError:
|
|
10
|
+
from importlib_resources import files # Python < 3.9 fallback
|
|
11
|
+
|
|
7
12
|
from ..logging import LoggerMixin
|
|
8
13
|
from .mixins.template_loader_mixin import TemplateLoaderMixin
|
|
9
14
|
|
|
@@ -64,13 +69,26 @@ class Volume(TemplateLoaderMixin, LoggerMixin, BaseModel):
|
|
|
64
69
|
Returns:
|
|
65
70
|
The rendered create statement as a string.
|
|
66
71
|
"""
|
|
67
|
-
|
|
68
|
-
templates = Path(__file__).parent / "templates"
|
|
69
|
-
|
|
72
|
+
# Use importlib.resources for robust template loading
|
|
70
73
|
try:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
template_files = files("cloe_nessy.models") / "templates"
|
|
75
|
+
template_content = (template_files / "create_volume.sql.j2").read_text()
|
|
76
|
+
|
|
77
|
+
# Create template directly from string content
|
|
78
|
+
from jinja2 import BaseLoader, Environment
|
|
79
|
+
|
|
80
|
+
env = Environment(loader=BaseLoader(), keep_trailing_newline=True)
|
|
81
|
+
template = env.from_string(template_content)
|
|
82
|
+
|
|
83
|
+
except (FileNotFoundError, AttributeError):
|
|
84
|
+
# Fallback to the old method if importlib.resources fails
|
|
85
|
+
template_name = "create_volume.sql.j2"
|
|
86
|
+
templates = Path(__file__).parent / "templates"
|
|
87
|
+
try:
|
|
88
|
+
template = self.get_template(templates, template_name)
|
|
89
|
+
except TemplateNotFound as template_err:
|
|
90
|
+
self._console_logger.error(f"Template [ {template_name} ] not found.")
|
|
91
|
+
raise template_err
|
|
92
|
+
|
|
75
93
|
render = template.render(volume=self, if_not_exists=if_not_exists)
|
|
76
94
|
return render
|
|
@@ -42,9 +42,9 @@ cloe_nessy/models/column.py,sha256=53fBwRnino72XKACsHZpN9QfCBqqSXyKLHZlM0huumg,1
|
|
|
42
42
|
cloe_nessy/models/constraint.py,sha256=hsFlhn4n928z81O3dl3v5bMetewPWzMjkJK3_4kASSM,178
|
|
43
43
|
cloe_nessy/models/foreign_key.py,sha256=DwRVHs9sShqqPV-NL7ow_3AmPPWX0Od26yZn_I565pU,1001
|
|
44
44
|
cloe_nessy/models/schema.py,sha256=yUrjjEhAH5zbCymE67Az_jPnVB8hGO-_UNfqzeZCD_Y,3376
|
|
45
|
-
cloe_nessy/models/table.py,sha256=
|
|
45
|
+
cloe_nessy/models/table.py,sha256=zw1Ika_dQCBNla60EGCo0PlkbLqJ1jp4orD28BLTV18,12861
|
|
46
46
|
cloe_nessy/models/types.py,sha256=XRbuJGdTNa6aXyE3IAzs_J9gVjbfkzMDLfGl-k6jI_4,223
|
|
47
|
-
cloe_nessy/models/volume.py,sha256=
|
|
47
|
+
cloe_nessy/models/volume.py,sha256=su_r0pzKf58qzkga9XJyObIb36V3_4rDWxc8fXbdS2U,3225
|
|
48
48
|
cloe_nessy/models/adapter/__init__.py,sha256=m36W_mqwB3dCYnCIt0fLOSHS4E1VU8FRGoaum4Gf95o,90
|
|
49
49
|
cloe_nessy/models/adapter/unity_catalog_adapter.py,sha256=a-14Ys-AevVYQd0xeJU1syLxjT5Wzo4uog1hFSEs76M,12651
|
|
50
50
|
cloe_nessy/models/mixins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -92,7 +92,7 @@ cloe_nessy/settings/__init__.py,sha256=ZbkneO3WaKOxon7qHFHnou7EnBOSnBFyKMDZblIEv
|
|
|
92
92
|
cloe_nessy/settings/settings.py,sha256=I4n129lrujriW-d8q4as2Kb4_kI932ModfZ5Ow_UpVM,3653
|
|
93
93
|
cloe_nessy/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
94
94
|
cloe_nessy/utils/file_and_directory_handler.py,sha256=r2EVt9xG81p6ScaJCwETC5an6pMT6WseB0jMOR-JlpU,602
|
|
95
|
-
cloe_nessy-0.3.
|
|
96
|
-
cloe_nessy-0.3.
|
|
97
|
-
cloe_nessy-0.3.
|
|
98
|
-
cloe_nessy-0.3.
|
|
95
|
+
cloe_nessy-0.3.11.1b0.dist-info/METADATA,sha256=ugc1ty-RCAN4gpYDV6l0iOldlxVnx0T61YsiSvPi4PM,3166
|
|
96
|
+
cloe_nessy-0.3.11.1b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
97
|
+
cloe_nessy-0.3.11.1b0.dist-info/top_level.txt,sha256=Z7izn8HmQpg2wBUb-0jzaKlYKMU7Ypzuc9__9vPtW_I,11
|
|
98
|
+
cloe_nessy-0.3.11.1b0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|