odatadol 0.0.2__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.
@@ -0,0 +1 @@
1
+ *.ipynb linguist-documentation
@@ -0,0 +1,119 @@
1
+ .claude/handoffs/
2
+ .claude/scratch/
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+
10
+ .DS_Store
11
+ # C extensions
12
+ *.so
13
+
14
+ # TLS certificates
15
+ ## Ignore all PEM files anywhere
16
+ *.pem
17
+ ## Also ignore any certs directory
18
+ certs/
19
+
20
+ # Distribution / packaging
21
+ .Python
22
+ build/
23
+ develop-eggs/
24
+ dist/
25
+ downloads/
26
+ eggs/
27
+ .eggs/
28
+ lib/
29
+ lib64/
30
+ parts/
31
+ sdist/
32
+ var/
33
+ wheels/
34
+ *.egg-info/
35
+ .installed.cfg
36
+ *.egg
37
+ MANIFEST
38
+ _build
39
+
40
+ # PyInstaller
41
+ # Usually these files are written by a python script from a template
42
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
43
+ *.manifest
44
+ *.spec
45
+
46
+ # Installer logs
47
+ pip-log.txt
48
+ pip-delete-this-directory.txt
49
+
50
+ # Unit test / coverage reports
51
+ htmlcov/
52
+ .tox/
53
+ .coverage
54
+ .coverage.*
55
+ .cache
56
+ nosetests.xml
57
+ coverage.xml
58
+ *.cover
59
+ .hypothesis/
60
+ .pytest_cache/
61
+
62
+ # Translations
63
+ *.mo
64
+ *.pot
65
+
66
+ # Django stuff:
67
+ *.log
68
+ local_settings.py
69
+ db.sqlite3
70
+
71
+ # Flask stuff:
72
+ instance/
73
+ .webassets-cache
74
+
75
+ # Scrapy stuff:
76
+ .scrapy
77
+
78
+ # Sphinx documentation
79
+ docs/_build/
80
+
81
+ # PyBuilder
82
+ target/
83
+
84
+ # Jupyter Notebook
85
+ .ipynb_checkpoints
86
+
87
+ # pyenv
88
+ .python-version
89
+
90
+ # celery beat schedule file
91
+ celerybeat-schedule
92
+
93
+ # SageMath parsed files
94
+ *.sage.py
95
+
96
+ # Environments
97
+ .env
98
+ .venv
99
+ env/
100
+ venv/
101
+ ENV/
102
+ env.bak/
103
+ venv.bak/
104
+
105
+ # Spyder project settings
106
+ .spyderproject
107
+ .spyproject
108
+
109
+ # Rope project settings
110
+ .ropeproject
111
+
112
+ # mkdocs documentation
113
+ /site
114
+
115
+ # mypy
116
+ .mypy_cache/
117
+
118
+ # PyCharm
119
+ .idea
odatadol-0.0.2/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Thor Whalen
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.5
2
+ Name: odatadol
3
+ Version: 0.0.2
4
+ Summary: Read an OData v4 entity set as a Mapping: stdlib-only transport, paging, column-group joins, $metadata
5
+ Project-URL: Homepage, https://github.com/i2mint/odatadol
6
+ Project-URL: Repository, https://github.com/i2mint/odatadol
7
+ Project-URL: Documentation, https://i2mint.github.io/odatadol
8
+ Author: Thor Whalen
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: dol,filemaker,key-value,mapping,odata,rest
12
+ Requires-Python: >=3.10
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
15
+ Requires-Dist: pytest>=7.0; extra == 'dev'
16
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
17
+ Provides-Extra: docs
18
+ Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
19
+ Requires-Dist: sphinx>=6.0; extra == 'docs'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # odatadol
23
+
24
+ Read an OData v4 entity set as a Python `Mapping`, with the standard library only (`urllib`, `json`, `xml.etree`): zero runtime dependencies.
25
+
26
+ ```
27
+ pip install odatadol
28
+ ```
29
+
30
+ ```python
31
+ from odatadol import ODataReader, BasicAuth
32
+
33
+ store = ODataReader(
34
+ 'https://example.com/odata/v4/Shop', 'Products',
35
+ key='ProductID', credentials=BasicAuth('reader', password),
36
+ )
37
+ len(store) # one $count request
38
+ store['P0042'] # one filtered request
39
+ list(store) # the key column only, in key order
40
+ dict(store.items()) # every record, read in bulk
41
+ ```
42
+
43
+ It is read-only by construction: every request is a `GET`, and no function takes an HTTP verb.
44
+
45
+ ## The functions under the facade
46
+
47
+ `ODataReader` is a thin layer over plain functions, each usable on its own. They take the service root and the entity set name, then keyword-only options.
48
+
49
+ | function | does |
50
+ |---|---|
51
+ | `entity_count(service, entity, filter=)` | `$count`, sent with `Accept: */*` |
52
+ | `entity_records(service, entity, select=, filter=, orderby=, top=, page_size=)` | records, lazily, paged by `$top`/`$skip` or `@odata.nextLink`, annotations dropped; a read ends on an empty page, so a server that silently caps its pages loses nothing |
53
+ | `entity_columns(service, entity, select=, key=, version=, filter=, max_url=)` | a `$select` too wide for one URL, read as column groups and joined on `key` |
54
+ | `entity_metadata(service, entity)` | `$metadata` as `{name: {'type': 'Edm.…', 'nullable': bool, 'annotations': {...}}}` |
55
+ | `odata_get(url)` | the one request everything goes through |
56
+
57
+ ```python
58
+ from decimal import Decimal
59
+ from odatadol import entity_records, entity_metadata
60
+
61
+ entity_metadata(service, 'Products')['Price']
62
+ # {'type': 'Edm.Decimal', 'nullable': True}
63
+
64
+ newest = next(entity_records(
65
+ service, 'Products', select=['ProductID', 'ModifiedAt'],
66
+ filter='ModifiedAt ne null', orderby='ModifiedAt desc', top=1,
67
+ parse_float=Decimal, # keep every digit of a fractional number
68
+ ))
69
+ ```
70
+
71
+ ## Seams
72
+
73
+ Every function takes the same keyword arguments for what a host may need to swap:
74
+
75
+ - `fetch=(url, headers) -> (status, body bytes)`: the transport. Defaults to `urllib_fetch` (use `functools.partial(urllib_fetch, timeout=...)` to change its timeout). Tests pass `odatadol.testing.FakeService`, a scripted server that records every URL it was asked for.
76
+ - `credentials=`: `None` (anonymous), `BasicAuth(account, password)`, `BearerToken(token)`, anything with a `header() -> str` method, or a zero-argument callable returning one of those, so a keychain or file lookup happens only when a request is made. Neither the password nor the `Authorization` header ever appears in an error, and credentials never follow a redirect or a `@odata.nextLink` to another origin (a cross-origin nextLink is refused). A server that would page forever (ignoring `$skip`, or repeating its nextLink) is stopped with an `ODataError`.
77
+ - `max_url=` (default 2000) and `page_size=` (default 1000).
78
+ - `parse_float=`: applied to every fractional JSON number; `decimal.Decimal` keeps every digit (default `float`).
79
+ - `literal=` (on `ODataReader`): writes a key as a `$filter` literal for `store[k]` and `k in store`; defaults to `odata_literal` (str, numbers, bool, `uuid.UUID`, `datetime` objects). For an `Edm.Guid` key that iteration returns as text, pass `literal=str`.
80
+
81
+ ## Wide reads are one moment, or they raise
82
+
83
+ A front end such as IIS refuses URLs past about 2,048 characters, answering its own 404 as if the entity did not exist. A `$select` of a hundred or more fields is past that, so `entity_columns` (and `ODataReader` with a wide `select=`) splits it into groups that fit `max_url`, reads each in key order, and joins them on the key.
84
+
85
+ A join of separate reads is only a true record if every read saw the same records in the same state, so:
86
+
87
+ - `version=` names a property the server rewrites on every edit (a modification timestamp). It is read in every group and must agree per key; otherwise an edit landing between two reads would yield a record that never existed.
88
+ - With a single group, a narrow key/version read follows it, because `$skip` paging over a delete before the cursor and an insert after it skips a live record while the count still balances.
89
+ - An empty or repeated key is refused (`ODataError`): joining on it would merge different records.
90
+ - Reads that disagree raise `UnstableRead` (an `ODataError`), saying how many records were new, gone or edited. The entity set changed during the read; retrying is safe.
91
+
92
+ ## Server quirks it copes with
93
+
94
+ Each was met against a real server and has a test:
95
+
96
+ - `$count` with `Accept: text/plain` refused; odatadol sends `*/*`.
97
+ - Property names with spaces must be double-quoted in `$select`/`$orderby` (`quote_name`), as FileMaker's OData requires.
98
+ - A percent-encoded `:` inside a `$filter` timestamp is a syntax error; `:` travels bare, as RFC 3986 allows.
99
+ - Raw control characters (a bare CR) inside JSON strings; parsed with `json.loads(strict=False)` and kept verbatim.
100
+
101
+ ## Writes
102
+
103
+ Not here, and not behind a flag on the reader. If writing (POST/PATCH) is ever added it will be a separate, opt-in class with its own transport seam (method, body and response headers, for ETags), so code holding a reader cannot reach a write by passing the wrong argument, and the reader's `fetch=(url, headers) -> (status, bytes)` stays as it is. A `fetch` may do its own retries (on 429 or 503, say); the reader needs nothing more from it.
@@ -0,0 +1,82 @@
1
+ # odatadol
2
+
3
+ Read an OData v4 entity set as a Python `Mapping`, with the standard library only (`urllib`, `json`, `xml.etree`): zero runtime dependencies.
4
+
5
+ ```
6
+ pip install odatadol
7
+ ```
8
+
9
+ ```python
10
+ from odatadol import ODataReader, BasicAuth
11
+
12
+ store = ODataReader(
13
+ 'https://example.com/odata/v4/Shop', 'Products',
14
+ key='ProductID', credentials=BasicAuth('reader', password),
15
+ )
16
+ len(store) # one $count request
17
+ store['P0042'] # one filtered request
18
+ list(store) # the key column only, in key order
19
+ dict(store.items()) # every record, read in bulk
20
+ ```
21
+
22
+ It is read-only by construction: every request is a `GET`, and no function takes an HTTP verb.
23
+
24
+ ## The functions under the facade
25
+
26
+ `ODataReader` is a thin layer over plain functions, each usable on its own. They take the service root and the entity set name, then keyword-only options.
27
+
28
+ | function | does |
29
+ |---|---|
30
+ | `entity_count(service, entity, filter=)` | `$count`, sent with `Accept: */*` |
31
+ | `entity_records(service, entity, select=, filter=, orderby=, top=, page_size=)` | records, lazily, paged by `$top`/`$skip` or `@odata.nextLink`, annotations dropped; a read ends on an empty page, so a server that silently caps its pages loses nothing |
32
+ | `entity_columns(service, entity, select=, key=, version=, filter=, max_url=)` | a `$select` too wide for one URL, read as column groups and joined on `key` |
33
+ | `entity_metadata(service, entity)` | `$metadata` as `{name: {'type': 'Edm.…', 'nullable': bool, 'annotations': {...}}}` |
34
+ | `odata_get(url)` | the one request everything goes through |
35
+
36
+ ```python
37
+ from decimal import Decimal
38
+ from odatadol import entity_records, entity_metadata
39
+
40
+ entity_metadata(service, 'Products')['Price']
41
+ # {'type': 'Edm.Decimal', 'nullable': True}
42
+
43
+ newest = next(entity_records(
44
+ service, 'Products', select=['ProductID', 'ModifiedAt'],
45
+ filter='ModifiedAt ne null', orderby='ModifiedAt desc', top=1,
46
+ parse_float=Decimal, # keep every digit of a fractional number
47
+ ))
48
+ ```
49
+
50
+ ## Seams
51
+
52
+ Every function takes the same keyword arguments for what a host may need to swap:
53
+
54
+ - `fetch=(url, headers) -> (status, body bytes)`: the transport. Defaults to `urllib_fetch` (use `functools.partial(urllib_fetch, timeout=...)` to change its timeout). Tests pass `odatadol.testing.FakeService`, a scripted server that records every URL it was asked for.
55
+ - `credentials=`: `None` (anonymous), `BasicAuth(account, password)`, `BearerToken(token)`, anything with a `header() -> str` method, or a zero-argument callable returning one of those, so a keychain or file lookup happens only when a request is made. Neither the password nor the `Authorization` header ever appears in an error, and credentials never follow a redirect or a `@odata.nextLink` to another origin (a cross-origin nextLink is refused). A server that would page forever (ignoring `$skip`, or repeating its nextLink) is stopped with an `ODataError`.
56
+ - `max_url=` (default 2000) and `page_size=` (default 1000).
57
+ - `parse_float=`: applied to every fractional JSON number; `decimal.Decimal` keeps every digit (default `float`).
58
+ - `literal=` (on `ODataReader`): writes a key as a `$filter` literal for `store[k]` and `k in store`; defaults to `odata_literal` (str, numbers, bool, `uuid.UUID`, `datetime` objects). For an `Edm.Guid` key that iteration returns as text, pass `literal=str`.
59
+
60
+ ## Wide reads are one moment, or they raise
61
+
62
+ A front end such as IIS refuses URLs past about 2,048 characters, answering its own 404 as if the entity did not exist. A `$select` of a hundred or more fields is past that, so `entity_columns` (and `ODataReader` with a wide `select=`) splits it into groups that fit `max_url`, reads each in key order, and joins them on the key.
63
+
64
+ A join of separate reads is only a true record if every read saw the same records in the same state, so:
65
+
66
+ - `version=` names a property the server rewrites on every edit (a modification timestamp). It is read in every group and must agree per key; otherwise an edit landing between two reads would yield a record that never existed.
67
+ - With a single group, a narrow key/version read follows it, because `$skip` paging over a delete before the cursor and an insert after it skips a live record while the count still balances.
68
+ - An empty or repeated key is refused (`ODataError`): joining on it would merge different records.
69
+ - Reads that disagree raise `UnstableRead` (an `ODataError`), saying how many records were new, gone or edited. The entity set changed during the read; retrying is safe.
70
+
71
+ ## Server quirks it copes with
72
+
73
+ Each was met against a real server and has a test:
74
+
75
+ - `$count` with `Accept: text/plain` refused; odatadol sends `*/*`.
76
+ - Property names with spaces must be double-quoted in `$select`/`$orderby` (`quote_name`), as FileMaker's OData requires.
77
+ - A percent-encoded `:` inside a `$filter` timestamp is a syntax error; `:` travels bare, as RFC 3986 allows.
78
+ - Raw control characters (a bare CR) inside JSON strings; parsed with `json.loads(strict=False)` and kept verbatim.
79
+
80
+ ## Writes
81
+
82
+ Not here, and not behind a flag on the reader. If writing (POST/PATCH) is ever added it will be a separate, opt-in class with its own transport seam (method, body and response headers, for ETags), so code holding a reader cannot reach a write by passing the wrong argument, and the reader's `fetch=(url, headers) -> (status, bytes)` stays as it is. A `fetch` may do its own retries (on 429 or 503, say); the reader needs nothing more from it.
@@ -0,0 +1,64 @@
1
+ """Read an OData v4 entity set as a Mapping, with the standard library only.
2
+
3
+ >>> from odatadol import ODataReader, BasicAuth # doctest: +SKIP
4
+ >>> store = ODataReader('https://example.com/odata', 'Products', # doctest: +SKIP
5
+ ... key='ProductID', credentials=BasicAuth('me', 'pw'))
6
+ >>> len(store); store[42]; list(store) # doctest: +SKIP
7
+
8
+ Under the facade are plain functions, usable on their own:
9
+
10
+ - :func:`odata_get`: the one (``GET``) request, through a ``fetch`` seam.
11
+ - :func:`entity_count`, :func:`entity_records`: ``$count`` and paged records, with
12
+ ``$select``/``$filter``/``$orderby``/``$top`` passed through.
13
+ - :func:`entity_columns`: a ``$select`` too wide for one URL, read as column groups
14
+ joined on a key and checked to be one moment (:class:`UnstableRead` otherwise).
15
+ - :func:`entity_metadata`: ``$metadata`` as ``{name: {type, nullable, annotations}}``.
16
+
17
+ Read-only by construction: no function takes an HTTP verb.
18
+ """
19
+
20
+ from odatadol.metadata import entity_metadata, parse_entity_metadata
21
+ from odatadol.read import (
22
+ DEFAULT_PAGE_SIZE,
23
+ MAX_URL_CHARS,
24
+ UnstableRead,
25
+ entity_columns,
26
+ entity_count,
27
+ entity_records,
28
+ entity_url,
29
+ quote_name,
30
+ )
31
+ from odatadol.store import ODataReader, odata_literal
32
+ from odatadol.transport import (
33
+ BasicAuth,
34
+ BearerToken,
35
+ Credentials,
36
+ Fetch,
37
+ ODataError,
38
+ odata_get,
39
+ redact,
40
+ urllib_fetch,
41
+ )
42
+
43
+ __all__ = [
44
+ "ODataReader",
45
+ "odata_literal",
46
+ "BasicAuth",
47
+ "BearerToken",
48
+ "Credentials",
49
+ "Fetch",
50
+ "ODataError",
51
+ "UnstableRead",
52
+ "odata_get",
53
+ "urllib_fetch",
54
+ "redact",
55
+ "entity_url",
56
+ "quote_name",
57
+ "entity_count",
58
+ "entity_records",
59
+ "entity_columns",
60
+ "entity_metadata",
61
+ "parse_entity_metadata",
62
+ "DEFAULT_PAGE_SIZE",
63
+ "MAX_URL_CHARS",
64
+ ]