dbt-common 1.11.0__py3-none-any.whl → 1.12.0__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.
- dbt_common/__about__.py +1 -1
- dbt_common/clients/_jinja_blocks.py +41 -2
- {dbt_common-1.11.0.dist-info → dbt_common-1.12.0.dist-info}/METADATA +2 -3
- {dbt_common-1.11.0.dist-info → dbt_common-1.12.0.dist-info}/RECORD +6 -6
- {dbt_common-1.11.0.dist-info → dbt_common-1.12.0.dist-info}/WHEEL +0 -0
- {dbt_common-1.11.0.dist-info → dbt_common-1.12.0.dist-info}/licenses/LICENSE +0 -0
dbt_common/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "1.
|
1
|
+
version = "1.12.0"
|
@@ -1,6 +1,7 @@
|
|
1
|
+
import dataclasses
|
1
2
|
import re
|
2
3
|
from collections import namedtuple
|
3
|
-
from typing import Iterator, List, Optional, Set, Union
|
4
|
+
from typing import Dict, Iterator, List, Optional, Set, Union
|
4
5
|
|
5
6
|
from dbt_common.exceptions import (
|
6
7
|
BlockDefinitionNotAtTopError,
|
@@ -104,11 +105,25 @@ STRING_PATTERN = regex(r"(?P<string>('([^'\\]*(?:\\.[^'\\]*)*)'|" r'"([^"\\]*(?:
|
|
104
105
|
QUOTE_START_PATTERN = regex(r"""(?P<quote>(['"]))""")
|
105
106
|
|
106
107
|
|
108
|
+
@dataclasses.dataclass
|
109
|
+
class PositionedMatch:
|
110
|
+
"""This class is used to cache search information, accelerating TagIterator.
|
111
|
+
It records the result of searching a string from the start_pos and also
|
112
|
+
the position of the first match, or None if there is no match."""
|
113
|
+
|
114
|
+
start_pos: int
|
115
|
+
match: Optional[re.Match]
|
116
|
+
|
117
|
+
|
107
118
|
class TagIterator:
|
108
119
|
def __init__(self, text: str) -> None:
|
109
120
|
self.text: str = text
|
110
121
|
self.pos: int = 0
|
111
122
|
|
123
|
+
# A cache of the most recent matches seen for each pattern, maintained
|
124
|
+
# in order to avoid slowly re-searching long inputs many times.
|
125
|
+
self._past_matches: Dict[re.Pattern, PositionedMatch] = {}
|
126
|
+
|
112
127
|
def linepos(self, end: Optional[int] = None) -> str:
|
113
128
|
"""Return relative position in line.
|
114
129
|
|
@@ -130,7 +145,31 @@ class TagIterator:
|
|
130
145
|
self.pos -= amount
|
131
146
|
|
132
147
|
def _search(self, pattern: re.Pattern) -> Optional[re.Match]:
|
133
|
-
|
148
|
+
# Check to see if we have cached a search for this pattern already.
|
149
|
+
positioned_match = self._past_matches.get(pattern)
|
150
|
+
|
151
|
+
if positioned_match is None or positioned_match.start_pos > self.pos:
|
152
|
+
# We did not have a cached search, or we did, but it was done at a location
|
153
|
+
# further along in the string and can't be used. Do a search and cache it.
|
154
|
+
match = pattern.search(self.text, self.pos)
|
155
|
+
self._past_matches[pattern] = PositionedMatch(self.pos, match)
|
156
|
+
else:
|
157
|
+
# We have a cached search and its start position falls before (or at) the
|
158
|
+
# current search position...
|
159
|
+
if positioned_match.match is None:
|
160
|
+
# ...but there is no match in the rest of the text.
|
161
|
+
match = None
|
162
|
+
elif positioned_match.match.start() >= self.pos:
|
163
|
+
# ...and there is a match we can reuse, because we have not yet passed
|
164
|
+
# the start position of the match. It's still the next match.
|
165
|
+
match = positioned_match.match
|
166
|
+
else:
|
167
|
+
# ...but we have passed the start of the cached match, and need to do a
|
168
|
+
# new search from our current position and cache it.
|
169
|
+
match = pattern.search(self.text, self.pos)
|
170
|
+
self._past_matches[pattern] = PositionedMatch(self.pos, match)
|
171
|
+
|
172
|
+
return match
|
134
173
|
|
135
174
|
def _match(self, pattern: re.Pattern) -> Optional[re.Match]:
|
136
175
|
return pattern.match(self.text, self.pos)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: dbt-common
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.12.0
|
4
4
|
Summary: The shared common utilities that dbt-core and adapter implementations use
|
5
5
|
Project-URL: Homepage, https://github.com/dbt-labs/dbt-common
|
6
6
|
Project-URL: Repository, https://github.com/dbt-labs/dbt-common.git
|
@@ -16,14 +16,13 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
16
16
|
Classifier: Operating System :: Microsoft :: Windows
|
17
17
|
Classifier: Operating System :: POSIX :: Linux
|
18
18
|
Classifier: Programming Language :: Python
|
19
|
-
Classifier: Programming Language :: Python :: 3.8
|
20
19
|
Classifier: Programming Language :: Python :: 3.9
|
21
20
|
Classifier: Programming Language :: Python :: 3.10
|
22
21
|
Classifier: Programming Language :: Python :: 3.11
|
23
22
|
Classifier: Programming Language :: Python :: 3.12
|
24
23
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
25
24
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
26
|
-
Requires-Python: >=3.
|
25
|
+
Requires-Python: >=3.9
|
27
26
|
Requires-Dist: agate<1.10,>=1.7.0
|
28
27
|
Requires-Dist: colorama<0.5,>=0.3.9
|
29
28
|
Requires-Dist: deepdiff<8.0,>=7.0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
dbt_common/__about__.py,sha256=
|
1
|
+
dbt_common/__about__.py,sha256=321j5SZZ1oxJ8inLWCUMR7BK6FyNniIooozPekshf70,19
|
2
2
|
dbt_common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
3
|
dbt_common/behavior_flags.py,sha256=tflh5PubIgEuogslprvnOEA2tM7e7opK6i8GOTnwrgw,4883
|
4
4
|
dbt_common/constants.py,sha256=-Y5DIL1SDPQWtlCNizXRYxFgbx1D7LaLs1ysamvGMRk,278
|
@@ -12,7 +12,7 @@ dbt_common/semver.py,sha256=Znewz6tc_NBpXr4mZf20bK_RayPL4ODrnxDbkUZrrRo,15034
|
|
12
12
|
dbt_common/tests.py,sha256=6lC_JuRtoYO6cbAF8-R5aTM4HtQiM_EH8X5m_97duGY,315
|
13
13
|
dbt_common/ui.py,sha256=rc2TEM29raBFc_LXcg901pMDD07C2ohwp9qzkE-7pBY,2567
|
14
14
|
dbt_common/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
dbt_common/clients/_jinja_blocks.py,sha256=
|
15
|
+
dbt_common/clients/_jinja_blocks.py,sha256=5I_VEWkkW_54uK09ErP_8ey7wj-OOXvt1OHqr73HLOk,14879
|
16
16
|
dbt_common/clients/agate_helper.py,sha256=anKKgKV5PSnFRuFeBwRMdHK3JCaQoUqB2ZXHD0su0Wo,9123
|
17
17
|
dbt_common/clients/jinja.py,sha256=GzpW1BN3W-__YFQ2amyx85Z_qwOOZXEwjmoTIr70HlA,19787
|
18
18
|
dbt_common/clients/system.py,sha256=aoUBtOuXVmkOyj6IhhJ3Y4a7JFzPO2F_zKyOtz3xy44,23932
|
@@ -57,7 +57,7 @@ dbt_common/utils/encoding.py,sha256=6_kSY2FvGNYMg7oX7PrbvVioieydih3Kl7Ii802LaHI,
|
|
57
57
|
dbt_common/utils/executor.py,sha256=pNY0UbPlwQmTE69Vt_Rj91YGCIOEaqeYU3CjAds0T70,2454
|
58
58
|
dbt_common/utils/formatting.py,sha256=JUn5rzJ-uajs9wPCN0-f2iRFY1pOJF5YjTD9dERuLoc,165
|
59
59
|
dbt_common/utils/jinja.py,sha256=JXgNmJArGGy0h7qkbNLA3zaEQmoF1CxsNBYTlIwFXDw,1101
|
60
|
-
dbt_common-1.
|
61
|
-
dbt_common-1.
|
62
|
-
dbt_common-1.
|
63
|
-
dbt_common-1.
|
60
|
+
dbt_common-1.12.0.dist-info/METADATA,sha256=2ahmvE1iJqtPJLu4uN1n4iFGAypBlQU13Tyoo5_TvKU,5249
|
61
|
+
dbt_common-1.12.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
62
|
+
dbt_common-1.12.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
63
|
+
dbt_common-1.12.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|