python3-cyberfusion-queue-support 1.1.4__tar.gz → 1.2__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 (30) hide show
  1. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/PKG-INFO +38 -1
  2. python3_cyberfusion_queue_support-1.2/README.md +82 -0
  3. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/pyproject.toml +1 -1
  4. python3_cyberfusion_queue_support-1.2/src/cyberfusion/QueueSupport/items/rmtree.py +57 -0
  5. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/outcomes.py +19 -0
  6. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/python3_cyberfusion_queue_support.egg-info/PKG-INFO +38 -1
  7. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/python3_cyberfusion_queue_support.egg-info/SOURCES.txt +1 -0
  8. python3_cyberfusion_queue_support-1.1.4/README.md +0 -45
  9. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/setup.cfg +0 -0
  10. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/__init__.py +0 -0
  11. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/exceptions/__init__.py +0 -0
  12. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/interfaces.py +0 -0
  13. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/__init__.py +0 -0
  14. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/chmod.py +0 -0
  15. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/chown.py +0 -0
  16. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/command.py +0 -0
  17. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/copy.py +0 -0
  18. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/mkdir.py +0 -0
  19. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/move.py +0 -0
  20. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_tmp_files_create.py +0 -0
  21. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_unit_disable.py +0 -0
  22. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_unit_enable.py +0 -0
  23. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_unit_reload.py +0 -0
  24. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_unit_restart.py +0 -0
  25. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/systemd_unit_stop.py +0 -0
  26. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/items/unlink.py +0 -0
  27. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/cyberfusion/QueueSupport/utilities.py +0 -0
  28. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/python3_cyberfusion_queue_support.egg-info/dependency_links.txt +0 -0
  29. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/python3_cyberfusion_queue_support.egg-info/requires.txt +0 -0
  30. {python3_cyberfusion_queue_support-1.1.4 → python3_cyberfusion_queue_support-1.2}/src/python3_cyberfusion_queue_support.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python3-cyberfusion-queue-support
3
- Version: 1.1.4
3
+ Version: 1.2
4
4
  Summary: Library to queue actions.
5
5
  Author-email: Cyberfusion <support@cyberfusion.io>
6
6
  Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-queue-support
@@ -11,6 +11,43 @@ Requires-Dist: python3-cyberfusion-systemd-support~=1.0
11
11
 
12
12
  Library to queue actions.
13
13
 
14
+ # Concepts
15
+
16
+ All project-specific terms are in _italic_.
17
+
18
+ After creating a _queue_, _items_ can be added to it.
19
+
20
+ ```python
21
+ queue = Queue()
22
+
23
+ queue.add(item)
24
+ ```
25
+
26
+ These _items_ can be of multiple types such as `ChmodItem` or `SystemdUnitRestartItem`, and they can have attributes such as a path for an `MkdirItem` or a unit name for a `SystemdUnitEnableItem`.
27
+
28
+ ```python
29
+ item1 = ChmodItem(path="/tmp/example.txt", mode=0o600)
30
+ item2 = SystemdUnitEnableItem(name="httpd.service")
31
+ ```
32
+
33
+ Each _item_ type has one or multiple _outcomes_ that should come true for an _item_ of that type to be completed. For example: for an _item_ of type `UnlinkItem`, the _outcome_ is that the file at the path given with the _item_ is unlinked.
34
+
35
+ When a _queue_ is _processed_, all the _items_ added to it are _fulfilled_, meaning all the _items'_ _outcomes_ are completed.
36
+
37
+ ```python
38
+ item = RmTreeItem(path="/tmp/dir")
39
+
40
+ queue = Queue()
41
+
42
+ queue.add(item)
43
+
44
+ # for each item added to the queue, its fulfill() function is run
45
+ queue.process()
46
+
47
+ # this would do the same
48
+ item.fulfill()
49
+ ```
50
+
14
51
  # Install
15
52
 
16
53
  ## PyPI
@@ -0,0 +1,82 @@
1
+ # python3-cyberfusion-queue-support
2
+
3
+ Library to queue actions.
4
+
5
+ # Concepts
6
+
7
+ All project-specific terms are in _italic_.
8
+
9
+ After creating a _queue_, _items_ can be added to it.
10
+
11
+ ```python
12
+ queue = Queue()
13
+
14
+ queue.add(item)
15
+ ```
16
+
17
+ These _items_ can be of multiple types such as `ChmodItem` or `SystemdUnitRestartItem`, and they can have attributes such as a path for an `MkdirItem` or a unit name for a `SystemdUnitEnableItem`.
18
+
19
+ ```python
20
+ item1 = ChmodItem(path="/tmp/example.txt", mode=0o600)
21
+ item2 = SystemdUnitEnableItem(name="httpd.service")
22
+ ```
23
+
24
+ Each _item_ type has one or multiple _outcomes_ that should come true for an _item_ of that type to be completed. For example: for an _item_ of type `UnlinkItem`, the _outcome_ is that the file at the path given with the _item_ is unlinked.
25
+
26
+ When a _queue_ is _processed_, all the _items_ added to it are _fulfilled_, meaning all the _items'_ _outcomes_ are completed.
27
+
28
+ ```python
29
+ item = RmTreeItem(path="/tmp/dir")
30
+
31
+ queue = Queue()
32
+
33
+ queue.add(item)
34
+
35
+ # for each item added to the queue, its fulfill() function is run
36
+ queue.process()
37
+
38
+ # this would do the same
39
+ item.fulfill()
40
+ ```
41
+
42
+ # Install
43
+
44
+ ## PyPI
45
+
46
+ Run the following command to install the package from PyPI:
47
+
48
+ pip3 install python3-cyberfusion-queue-support
49
+
50
+ ## Debian
51
+
52
+ Run the following commands to build a Debian package:
53
+
54
+ mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
55
+ dpkg-buildpackage -us -uc
56
+
57
+ # Configure
58
+
59
+ No configuration is supported.
60
+
61
+ # Usage
62
+
63
+ ## Example
64
+
65
+ ```python
66
+ from cyberfusion.QueueSupport import Queue
67
+ from cyberfusion.QueueSupport.items.chmod import ChmodItem
68
+
69
+ queue = Queue()
70
+
71
+ item = ChmodItem(path="/tmp/example.txt", mode=0o600)
72
+ print(item.outcomes)
73
+
74
+ queue.add(item)
75
+
76
+ preview = True or False
77
+
78
+ outcomes = queue.process(preview=preview)
79
+
80
+ for outcome in outcomes:
81
+ print(str(outcome))
82
+ ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python3-cyberfusion-queue-support"
7
- version = "1.1.4"
7
+ version = "1.2"
8
8
  description = "Library to queue actions."
9
9
  readme = "README.md"
10
10
  authors = [
@@ -0,0 +1,57 @@
1
+ """Item."""
2
+
3
+ import logging
4
+ import os
5
+ import shutil
6
+ from typing import List, Optional
7
+
8
+ from cyberfusion.QueueSupport.exceptions import PathIsSymlinkError
9
+ from cyberfusion.QueueSupport.items import _Item
10
+ from cyberfusion.QueueSupport.outcomes import RmTreeItemRemoveOutcome
11
+
12
+ logger = logging.getLogger(__name__)
13
+
14
+
15
+ class RmTreeItem(_Item):
16
+ """Represents item."""
17
+
18
+ def __init__(
19
+ self,
20
+ *,
21
+ path: str,
22
+ reference: Optional[str] = None,
23
+ hide_outcomes: bool = False,
24
+ ) -> None:
25
+ """Set attributes."""
26
+ self.path = path
27
+ self._reference = reference
28
+ self._hide_outcomes = hide_outcomes
29
+
30
+ if os.path.islink(self.path):
31
+ raise PathIsSymlinkError(self.path)
32
+
33
+ @property
34
+ def outcomes(self) -> List[RmTreeItemRemoveOutcome]:
35
+ """Get outcomes of calling self.fulfill."""
36
+ outcomes = []
37
+
38
+ if os.path.exists(self.path):
39
+ outcomes.append(
40
+ RmTreeItemRemoveOutcome(
41
+ path=self.path,
42
+ )
43
+ )
44
+
45
+ return outcomes
46
+
47
+ def fulfill(self) -> None:
48
+ """Fulfill outcomes."""
49
+ for outcome in self.outcomes:
50
+ shutil.rmtree(outcome.path)
51
+
52
+ def __eq__(self, other: object) -> bool:
53
+ """Get equality based on attributes."""
54
+ if not isinstance(other, RmTreeItem):
55
+ return False
56
+
57
+ return other.path == self.path
@@ -105,6 +105,25 @@ class UnlinkItemUnlinkOutcome(OutcomeInterface):
105
105
  return other.path == self.path
106
106
 
107
107
 
108
+ class RmTreeItemRemoveOutcome(OutcomeInterface):
109
+ """Represents outcome."""
110
+
111
+ def __init__(self, *, path: str) -> None:
112
+ """Set attributes."""
113
+ self.path = path
114
+
115
+ def __str__(self) -> str:
116
+ """Get human-readable string."""
117
+ return f"Remove directory tree {self.path}"
118
+
119
+ def __eq__(self, other: object) -> bool:
120
+ """Get equality based on attributes."""
121
+ if not isinstance(other, RmTreeItemRemoveOutcome):
122
+ return False
123
+
124
+ return other.path == self.path
125
+
126
+
108
127
  class CommandItemRunOutcome(OutcomeInterface):
109
128
  """Represents outcome."""
110
129
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python3-cyberfusion-queue-support
3
- Version: 1.1.4
3
+ Version: 1.2
4
4
  Summary: Library to queue actions.
5
5
  Author-email: Cyberfusion <support@cyberfusion.io>
6
6
  Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-queue-support
@@ -11,6 +11,43 @@ Requires-Dist: python3-cyberfusion-systemd-support~=1.0
11
11
 
12
12
  Library to queue actions.
13
13
 
14
+ # Concepts
15
+
16
+ All project-specific terms are in _italic_.
17
+
18
+ After creating a _queue_, _items_ can be added to it.
19
+
20
+ ```python
21
+ queue = Queue()
22
+
23
+ queue.add(item)
24
+ ```
25
+
26
+ These _items_ can be of multiple types such as `ChmodItem` or `SystemdUnitRestartItem`, and they can have attributes such as a path for an `MkdirItem` or a unit name for a `SystemdUnitEnableItem`.
27
+
28
+ ```python
29
+ item1 = ChmodItem(path="/tmp/example.txt", mode=0o600)
30
+ item2 = SystemdUnitEnableItem(name="httpd.service")
31
+ ```
32
+
33
+ Each _item_ type has one or multiple _outcomes_ that should come true for an _item_ of that type to be completed. For example: for an _item_ of type `UnlinkItem`, the _outcome_ is that the file at the path given with the _item_ is unlinked.
34
+
35
+ When a _queue_ is _processed_, all the _items_ added to it are _fulfilled_, meaning all the _items'_ _outcomes_ are completed.
36
+
37
+ ```python
38
+ item = RmTreeItem(path="/tmp/dir")
39
+
40
+ queue = Queue()
41
+
42
+ queue.add(item)
43
+
44
+ # for each item added to the queue, its fulfill() function is run
45
+ queue.process()
46
+
47
+ # this would do the same
48
+ item.fulfill()
49
+ ```
50
+
14
51
  # Install
15
52
 
16
53
  ## PyPI
@@ -13,6 +13,7 @@ src/cyberfusion/QueueSupport/items/command.py
13
13
  src/cyberfusion/QueueSupport/items/copy.py
14
14
  src/cyberfusion/QueueSupport/items/mkdir.py
15
15
  src/cyberfusion/QueueSupport/items/move.py
16
+ src/cyberfusion/QueueSupport/items/rmtree.py
16
17
  src/cyberfusion/QueueSupport/items/systemd_tmp_files_create.py
17
18
  src/cyberfusion/QueueSupport/items/systemd_unit_disable.py
18
19
  src/cyberfusion/QueueSupport/items/systemd_unit_enable.py
@@ -1,45 +0,0 @@
1
- # python3-cyberfusion-queue-support
2
-
3
- Library to queue actions.
4
-
5
- # Install
6
-
7
- ## PyPI
8
-
9
- Run the following command to install the package from PyPI:
10
-
11
- pip3 install python3-cyberfusion-queue-support
12
-
13
- ## Debian
14
-
15
- Run the following commands to build a Debian package:
16
-
17
- mk-build-deps -i -t 'apt -o Debug::pkgProblemResolver=yes --no-install-recommends -y'
18
- dpkg-buildpackage -us -uc
19
-
20
- # Configure
21
-
22
- No configuration is supported.
23
-
24
- # Usage
25
-
26
- ## Example
27
-
28
- ```python
29
- from cyberfusion.QueueSupport import Queue
30
- from cyberfusion.QueueSupport.items.chmod import ChmodItem
31
-
32
- queue = Queue()
33
-
34
- item = ChmodItem(path="/tmp/example.txt", mode=0o600)
35
- print(item.outcomes)
36
-
37
- queue.add(item)
38
-
39
- preview = True or False
40
-
41
- outcomes = queue.process(preview=preview)
42
-
43
- for outcome in outcomes:
44
- print(str(outcome))
45
- ```