encommon 0.22.4__tar.gz → 0.22.6__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 (146) hide show
  1. {encommon-0.22.4/encommon.egg-info → encommon-0.22.6}/PKG-INFO +3 -2
  2. {encommon-0.22.4 → encommon-0.22.6}/encommon/colors/color.py +46 -0
  3. {encommon-0.22.4 → encommon-0.22.6}/encommon/colors/test/test_color.py +3 -1
  4. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_timers.py +2 -2
  5. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_windows.py +2 -2
  6. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/timers.py +12 -11
  7. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/windows.py +12 -11
  8. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/__init__.py +2 -0
  9. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/files.py +39 -0
  10. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/test_files.py +28 -0
  11. encommon-0.22.6/encommon/version.txt +1 -0
  12. {encommon-0.22.4 → encommon-0.22.6/encommon.egg-info}/PKG-INFO +3 -2
  13. encommon-0.22.4/encommon/version.txt +0 -1
  14. {encommon-0.22.4 → encommon-0.22.6}/LICENSE +0 -0
  15. {encommon-0.22.4 → encommon-0.22.6}/MANIFEST.in +0 -0
  16. {encommon-0.22.4 → encommon-0.22.6}/README.md +0 -0
  17. {encommon-0.22.4 → encommon-0.22.6}/encommon/__init__.py +0 -0
  18. {encommon-0.22.4 → encommon-0.22.6}/encommon/colors/__init__.py +0 -0
  19. {encommon-0.22.4 → encommon-0.22.6}/encommon/colors/test/__init__.py +0 -0
  20. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/__init__.py +0 -0
  21. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/config.py +0 -0
  22. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/files.py +0 -0
  23. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/logger.py +0 -0
  24. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/params.py +0 -0
  25. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/paths.py +0 -0
  26. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/__init__.py +0 -0
  27. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/test_config.py +0 -0
  28. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/test_files.py +0 -0
  29. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/test_logger.py +0 -0
  30. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/test_paths.py +0 -0
  31. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/test/test_utils.py +0 -0
  32. {encommon-0.22.4 → encommon-0.22.6}/encommon/config/utils.py +0 -0
  33. {encommon-0.22.4 → encommon-0.22.6}/encommon/conftest.py +0 -0
  34. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/__init__.py +0 -0
  35. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/crypts.py +0 -0
  36. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/hashes.py +0 -0
  37. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/params.py +0 -0
  38. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/test/__init__.py +0 -0
  39. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/test/test_crypts.py +0 -0
  40. {encommon-0.22.4 → encommon-0.22.6}/encommon/crypts/test/test_hashes.py +0 -0
  41. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/__init__.py +0 -0
  42. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/jinja2.py +0 -0
  43. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/network.py +0 -0
  44. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/test/__init__.py +0 -0
  45. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/test/test_jinja2.py +0 -0
  46. {encommon-0.22.4 → encommon-0.22.6}/encommon/parse/test/test_network.py +0 -0
  47. {encommon-0.22.4 → encommon-0.22.6}/encommon/py.typed +0 -0
  48. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/__init__.py +0 -0
  49. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/common.py +0 -0
  50. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/duration.py +0 -0
  51. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/params.py +0 -0
  52. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/parse.py +0 -0
  53. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/__init__.py +0 -0
  54. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_duration.py +0 -0
  55. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_params.py +0 -0
  56. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_parse.py +0 -0
  57. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_time.py +0 -0
  58. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_timer.py +0 -0
  59. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_unitime.py +0 -0
  60. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_utils.py +0 -0
  61. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/test/test_window.py +0 -0
  62. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/time.py +0 -0
  63. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/timer.py +0 -0
  64. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/unitime.py +0 -0
  65. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/utils.py +0 -0
  66. {encommon-0.22.4 → encommon-0.22.6}/encommon/times/window.py +0 -0
  67. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/__init__.py +0 -0
  68. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/classes.py +0 -0
  69. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/dicts.py +0 -0
  70. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/empty.py +0 -0
  71. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/funcs.py +0 -0
  72. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/lists.py +0 -0
  73. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/notate.py +0 -0
  74. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/strings.py +0 -0
  75. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/__init__.py +0 -0
  76. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_classes.py +0 -0
  77. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_dicts.py +0 -0
  78. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_empty.py +0 -0
  79. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_funcs.py +0 -0
  80. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_lists.py +0 -0
  81. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_notate.py +0 -0
  82. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/test/test_strings.py +0 -0
  83. {encommon-0.22.4 → encommon-0.22.6}/encommon/types/types.py +0 -0
  84. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/common.py +0 -0
  85. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/match.py +0 -0
  86. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/paths.py +0 -0
  87. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/sample.py +0 -0
  88. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/stdout.py +0 -0
  89. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/__init__.py +0 -0
  90. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/test_match.py +0 -0
  91. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/test_paths.py +0 -0
  92. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/test_sample.py +0 -0
  93. {encommon-0.22.4 → encommon-0.22.6}/encommon/utils/test/test_stdout.py +0 -0
  94. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/__init__.py +0 -0
  95. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/content.py +0 -0
  96. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/images/enasis.svg +0 -0
  97. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/images/failure.svg +0 -0
  98. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/images/information.svg +0 -0
  99. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/images/success.svg +0 -0
  100. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/images/warning.svg +0 -0
  101. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/index.html +0 -0
  102. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/color.js +0 -0
  103. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/datagrid.js +0 -0
  104. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/datetime.js +0 -0
  105. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/default.js +0 -0
  106. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/duration.js +0 -0
  107. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/helpers.js +0 -0
  108. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/image.js +0 -0
  109. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/message.js +0 -0
  110. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/moderate.js +0 -0
  111. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/numeric.js +0 -0
  112. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/statate.js +0 -0
  113. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/scripts/tagues.js +0 -0
  114. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/color.css +0 -0
  115. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/datagrid.css +0 -0
  116. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/datetime.css +0 -0
  117. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/default.css +0 -0
  118. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/duration.css +0 -0
  119. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/image.css +0 -0
  120. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/message.css +0 -0
  121. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/moderate.css +0 -0
  122. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/numeric.css +0 -0
  123. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/statate.css +0 -0
  124. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/styles/tagues.css +0 -0
  125. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/__init__.py +0 -0
  126. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/conftest.py +0 -0
  127. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_color.py +0 -0
  128. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_content.py +0 -0
  129. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_datagrid.py +0 -0
  130. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_datetime.py +0 -0
  131. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_default.py +0 -0
  132. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_duration.py +0 -0
  133. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_helpers.py +0 -0
  134. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_image.py +0 -0
  135. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_message.py +0 -0
  136. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_moderate.py +0 -0
  137. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_numeric.py +0 -0
  138. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_statate.py +0 -0
  139. {encommon-0.22.4 → encommon-0.22.6}/encommon/webkit/test/test_tagues.py +0 -0
  140. {encommon-0.22.4 → encommon-0.22.6}/encommon.egg-info/SOURCES.txt +0 -0
  141. {encommon-0.22.4 → encommon-0.22.6}/encommon.egg-info/dependency_links.txt +0 -0
  142. {encommon-0.22.4 → encommon-0.22.6}/encommon.egg-info/requires.txt +0 -0
  143. {encommon-0.22.4 → encommon-0.22.6}/encommon.egg-info/top_level.txt +0 -0
  144. {encommon-0.22.4 → encommon-0.22.6}/pyproject.toml +0 -0
  145. {encommon-0.22.4 → encommon-0.22.6}/require/install.txt +0 -0
  146. {encommon-0.22.4 → encommon-0.22.6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: encommon
3
- Version: 0.22.4
3
+ Version: 0.22.6
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Project-URL: Source, https://github.com/enasisnetwork/encommon
@@ -20,6 +20,7 @@ Requires-Dist: python-dateutil
20
20
  Requires-Dist: pyyaml
21
21
  Requires-Dist: snaptime
22
22
  Requires-Dist: sqlalchemy
23
+ Dynamic: license-file
23
24
 
24
25
  # Enasis Network Common Library
25
26
 
@@ -7,6 +7,7 @@ is permitted, for more information consult the project license file.
7
7
 
8
8
 
9
9
 
10
+ from colorsys import hls_to_rgb
10
11
  from contextlib import suppress
11
12
  from typing import Union
12
13
 
@@ -61,6 +62,51 @@ class Color:
61
62
  self.__source = source
62
63
 
63
64
 
65
+ @classmethod
66
+ def from_hsl(
67
+ cls,
68
+ hue: int,
69
+ sat: int,
70
+ lev: int,
71
+ ) -> 'Color':
72
+ """
73
+ Initialize instance for class using provided parameters.
74
+ """
75
+
76
+ h, s, l = ( # noqa: E741
77
+ hue / 360,
78
+ sat / 100,
79
+ lev / 100)
80
+
81
+ r, g, b = hls_to_rgb(h, l, s)
82
+
83
+ color = (
84
+ f'{round(r * 255):02X}'
85
+ f'{round(g * 255):02X}'
86
+ f'{round(b * 255):02X}')
87
+
88
+ return cls(color)
89
+
90
+
91
+ @classmethod
92
+ def from_rgb(
93
+ cls,
94
+ red: int,
95
+ green: int,
96
+ blue: int,
97
+ ) -> 'Color':
98
+ """
99
+ Initialize instance for class using provided parameters.
100
+ """
101
+
102
+ value = (
103
+ f'{red:02X}'
104
+ f'{green:02X}'
105
+ f'{blue:02X}')
106
+
107
+ return cls(value)
108
+
109
+
64
110
  def __repr__(
65
111
  self,
66
112
  ) -> str:
@@ -84,6 +84,7 @@ def test_Color_rgb(
84
84
  """
85
85
 
86
86
  assert Color(source).rgb == expect
87
+ assert Color.from_rgb(*expect) == source
87
88
 
88
89
 
89
90
 
@@ -155,7 +156,7 @@ def test_Color_xy(
155
156
  ('ffff00', (60, 100, 50)),
156
157
  ('00ffff', (180, 100, 50)),
157
158
  ('ff00ff', (300, 100, 50)),
158
- ('800080', (300, 100, 25))])
159
+ ('80007F', (300, 100, 25))])
159
160
  def test_Color_hsl(
160
161
  source: str,
161
162
  expect: tuple[int, ...],
@@ -168,6 +169,7 @@ def test_Color_hsl(
168
169
  """
169
170
 
170
171
  assert Color(source).hsl == expect
172
+ assert Color.from_hsl(*expect) == source
171
173
 
172
174
 
173
175
 
@@ -100,8 +100,8 @@ def test_Timers(
100
100
  '_Timers__params',
101
101
  '_Timers__store',
102
102
  '_Timers__group',
103
- '_Timers__store_engine',
104
- '_Timers__store_session',
103
+ '_Timers__sengine',
104
+ '_Timers__session',
105
105
  '_Timers__timers']
106
106
 
107
107
 
@@ -111,8 +111,8 @@ def test_Windows(
111
111
  '_Windows__params',
112
112
  '_Windows__store',
113
113
  '_Windows__group',
114
- '_Windows__store_engine',
115
- '_Windows__store_session',
114
+ '_Windows__sengine',
115
+ '_Windows__session',
116
116
  '_Windows__start',
117
117
  '_Windows__stop',
118
118
  '_Windows__windows']
@@ -107,8 +107,8 @@ class Timers:
107
107
  __store: str
108
108
  __group: str
109
109
 
110
- __store_engine: Engine
111
- __store_session: (
110
+ __sengine: Engine
111
+ __session: (
112
112
  # pylint: disable=unsubscriptable-object
113
113
  sessionmaker[Session])
114
114
 
@@ -152,17 +152,18 @@ class Timers:
152
152
  Construct instances using the configuration parameters.
153
153
  """
154
154
 
155
- store = self.__store
156
-
157
- engine = create_engine(store)
155
+ sengine = create_engine(
156
+ self.__store,
157
+ pool_pre_ping=True)
158
158
 
159
159
  (SQLBase.metadata
160
- .create_all(engine))
160
+ .create_all(sengine))
161
161
 
162
- session = sessionmaker(engine)
162
+ session = (
163
+ sessionmaker(sengine))
163
164
 
164
- self.__store_engine = engine
165
- self.__store_session = session
165
+ self.__sengine = sengine
166
+ self.__session = session
166
167
 
167
168
 
168
169
  @property
@@ -214,7 +215,7 @@ class Timers:
214
215
  :returns: Value for the attribute from class instance.
215
216
  """
216
217
 
217
- return self.__store_engine
218
+ return self.__sengine
218
219
 
219
220
 
220
221
  @property
@@ -227,7 +228,7 @@ class Timers:
227
228
  :returns: Value for the attribute from class instance.
228
229
  """
229
230
 
230
- return self.__store_session()
231
+ return self.__session()
231
232
 
232
233
 
233
234
  @property
@@ -109,8 +109,8 @@ class Windows:
109
109
  __store: str
110
110
  __group: str
111
111
 
112
- __store_engine: Engine
113
- __store_session: (
112
+ __sengine: Engine
113
+ __session: (
114
114
  # pylint: disable=unsubscriptable-object
115
115
  sessionmaker[Session])
116
116
 
@@ -168,17 +168,18 @@ class Windows:
168
168
  Construct instances using the configuration parameters.
169
169
  """
170
170
 
171
- store = self.__store
172
-
173
- engine = create_engine(store)
171
+ sengine = create_engine(
172
+ self.__store,
173
+ pool_pre_ping=True)
174
174
 
175
175
  (SQLBase.metadata
176
- .create_all(engine))
176
+ .create_all(sengine))
177
177
 
178
- session = sessionmaker(engine)
178
+ session = (
179
+ sessionmaker(sengine))
179
180
 
180
- self.__store_engine = engine
181
- self.__store_session = session
181
+ self.__sengine = sengine
182
+ self.__session = session
182
183
 
183
184
 
184
185
  @property
@@ -230,7 +231,7 @@ class Windows:
230
231
  :returns: Value for the attribute from class instance.
231
232
  """
232
233
 
233
- return self.__store_engine
234
+ return self.__sengine
234
235
 
235
236
 
236
237
  @property
@@ -243,7 +244,7 @@ class Windows:
243
244
  :returns: Value for the attribute from class instance.
244
245
  """
245
246
 
246
- return self.__store_session()
247
+ return self.__session()
247
248
 
248
249
 
249
250
  @property
@@ -7,6 +7,7 @@ is permitted, for more information consult the project license file.
7
7
 
8
8
 
9
9
 
10
+ from .files import append_text
10
11
  from .files import read_text
11
12
  from .files import save_text
12
13
  from .match import fuzz_match
@@ -27,6 +28,7 @@ from .stdout import strip_ansi
27
28
 
28
29
 
29
30
  __all__ = [
31
+ 'append_text',
30
32
  'array_ansi',
31
33
  'fuzz_match',
32
34
  'kvpair_ansi',
@@ -23,6 +23,8 @@ def read_text(
23
23
 
24
24
  Example
25
25
  -------
26
+ >>> path.exists()
27
+ False
26
28
  >>> save_text(path, 'foo')
27
29
  'foo'
28
30
  >>> read_text(path)
@@ -52,6 +54,8 @@ def save_text(
52
54
 
53
55
  Example
54
56
  -------
57
+ >>> path.exists()
58
+ False
55
59
  >>> save_text(path, 'foo')
56
60
  'foo'
57
61
  >>> read_text(path)
@@ -69,3 +73,38 @@ def save_text(
69
73
  encoding='utf-8')
70
74
 
71
75
  return read_text(path)
76
+
77
+
78
+
79
+ def append_text(
80
+ path: str | Path,
81
+ content: str,
82
+ ) -> None:
83
+ """
84
+ Append the provided text content into provided file path.
85
+
86
+ .. testsetup::
87
+ >>> tmpdir = getfixture('tmpdir')
88
+ >>> path = Path(f'{tmpdir}/text.txt')
89
+
90
+ Example
91
+ -------
92
+ >>> path.exists()
93
+ False
94
+ >>> append_text(path, 'foo')
95
+ >>> append_text(path, 'foo')
96
+ >>> read_text(path)
97
+ 'foofoo'
98
+
99
+ :param path: Complete or relative path to the text file.
100
+ :param content: Content that will be written to the file.
101
+ """
102
+
103
+ path = Path(path).resolve()
104
+
105
+ with path.open(
106
+ mode='a',
107
+ encoding='utf-8',
108
+ ) as file:
109
+
110
+ file.write(f'{content}')
@@ -9,6 +9,7 @@ is permitted, for more information consult the project license file.
9
9
 
10
10
  from pathlib import Path
11
11
 
12
+ from ..files import append_text
12
13
  from ..files import read_text
13
14
  from ..files import save_text
14
15
 
@@ -33,3 +34,30 @@ def test_readsave_text(
33
34
  f'{tmp_path}/test.txt')
34
35
 
35
36
  assert loaded == content
37
+
38
+
39
+
40
+ def test_append_text(
41
+ tmp_path: Path,
42
+ ) -> None:
43
+ """
44
+ Perform various tests associated with relevant routines.
45
+
46
+ :param tmp_path: pytest object for temporal filesystem.
47
+ """
48
+
49
+ content = 'pytest'
50
+
51
+ append_text(
52
+ f'{tmp_path}/test.txt',
53
+ content)
54
+
55
+ append_text(
56
+ f'{tmp_path}/test.txt',
57
+ content)
58
+
59
+ loaded = read_text(
60
+ f'{tmp_path}/test.txt')
61
+
62
+ assert loaded == (
63
+ f'{content}{content}')
@@ -0,0 +1 @@
1
+ 0.22.6
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: encommon
3
- Version: 0.22.4
3
+ Version: 0.22.6
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Project-URL: Source, https://github.com/enasisnetwork/encommon
@@ -20,6 +20,7 @@ Requires-Dist: python-dateutil
20
20
  Requires-Dist: pyyaml
21
21
  Requires-Dist: snaptime
22
22
  Requires-Dist: sqlalchemy
23
+ Dynamic: license-file
23
24
 
24
25
  # Enasis Network Common Library
25
26
 
@@ -1 +0,0 @@
1
- 0.22.4
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes