python3-cyberfusion-file-support 1.4__tar.gz → 1.5__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.
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/PKG-INFO +3 -3
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/pyproject.toml +2 -2
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/cyberfusion/FileSupport/__init__.py +26 -55
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/python3_cyberfusion_file_support.egg-info/PKG-INFO +3 -3
- python3_cyberfusion_file_support-1.5/src/python3_cyberfusion_file_support.egg-info/requires.txt +2 -0
- python3_cyberfusion_file_support-1.4/src/python3_cyberfusion_file_support.egg-info/requires.txt +0 -2
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/README.md +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/setup.cfg +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/cyberfusion/FileSupport/encryption.py +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/cyberfusion/FileSupport/exceptions.py +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/python3_cyberfusion_file_support.egg-info/SOURCES.txt +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/python3_cyberfusion_file_support.egg-info/dependency_links.txt +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/src/python3_cyberfusion_file_support.egg-info/top_level.txt +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-cyberfusion-file-support
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5
|
|
4
4
|
Summary: Library for idempotent writing to files.
|
|
5
5
|
Author-email: Cyberfusion <support@cyberfusion.io>
|
|
6
6
|
Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-file-support
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: python3-cyberfusion-common~=2.0
|
|
9
|
-
Requires-Dist: python3-cyberfusion-queue-support~=1.
|
|
9
|
+
Requires-Dist: python3-cyberfusion-queue-support~=1.7.0
|
|
10
10
|
|
|
11
11
|
# python3-cyberfusion-file-support
|
|
12
12
|
|
{python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.5}/pyproject.toml
RENAMED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python3-cyberfusion-file-support"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.5"
|
|
8
8
|
description = "Library for idempotent writing to files."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -12,7 +12,7 @@ authors = [
|
|
|
12
12
|
]
|
|
13
13
|
dependencies = [
|
|
14
14
|
"python3-cyberfusion-common~=2.0",
|
|
15
|
-
"python3-cyberfusion-queue-support~=1.
|
|
15
|
+
"python3-cyberfusion-queue-support~=1.7.0",
|
|
16
16
|
]
|
|
17
17
|
|
|
18
18
|
[project.urls]
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"""Classes for files."""
|
|
2
2
|
|
|
3
|
-
import difflib
|
|
4
|
-
|
|
5
3
|
import os
|
|
6
4
|
|
|
7
5
|
from typing import List, Optional, Union
|
|
@@ -35,20 +33,15 @@ class _DestinationFile:
|
|
|
35
33
|
self.encryption_properties = encryption_properties
|
|
36
34
|
|
|
37
35
|
@property
|
|
38
|
-
def
|
|
36
|
+
def _exists(self) -> bool:
|
|
39
37
|
"""Get if exists."""
|
|
40
38
|
return os.path.exists(self.path)
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if not self.exists:
|
|
40
|
+
def decrypt(self) -> Optional[str]:
|
|
41
|
+
"""Decrypt file."""
|
|
42
|
+
if not self._exists or not self.encryption_properties:
|
|
46
43
|
return None
|
|
47
44
|
|
|
48
|
-
if not self.encryption_properties:
|
|
49
|
-
with open(self.path, "r") as f:
|
|
50
|
-
return f.read()
|
|
51
|
-
|
|
52
45
|
try:
|
|
53
46
|
return decrypt_file(self.encryption_properties, self.path)
|
|
54
47
|
except DecryptionError as e:
|
|
@@ -130,57 +123,35 @@ class DestinationFileReplacement:
|
|
|
130
123
|
with open(path, open_mode) as f:
|
|
131
124
|
f.write(contents)
|
|
132
125
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if not self.destination_file.exists:
|
|
137
|
-
return True
|
|
126
|
+
def add_to_queue(self) -> None:
|
|
127
|
+
"""Add items for replacement to queue."""
|
|
128
|
+
add_copy_item = True
|
|
138
129
|
|
|
139
|
-
|
|
130
|
+
decrypted_contents = self.destination_file.decrypt()
|
|
140
131
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
# If encrypted, only add CopyItem when unencrypted contents changed.
|
|
133
|
+
# CopyItem does not account for encryption, so without this check the
|
|
134
|
+
# file would always be copied.
|
|
144
135
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
results = []
|
|
148
|
-
|
|
149
|
-
for line in difflib.unified_diff(
|
|
150
|
-
(
|
|
151
|
-
self.destination_file.contents.splitlines()
|
|
152
|
-
if self.destination_file.contents
|
|
153
|
-
else []
|
|
154
|
-
),
|
|
155
|
-
self.contents.splitlines(),
|
|
156
|
-
fromfile=self.tmp_path,
|
|
157
|
-
tofile=self.destination_file.path,
|
|
158
|
-
lineterm="",
|
|
159
|
-
n=0,
|
|
160
|
-
):
|
|
161
|
-
results.append(line)
|
|
136
|
+
if decrypted_contents:
|
|
137
|
+
add_copy_item = decrypted_contents != self.contents
|
|
162
138
|
|
|
163
|
-
|
|
139
|
+
# Copy and unlink instead of move. MoveItem copies metadata (which
|
|
140
|
+
# means mode etc. of destination file is incorrect, as set to the tmp
|
|
141
|
+
# file until corrected by later queue items). CopyItem does not copy
|
|
142
|
+
# metadata, so if the destination file already exists, its mode etc.
|
|
143
|
+
# is unchanged.
|
|
164
144
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
# mode etc. of destination file is incorrect, as set to the tmp file
|
|
171
|
-
# until corrected by later queue items). CopyItem does not copy
|
|
172
|
-
# metadata, so if the destination file already exists, its mode
|
|
173
|
-
# etc. is unchanged.
|
|
174
|
-
|
|
175
|
-
self.queue.add(
|
|
176
|
-
CopyItem(
|
|
177
|
-
source=self.tmp_path,
|
|
178
|
-
destination=self.destination_file.path,
|
|
179
|
-
reference=self.reference,
|
|
180
|
-
),
|
|
145
|
+
if add_copy_item:
|
|
146
|
+
copy_item = CopyItem(
|
|
147
|
+
source=self.tmp_path,
|
|
148
|
+
destination=self.destination_file.path,
|
|
149
|
+
reference=self.reference,
|
|
181
150
|
)
|
|
182
151
|
|
|
183
|
-
|
|
152
|
+
self.queue.add(copy_item)
|
|
153
|
+
|
|
154
|
+
if self.command and copy_item.outcomes:
|
|
184
155
|
self.queue.add(
|
|
185
156
|
CommandItem(command=self.command, reference=self.reference),
|
|
186
157
|
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-cyberfusion-file-support
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5
|
|
4
4
|
Summary: Library for idempotent writing to files.
|
|
5
5
|
Author-email: Cyberfusion <support@cyberfusion.io>
|
|
6
6
|
Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-file-support
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: python3-cyberfusion-common~=2.0
|
|
9
|
-
Requires-Dist: python3-cyberfusion-queue-support~=1.
|
|
9
|
+
Requires-Dist: python3-cyberfusion-queue-support~=1.7.0
|
|
10
10
|
|
|
11
11
|
# python3-cyberfusion-file-support
|
|
12
12
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|