python3-cyberfusion-file-support 1.4__tar.gz → 1.6.0__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.6.0}/PKG-INFO +3 -3
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/pyproject.toml +2 -2
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/cyberfusion/FileSupport/__init__.py +37 -53
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/python3_cyberfusion_file_support.egg-info/PKG-INFO +3 -3
- python3_cyberfusion_file_support-1.6.0/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.6.0}/README.md +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/setup.cfg +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/cyberfusion/FileSupport/encryption.py +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/cyberfusion/FileSupport/exceptions.py +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/python3_cyberfusion_file_support.egg-info/SOURCES.txt +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/src/python3_cyberfusion_file_support.egg-info/dependency_links.txt +0 -0
- {python3_cyberfusion_file_support-1.4 → python3_cyberfusion_file_support-1.6.0}/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.6.0
|
|
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.6.0}/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.6.0"
|
|
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:
|
|
@@ -131,56 +124,47 @@ class DestinationFileReplacement:
|
|
|
131
124
|
f.write(contents)
|
|
132
125
|
|
|
133
126
|
@property
|
|
134
|
-
def
|
|
135
|
-
"""Get
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
def _copy_item(self) -> CopyItem:
|
|
128
|
+
"""Get copy item."""
|
|
129
|
+
return CopyItem(
|
|
130
|
+
source=self.tmp_path,
|
|
131
|
+
destination=self.destination_file.path,
|
|
132
|
+
reference=self.reference,
|
|
133
|
+
)
|
|
140
134
|
|
|
141
135
|
@property
|
|
142
|
-
def
|
|
143
|
-
"""
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"""
|
|
147
|
-
results = []
|
|
136
|
+
def changed(self) -> bool:
|
|
137
|
+
"""Check if the destination file content has changed."""
|
|
138
|
+
if self.encryption_properties:
|
|
139
|
+
decrypted_contents = self.destination_file.decrypt()
|
|
148
140
|
|
|
149
|
-
|
|
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)
|
|
141
|
+
return decrypted_contents != self.contents
|
|
162
142
|
|
|
163
|
-
return
|
|
143
|
+
return bool(self._copy_item.outcomes)
|
|
164
144
|
|
|
165
145
|
def add_to_queue(self) -> None:
|
|
166
146
|
"""Add items for replacement to queue."""
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
147
|
+
add_copy_item = True
|
|
148
|
+
|
|
149
|
+
# If encrypted, only add CopyItem when unencrypted contents changed.
|
|
150
|
+
# CopyItem does not account for encryption, so without this check the
|
|
151
|
+
# file would always be copied.
|
|
152
|
+
|
|
153
|
+
if self.encryption_properties:
|
|
154
|
+
add_copy_item = self.changed
|
|
155
|
+
|
|
156
|
+
# Copy and unlink instead of move. MoveItem copies metadata (which
|
|
157
|
+
# means mode etc. of destination file is incorrect, as set to the tmp
|
|
158
|
+
# file until corrected by later queue items). CopyItem does not copy
|
|
159
|
+
# metadata, so if the destination file already exists, its mode etc.
|
|
160
|
+
# is unchanged.
|
|
161
|
+
|
|
162
|
+
if add_copy_item:
|
|
163
|
+
copy_item = self._copy_item
|
|
164
|
+
|
|
165
|
+
self.queue.add(copy_item)
|
|
182
166
|
|
|
183
|
-
if self.command:
|
|
167
|
+
if self.command and copy_item.outcomes:
|
|
184
168
|
self.queue.add(
|
|
185
169
|
CommandItem(command=self.command, reference=self.reference),
|
|
186
170
|
)
|
|
@@ -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.6.0
|
|
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
|