safer 5.1.0__py3-none-any.whl → 5.3.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.
safer/.DS_Store
ADDED
|
Binary file
|
safer/__init__.py
CHANGED
|
@@ -147,6 +147,7 @@ With `safer`
|
|
|
147
147
|
# Either the whole file is written, or nothing
|
|
148
148
|
|
|
149
149
|
"""
|
|
150
|
+
|
|
150
151
|
from __future__ import annotations
|
|
151
152
|
|
|
152
153
|
import contextlib
|
|
@@ -253,6 +254,7 @@ def writer(
|
|
|
253
254
|
raise NotImplementedError(BUG_MESSAGE)
|
|
254
255
|
|
|
255
256
|
def write(v):
|
|
257
|
+
assert isinstance(stream, t.ContextManager), (stream, type(stream))
|
|
256
258
|
with stream:
|
|
257
259
|
stream.write(v)
|
|
258
260
|
|
|
@@ -399,7 +401,7 @@ def open(
|
|
|
399
401
|
parent = os.path.dirname(os.path.abspath(name))
|
|
400
402
|
if not os.path.exists(parent):
|
|
401
403
|
if not make_parents:
|
|
402
|
-
raise
|
|
404
|
+
raise OSError('Directory does not exist')
|
|
403
405
|
os.makedirs(parent)
|
|
404
406
|
|
|
405
407
|
def simple_open():
|
|
@@ -552,7 +554,7 @@ def printer(
|
|
|
552
554
|
Same as for `safer.open()`
|
|
553
555
|
"""
|
|
554
556
|
if 'r' in mode and '+' not in mode:
|
|
555
|
-
raise
|
|
557
|
+
raise OSError('File not open for writing')
|
|
556
558
|
|
|
557
559
|
if 'b' in mode:
|
|
558
560
|
raise ValueError('Cannot print to a file open in binary mode')
|
|
@@ -598,7 +600,7 @@ class _Closer:
|
|
|
598
600
|
|
|
599
601
|
|
|
600
602
|
# Wrap an existing IO class so that it calls safer at the end
|
|
601
|
-
@functools.lru_cache
|
|
603
|
+
@functools.lru_cache
|
|
602
604
|
def _wrap_class(stream_cls):
|
|
603
605
|
@functools.wraps(stream_cls.__exit__)
|
|
604
606
|
def exit(self, *args):
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: safer
|
|
3
|
-
Version: 5.
|
|
3
|
+
Version: 5.3.0
|
|
4
4
|
Summary: 🧿 A safer writer for files and streams 🧿
|
|
5
|
-
Home-page: https://github.com/rec/safer
|
|
6
|
-
License: MIT
|
|
7
5
|
Author: Tom Ritchford
|
|
8
|
-
Author-email: tom@swirly.com
|
|
9
|
-
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
6
|
+
Author-email: Tom Ritchford <tom@swirly.com>
|
|
7
|
+
License-Expression: MIT
|
|
11
8
|
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
14
9
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
10
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
11
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
-
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Project-URL: Homepage, https://github.com/rec/safer
|
|
18
16
|
Project-URL: Repository, https://github.com/rec/safer
|
|
17
|
+
Project-URL: Documentation, https://rec.github.io/safer
|
|
19
18
|
Description-Content-Type: text/markdown
|
|
20
19
|
|
|
21
20
|
# 🧿 `safer`: A safer writer 🧿
|
|
@@ -164,4 +163,3 @@ With `safer`
|
|
|
164
163
|
|
|
165
164
|
|
|
166
165
|
### [API Documentation](https://rec.github.io/safer#safer--api-documentation)
|
|
167
|
-
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
safer/.DS_Store,sha256=9uTAJ6op3-OCDu24y8I5d1RJelGP0F0TYAFYXHowPNM,6148
|
|
2
|
+
safer/__init__.py,sha256=SBfhw68Hm2WC5nkzbTPBGGS5F8nk55Jj4YmicCSS3dw,22775
|
|
3
|
+
safer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
safer-5.3.0.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
5
|
+
safer-5.3.0.dist-info/METADATA,sha256=tFpFzOyxv3FxAw4oM6OZyk_7pvnYl88IZeWPSRbEDJE,5439
|
|
6
|
+
safer-5.3.0.dist-info/RECORD,,
|
safer-5.1.0.dist-info/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Tom Swirly
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
safer-5.1.0.dist-info/RECORD
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
safer/__init__.py,sha256=gol1HEWHBCBlrotKRuS2mSln5GAyv6PWdML09x9GZI8,22692
|
|
2
|
-
safer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
safer-5.1.0.dist-info/LICENSE,sha256=YrPqlE_MughiZSHUT2iVoduqlqmStMop9EEwCTdlzBw,1067
|
|
4
|
-
safer-5.1.0.dist-info/METADATA,sha256=TiGbpkpfSotKcUdbSdeR8kz27YdpbD1EroL_D52Zi0M,5449
|
|
5
|
-
safer-5.1.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
6
|
-
safer-5.1.0.dist-info/RECORD,,
|