python3-cyberfusion-file-support 1.8__tar.gz → 1.9__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.
Files changed (13) hide show
  1. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/PKG-INFO +2 -2
  2. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/pyproject.toml +2 -2
  3. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/cyberfusion/FileSupport/__init__.py +22 -7
  4. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/python3_cyberfusion_file_support.egg-info/PKG-INFO +2 -2
  5. python3_cyberfusion_file_support-1.9/src/python3_cyberfusion_file_support.egg-info/requires.txt +2 -0
  6. python3_cyberfusion_file_support-1.8/src/python3_cyberfusion_file_support.egg-info/requires.txt +0 -2
  7. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/README.md +0 -0
  8. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/setup.cfg +0 -0
  9. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/cyberfusion/FileSupport/encryption.py +0 -0
  10. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/cyberfusion/FileSupport/exceptions.py +0 -0
  11. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/python3_cyberfusion_file_support.egg-info/SOURCES.txt +0 -0
  12. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/python3_cyberfusion_file_support.egg-info/dependency_links.txt +0 -0
  13. {python3_cyberfusion_file_support-1.8 → python3_cyberfusion_file_support-1.9}/src/python3_cyberfusion_file_support.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-cyberfusion-file-support
3
- Version: 1.8
3
+ Version: 1.9
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.12
9
- Requires-Dist: python3-cyberfusion-queue-support~=3.3
9
+ Requires-Dist: python3-cyberfusion-queue-support~=4.0
10
10
 
11
11
  # python3-cyberfusion-file-support
12
12
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python3-cyberfusion-file-support"
7
- version = "1.8"
7
+ version = "1.9"
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.12",
15
- "python3-cyberfusion-queue-support~=3.3",
15
+ "python3-cyberfusion-queue-support~=4.0",
16
16
  ]
17
17
 
18
18
  [project.urls]
@@ -1,5 +1,6 @@
1
1
  """Classes for files."""
2
2
 
3
+ import functools
3
4
  import os
4
5
 
5
6
  from typing import List, Optional, Union
@@ -9,6 +10,7 @@ from cyberfusion.QueueSupport import Queue
9
10
  from cyberfusion.QueueSupport.items.command import CommandItem
10
11
  from cyberfusion.QueueSupport.items.copy import CopyItem
11
12
  from cyberfusion.QueueSupport.items.unlink import UnlinkItem
13
+ from cyberfusion.QueueSupport.outcomes import CopyItemCopyOutcome
12
14
 
13
15
  from cyberfusion.FileSupport.encryption import (
14
16
  EncryptionProperties,
@@ -123,7 +125,7 @@ class DestinationFileReplacement:
123
125
  with open(path, open_mode) as f:
124
126
  f.write(contents)
125
127
 
126
- @property
128
+ @functools.cached_property
127
129
  def _copy_item(self) -> CopyItem:
128
130
  """Get copy item."""
129
131
  return CopyItem(
@@ -132,7 +134,22 @@ class DestinationFileReplacement:
132
134
  reference=self.reference,
133
135
  )
134
136
 
135
- @property
137
+ @functools.cached_property
138
+ def _copy_item_outcomes(self) -> List[CopyItemCopyOutcome]:
139
+ """Get outcomes of copy item.
140
+
141
+ Getting the outcomes reads both the destination file and the temporary
142
+ file, and compares them line by line. Both 'changed' and 'add_to_queue'
143
+ need them, so they are gotten once: getting them twice doubles the reads
144
+ and comparisons, which adds up when many files are replaced.
145
+
146
+ The object represents the destination file as it was when the object was
147
+ created - the temporary file is written then as well - so getting the
148
+ outcomes again would give the same result anyway.
149
+ """
150
+ return self._copy_item.outcomes
151
+
152
+ @functools.cached_property
136
153
  def changed(self) -> bool:
137
154
  """Check if the destination file content has changed."""
138
155
  if self.encryption_properties:
@@ -140,7 +157,7 @@ class DestinationFileReplacement:
140
157
 
141
158
  return decrypted_contents != self.contents
142
159
 
143
- return bool(self._copy_item.outcomes)
160
+ return bool(self._copy_item_outcomes)
144
161
 
145
162
  def add_to_queue(self) -> None:
146
163
  """Add items for replacement to queue."""
@@ -160,11 +177,9 @@ class DestinationFileReplacement:
160
177
  # is unchanged.
161
178
 
162
179
  if add_copy_item:
163
- copy_item = self._copy_item
164
-
165
- self.queue.add(copy_item)
180
+ self.queue.add(self._copy_item)
166
181
 
167
- if self.command and copy_item.outcomes:
182
+ if self.command and self._copy_item_outcomes:
168
183
  self.queue.add(
169
184
  CommandItem(command=self.command, reference=self.reference),
170
185
  )
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-cyberfusion-file-support
3
- Version: 1.8
3
+ Version: 1.9
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.12
9
- Requires-Dist: python3-cyberfusion-queue-support~=3.3
9
+ Requires-Dist: python3-cyberfusion-queue-support~=4.0
10
10
 
11
11
  # python3-cyberfusion-file-support
12
12
 
@@ -0,0 +1,2 @@
1
+ python3-cyberfusion-common~=2.12
2
+ python3-cyberfusion-queue-support~=4.0
@@ -1,2 +0,0 @@
1
- python3-cyberfusion-common~=2.12
2
- python3-cyberfusion-queue-support~=3.3