python-corekit 0.6.1__py3-none-any.whl → 0.6.2__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.
corekit/data/__init__.py CHANGED
@@ -30,6 +30,7 @@ from corekit.data.expressions import (
30
30
  FieldExpression,
31
31
  GreaterThan,
32
32
  GreaterThanOrEquals,
33
+ IContains,
33
34
  IsIn,
34
35
  LessThan,
35
36
  LessThanOrEquals,
@@ -62,6 +63,7 @@ __all__ = [
62
63
  "Comparison",
63
64
  "Contains",
64
65
  "Dataset",
66
+ "IContains",
65
67
  "DatasetStats",
66
68
  "Equals",
67
69
  "Expression",
@@ -20,6 +20,7 @@ from corekit.data.expressions.comparison import (
20
20
  FieldExpression,
21
21
  GreaterThan,
22
22
  GreaterThanOrEquals,
23
+ IContains,
23
24
  IsIn,
24
25
  LessThan,
25
26
  LessThanOrEquals,
@@ -36,6 +37,7 @@ __all__ = [
36
37
  "Comparison",
37
38
  "Contains",
38
39
  "Equals",
40
+ "IContains",
39
41
  "Expression",
40
42
  "FieldExpression",
41
43
  "GreaterThan",
@@ -182,6 +182,34 @@ class Contains(Comparison):
182
182
  self._reject_sql("substring match is case-sensitive in Python and LIKE is not")
183
183
 
184
184
 
185
+ class IContains(Comparison):
186
+ """
187
+ Case-insensitive substring: the left side contains the right.
188
+
189
+ Python folds both sides with ``casefold``. SQL uses ``ILIKE``, which is
190
+ case-insensitive on PostgreSQL and compiled to ``lower`` comparisons
191
+ elsewhere. ``Contains`` stays case-sensitive and does not compile, because
192
+ LIKE would not mean the same thing.
193
+ """
194
+
195
+ operator = Operator.ICONTAINS
196
+
197
+ def __call__(self, context: Any, *args: Any, **kwargs: Any) -> bool:
198
+ left = self.get_left(context, *args, **kwargs)
199
+ right = self.get_right(context, *args, **kwargs)
200
+ if not isinstance(left, str) or not isinstance(right, str):
201
+ return False
202
+ return right.casefold() in left.casefold()
203
+
204
+ def to_sqlalchemy(self, context: Any) -> Any:
205
+ if self.compares_fields:
206
+ self._reject_sql("the right side is a field, and ILIKE needs a value")
207
+ needle = self.get_right(context)
208
+ if not isinstance(needle, str):
209
+ self._reject_sql("case-insensitive substring match needs a string")
210
+ return self.get_left(context).ilike(f"%{needle}%")
211
+
212
+
185
213
  class ValueExpression(Expression):
186
214
  """
187
215
  Expression representing a single value to be compared.
@@ -220,6 +248,9 @@ class ValueExpression(Expression):
220
248
  def contains(self, substring: Any) -> "Comparison":
221
249
  return Contains(self, substring)
222
250
 
251
+ def icontains(self, substring: Any) -> "Comparison":
252
+ return IContains(self, substring)
253
+
223
254
  def resolve(self, context: Any = None, target: Target = Target.VALUE, *args: Any, **kwargs: Any) -> Any:
224
255
  """
225
256
  Resolve this literal, which is its own value for every target.
@@ -33,6 +33,7 @@ class Operator(ValidatingEnum):
33
33
  GREATER_THAN_OR_EQUALS = Dialect(">=")
34
34
  IS_IN = Dialect("is in")
35
35
  CONTAINS = Dialect("contains")
36
+ ICONTAINS = Dialect("icontains")
36
37
 
37
38
  @property
38
39
  def symbol(self) -> str:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-corekit
3
- Version: 0.6.1
3
+ Version: 0.6.2
4
4
  Summary: Shared foundations for Python projects: logging, benchmarking, registries, FastAPI application and routers, SQL statements and migrations, background tasks, ETL, LLM chat/tool primitives, and HTML scraping
5
5
  Author: Steven Jacobsen
6
6
  License-Expression: MIT
@@ -39,14 +39,14 @@ corekit/crypto/__init__.py,sha256=Qf_FCUoG_jb7Q9tnN4ctX8I6xyaeaJwk74ag_bSchAQ,87
39
39
  corekit/crypto/constants.py,sha256=m-uq7_EJ4XfUTSZxFv6h429UkKSrGTj3o_9DfRFGyvU,298
40
40
  corekit/crypto/enum.py,sha256=0csj06cATCYDPY_QTNy66j_hB16WCqcHg8tJOO0lMNU,212
41
41
  corekit/crypto/hasher.py,sha256=KkxBM8pwaFwdUV31D-LO7Pg8bFULI5Y8rtUDTWti08w,3184
42
- corekit/data/__init__.py,sha256=COGfw3-OBRp6KKWBSixid5vfaeasFVY5X4Wza0mB_kY,1977
42
+ corekit/data/__init__.py,sha256=4hBzfN0gQ3wxvIdf50sXQMDOM6SmsvC_DRLlyZA7YIU,2009
43
43
  corekit/data/dataset.py,sha256=TK1yAs7bNCQpV7Z16YqCzYf2Q_Vpu2IbEs1sqMMbikM,12835
44
44
  corekit/data/record.py,sha256=EczoOvcxl-lHO1M92AjUh_5E9UQJ2qwBsiu6Yo-34gs,5233
45
45
  corekit/data/stats.py,sha256=cRnLGgUHEz66GS1Rs7c_wr2ZVvIJ8WbKq4ifBKR_t0U,4950
46
- corekit/data/expressions/__init__.py,sha256=_uOPah6QnbnT_W3DROD399b-TtjYQhsmnooD1pr62rE,1301
47
- corekit/data/expressions/comparison.py,sha256=teLuLEpZ-oohAaE9Oom6tdUSWGTGMDpTxJdWPKv6_7I,9374
46
+ corekit/data/expressions/__init__.py,sha256=9JspaJamghkPuExiZRyjK-f60Q7aYDkO8a3X4z1X7r0,1333
47
+ corekit/data/expressions/comparison.py,sha256=Hx4YpNI_vaUieU93MYNq4MdOw7lwY9aQ3zpTeCmLaBs,10608
48
48
  corekit/data/expressions/expression.py,sha256=J8EVyzRjh3VZvqiJyryjHZJfp5c2KwwENVYhZo8S2aw,2126
49
- corekit/data/expressions/operator.py,sha256=o_QFyiM9v9Ms83k2p2c6fhL3F05TIJ-gplhTk_t1LJk,893
49
+ corekit/data/expressions/operator.py,sha256=BMvGq8obCym-8XdTpqfuxDePRG_olz2FNvqhagHhoX8,930
50
50
  corekit/data/expressions/target.py,sha256=QSl7sH1qFVUc-mL7gsasTsCahWKhHqdo0bMHt--t2m8,470
51
51
  corekit/decorators/__init__.py,sha256=YrBcc_4wkSs7nEb3OjC7C7a8fNEvBk3RzOpD8QccHKM,83
52
52
  corekit/decorators/exception_handling.py,sha256=p86gfvdmsmC7_va042NSoGkWrJrbLLuw0ncE131wLWU,2326
@@ -185,8 +185,8 @@ corekit/utils/text.py,sha256=0322DdZGuDGEagTyejuda6QT1jbbxNIO6loC-_AGml0,2311
185
185
  corekit/utils/time.py,sha256=-iPaETXcgDu7J39Kwe938JyZKhPVjl6a572BBqsqcDQ,2215
186
186
  corekit/utils/validators.py,sha256=_HVKo3y264KGNaZ-1RyM1x46VPvu7XKcQkrHWDC9uxs,340
187
187
  corekit/utils/void.py,sha256=eXDb2QynuguiSgHGJLdgE08MuRnxBdYebRdMD7s1m9o,178
188
- python_corekit-0.6.1.dist-info/licenses/LICENSE,sha256=357LYxbxAQZ95q5cV-8JK6j-KNgiE6AteRodjEsm-kE,1072
189
- python_corekit-0.6.1.dist-info/METADATA,sha256=HXyIOMiQU418S4Kvn5SEWoOzH1FJMNoHm_zqYOvhPlU,15304
190
- python_corekit-0.6.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
191
- python_corekit-0.6.1.dist-info/top_level.txt,sha256=SDK4o8BoaI47E9tPbiNCbbWoc2y6N_wCjwnIEfr-GWI,8
192
- python_corekit-0.6.1.dist-info/RECORD,,
188
+ python_corekit-0.6.2.dist-info/licenses/LICENSE,sha256=357LYxbxAQZ95q5cV-8JK6j-KNgiE6AteRodjEsm-kE,1072
189
+ python_corekit-0.6.2.dist-info/METADATA,sha256=-r-63dBItRnnlnDQudj-Jc98X342NSib335VnNrFzDo,15304
190
+ python_corekit-0.6.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
191
+ python_corekit-0.6.2.dist-info/top_level.txt,sha256=SDK4o8BoaI47E9tPbiNCbbWoc2y6N_wCjwnIEfr-GWI,8
192
+ python_corekit-0.6.2.dist-info/RECORD,,