cql2 0.2.0__cp39-none-win32.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.
cql2/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .cql2 import *
2
+
3
+ __doc__ = cql2.__doc__
4
+ if hasattr(cql2, "__all__"):
5
+ __all__ = cql2.__all__
cql2/__init__.pyi ADDED
@@ -0,0 +1,98 @@
1
+ from typing import Any
2
+ from os import PathLike
3
+
4
+ class SqlQuery:
5
+ """A SQL query"""
6
+
7
+ query: str
8
+ """The query, with parameterized fields."""
9
+
10
+ params: list[str]
11
+ """The parameters, to use for binding."""
12
+
13
+ class Expr:
14
+ @staticmethod
15
+ def from_path(path: PathLike | str) -> Expr:
16
+ """Reads CQL2 from a filesystem path.
17
+
18
+ Args:
19
+ path (PathLike | str): The input path
20
+
21
+ Returns:
22
+ Expr: The CQL2 expression
23
+
24
+ Examples:
25
+ >>> from cql2 import Expr
26
+ >>> expr = Expr.from_path("fixtures/text/example01.txt")
27
+ """
28
+
29
+ def __init__(self, cql2: str | dict[str, Any]) -> None:
30
+ """A CQL2 expression.
31
+
32
+ The cql2 can either be a cql2-text string, a cql2-json string, or a
33
+ cql2-json dictionary.
34
+
35
+ Args:
36
+ cql2 (str | dict[str, Any]): The input CQL2
37
+
38
+ Examples:
39
+ >>> from cql2 import Expr
40
+ >>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
41
+ >>> expr = Expr({"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]})
42
+ """
43
+
44
+ def validate(self) -> None:
45
+ """Validates this expression using json-schema.
46
+
47
+ Raises:
48
+ ValidationError: Raised if the validation fails
49
+
50
+ Examples:
51
+ >>> from cql2 import Expr
52
+ >>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
53
+ >>> expr.validate()
54
+ """
55
+
56
+ def to_json(self) -> dict[str, Any]:
57
+ """Converts this cql2 expression to a cql2-json dictionary.
58
+
59
+ Returns:
60
+ dict[str, Any]: The cql2-json
61
+
62
+ Examples:
63
+ >>> from cql2 import Expr
64
+ >>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
65
+ >>> expr.to_json()
66
+ {'op': '=', 'args': [{'property': 'landsat:scene_id'}, 'LC82030282019133LGN00']}
67
+ """
68
+
69
+ def to_text(self) -> str:
70
+ """Converts this cql2 expression to cql2-text.
71
+
72
+ Returns:
73
+ str: The cql2-text
74
+
75
+ Examples:
76
+ >>> from cql2 import Expr
77
+ >>> expr = Expr({"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]})
78
+ >>> expr.to_text()
79
+ '("landsat:scene_id" = \'LC82030282019133LGN00\')'
80
+ """
81
+
82
+ def to_sql(self) -> SqlQuery:
83
+ """Converts this cql2 expression to a SQL query.
84
+
85
+ Returns:
86
+ SqlQuery: The SQL query and parameters
87
+
88
+ Examples:
89
+ >>> from cql2 import Expr
90
+ >>> expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
91
+ >>> q.query
92
+ '("landsat:scene_id" = $1)'
93
+ >>> q.params
94
+ ['LC82030282019133LGN00']
95
+ """
96
+
97
+ class ValidationError(Exception):
98
+ """An error raised when cql2 json-schema validation fails."""
Binary file
cql2/py.typed ADDED
File without changes
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.3
2
+ Name: cql2
3
+ Version: 0.2.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Summary: Parse, validate, and convert Common Query Language (CQL2) text and JSON
8
+ Keywords: cql2
9
+ Home-Page: https://github.com/developmentseed/cql2-rs
10
+ Author: David Bitner <bitner@dbspatial.com>
11
+ Author-email: David Bitner <bitner@dbspatial.com>
12
+ License: MIT
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
15
+ Project-URL: Source Code, https://github.com/developmentseed/cql2-rs
16
+
17
+ # cql2
18
+
19
+ Python library and command-line interface (CLI) for parsing and converting [Common Query Language (CQL2)](https://www.ogc.org/standard/cql2/), with Rust under the hood.
20
+
21
+ ## Usage
22
+
23
+ ```shell
24
+ pip install cql2
25
+ ```
26
+
27
+ Then:
28
+
29
+ ```python
30
+ expr = Expr("landsat:scene_id = 'LC82030282019133LGN00'")
31
+ # or
32
+ expr = Expr.from_path("fixtures/text/example01.txt")
33
+
34
+ s = expr.to_text()
35
+ d = expr.to_json()
36
+ sql = expr.to_sql()
37
+ print("SQL query:", sql.query)
38
+ print("SQL params:", sql.params)
39
+ ```
40
+
41
+ Or from via the command-line interface:
42
+
43
+ ```shell
44
+ $ cql2 -o json "landsat:scene_id = 'LC82030282019133LGN00'"
45
+ {"op":"=","args":[{"property":"landsat:scene_id"},"LC82030282019133LGN00"]}
46
+ ```
47
+
48
+ ## Developing
49
+
50
+ To install the package to your virtual environment and test:
51
+
52
+ ```shell
53
+ maturin develop --uv -m python/Cargo.toml && pytest python
54
+ ```
55
+
56
+ ## More information
57
+
58
+ This package is part of [cql2-rs](https://github.com/developmentseed/cql2-rs/), see that repo for license and contributing information.
59
+
@@ -0,0 +1,8 @@
1
+ cql2-0.2.0.dist-info/METADATA,sha256=et9Y2UMQT4ZDAQ9tHr7K14ebDysFId2sRpA2LYJ3qq0,1669
2
+ cql2-0.2.0.dist-info/WHEEL,sha256=8oDS9lEgrtw5U4qwq5k5ejtIqRM0xNzMNTKqkiM20hA,90
3
+ cql2-0.2.0.dist-info/entry_points.txt,sha256=71myRgqcjlXJ5L8YfBsyaQS-Ef8mXeSlOCDwf1rrURo,33
4
+ cql2/__init__.py,sha256=lQIzMwXTmBW1tLuKrIKf3_nxwWMiik5UOd5CBYV22uQ,99
5
+ cql2/__init__.pyi,sha256=miTY8X4iZPkrK0mDwAOCYeraooLIF15Dbe41j2xgJSU,2932
6
+ cql2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ cql2/cql2.cp39-win32.pyd,sha256=DnVm7pkcCMkvRzuiWCPKxClIzCDo-eCrw-vnAPbJgos,3623424
8
+ cql2-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.7.4)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-none-win32
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cql2=cql2:main