safer 4.12.3__py3-none-any.whl → 5.0.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/__init__.py CHANGED
@@ -1,5 +1,4 @@
1
- """
2
- # 🧿 `safer`: A safer writer 🧿
1
+ """# 🧿 `safer`: A safer writer 🧿
3
2
 
4
3
  Avoid partial writes or corruption!
5
4
 
@@ -42,6 +41,10 @@ https://pypi.org/project/atomicwrites/
42
41
  It also has a useful `dry_run` setting to let you test your code without
43
42
  actually overwriting the target file.
44
43
 
44
+ NOTE: Just like plain old `open`, if a file that is already opened for writing
45
+ is opened again before the first write has completed, the results are
46
+ unpredictable: so don't do it!
47
+
45
48
  * `safer.writer()` wraps an existing writer, socket or stream and writes a
46
49
  whole response or nothing
47
50
 
@@ -67,7 +70,6 @@ writes the data to a temporary file on disk, which is moved over using
67
70
  does not work on Windows. (In fact, it's unclear if any of this works on
68
71
  Windows, but that certainly won't. Windows developer solicted!)
69
72
 
70
-
71
73
  ### Example: `safer.writer()`
72
74
 
73
75
  `safer.writer()` wraps an existing stream - a writer, socket, or callback -
@@ -143,6 +145,7 @@ With `safer`
143
145
  for item in items:
144
146
  print(item)
145
147
  # Either the whole file is written, or nothing
148
+
146
149
  """
147
150
  import contextlib
148
151
  import functools
@@ -657,14 +660,16 @@ class _FileRenameCloser(_FileCloser):
657
660
  self.target_file = target_file
658
661
  self.dry_run = dry_run
659
662
  self.is_binary = is_binary
663
+ if temp_file is True:
664
+ parent, file = os.path.split(target_file)
665
+ temp_file = os.path.join(parent, f'.{file}.tmp-safer')
666
+
660
667
  super().__init__(temp_file, delete_failures, parent)
661
668
 
662
669
  def _success(self):
663
670
  if not self.dry_run:
664
671
  if os.path.exists(self.target_file):
665
672
  shutil.copymode(self.target_file, self.temp_file)
666
- else:
667
- os.chmod(self.temp_file, 0o100644)
668
673
  os.replace(self.temp_file, self.target_file)
669
674
 
670
675
  elif callable(self.dry_run):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: safer
3
- Version: 4.12.3
3
+ Version: 5.0.0
4
4
  Summary: 🧿 A safer writer for files and streams 🧿
5
5
  Home-page: https://github.com/rec/safer
6
6
  License: MIT
@@ -0,0 +1,6 @@
1
+ safer/__init__.py,sha256=eRkfOSVTIr5Wd9aOF6EJBkfyizjeS_P6Uaeu0qBKe3Y,22455
2
+ safer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ safer-5.0.0.dist-info/LICENSE,sha256=YrPqlE_MughiZSHUT2iVoduqlqmStMop9EEwCTdlzBw,1067
4
+ safer-5.0.0.dist-info/METADATA,sha256=v2pjAfB1KHIGyg7W-fhSb0_mP2FOHePB8B7rPjzow8M,5449
5
+ safer-5.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
+ safer-5.0.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.8.1
2
+ Generator: poetry-core 1.9.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,6 +0,0 @@
1
- safer/__init__.py,sha256=pHsZGbnFFGcOsoR3mqlFksHYTUEDFiHEsYz0emW-nmE,22192
2
- safer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- safer-4.12.3.dist-info/LICENSE,sha256=YrPqlE_MughiZSHUT2iVoduqlqmStMop9EEwCTdlzBw,1067
4
- safer-4.12.3.dist-info/METADATA,sha256=H_QnHGAiyLOoMJ1FY0ZRjrNADF01l586Ohf9rTz5yUE,5450
5
- safer-4.12.3.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
6
- safer-4.12.3.dist-info/RECORD,,