encommon 0.22.4__py3-none-any.whl → 0.22.5__py3-none-any.whl

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.
@@ -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',
encommon/utils/files.py CHANGED
@@ -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}')
encommon/version.txt CHANGED
@@ -1 +1 @@
1
- 0.22.4
1
+ 0.22.5
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: encommon
3
- Version: 0.22.4
3
+ Version: 0.22.5
4
4
  Summary: Enasis Network Common Library
5
5
  License: MIT
6
6
  Project-URL: Source, https://github.com/enasisnetwork/encommon
@@ -1,7 +1,7 @@
1
1
  encommon/__init__.py,sha256=YDGzuhpk5Gd1hq54LI0hw1NrrDvrJDrvH20TEy_0l5E,443
2
2
  encommon/conftest.py,sha256=I7Zl2cMytnA-mwSPh0rRjsU0YSlES94jQq6mocRhVUE,1884
3
3
  encommon/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- encommon/version.txt,sha256=-eRxdwnwDKJRp0_JuBOL0dSCuOs0VzMGRMBCywRYzlQ,7
4
+ encommon/version.txt,sha256=1_2Pa7I6bnAVrcxjripp4FkoMeyHLQldx8uC7l2MixQ,7
5
5
  encommon/colors/__init__.py,sha256=XRiGimMj8oo040NO5a5ZsbsIUxaGVW4tf4xWTPWgnZY,269
6
6
  encommon/colors/color.py,sha256=YmmJzwTGdTafe_cWENvvoyW4YCyeycVIqCDJYLr4k-w,10918
7
7
  encommon/colors/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
@@ -72,15 +72,15 @@ encommon/types/test/test_funcs.py,sha256=dYVJgihEj1j3F-OxH0mYSIMoDwZbjvgMnvJKea8
72
72
  encommon/types/test/test_lists.py,sha256=uRdON1vnDT21TBl2prlO15SHIkN7YOApZzHS78R-Bvs,1139
73
73
  encommon/types/test/test_notate.py,sha256=KTOqlHUuS7ed80_h0n7TJNkAqoeULrkbiMH6sPw0lak,9520
74
74
  encommon/types/test/test_strings.py,sha256=oXusioFMdknHeBdwlP_GakDVS9Tf2YBndjonj22UfmM,1277
75
- encommon/utils/__init__.py,sha256=bBgh81wX_TwLgWkx0aBAyVLHNphrfcyQc1AF7-ziyNI,1027
75
+ encommon/utils/__init__.py,sha256=Wb-YFSoGlcAW36LsaQTc_IYiqDbb2d8m_ggej42LNeI,1077
76
76
  encommon/utils/common.py,sha256=-bjGJ2UJa-WTOsVYiuZcVj1gkyH5OlRdRkJtxPw8J6k,555
77
- encommon/utils/files.py,sha256=2uj10JfvKZHdLHNF992_LUvQ4rfMRCZGqJd7LrxKDnE,1458
77
+ encommon/utils/files.py,sha256=mP8p9mcYcK3dGqWcLvYxnYamqa0udmtTbXWVPo6i9W4,2208
78
78
  encommon/utils/match.py,sha256=XvmmMKQ1q8_21zzPGuVvaZf6XwHXPZn4IWIYBEqVCQM,2471
79
79
  encommon/utils/paths.py,sha256=u8-vTONG3QdnpkKfVpl19WssH95bCHg1gHlnRwzyAFM,3509
80
80
  encommon/utils/sample.py,sha256=wcT_me9L-U6atd8kEew4q_4B-iIn8vV1LhEDoVr-cFw,4834
81
81
  encommon/utils/stdout.py,sha256=nzXvdnvgjfdtLlAdIsOZurjGMfUX239gZZxPPQK9BIw,8595
82
82
  encommon/utils/test/__init__.py,sha256=PjrnBYT0efyvbaGeNx94dm3tP3EVHUHSVs-VGeLEv5g,218
83
- encommon/utils/test/test_files.py,sha256=-hdl4UOo-vH1H5gTL1r9Ib3P26DtWaD2YV32P08ykvc,679
83
+ encommon/utils/test/test_files.py,sha256=Nc7EteuZpnaFaF8OaqzEhuui9_SYHG1SK1OcoX9jEa8,1175
84
84
  encommon/utils/test/test_match.py,sha256=QagKpTFdRo23-Y55fSaJrSMpt5jIebScKbz0h8tivrI,1124
85
85
  encommon/utils/test/test_paths.py,sha256=4AzIhQyYFEWhRWHgOZCCzomQ3Zs3EVwRnDQDa6Nq1Mc,1942
86
86
  encommon/utils/test/test_sample.py,sha256=Qf-W0XbjTe5PfG87sdVizL2ymUPRTdX0qQtLGHaTgx8,3539
@@ -131,8 +131,8 @@ encommon/webkit/test/test_moderate.py,sha256=KitKGBtwHOQm0pXXZA5nl9MwAi2pbHOsKhM
131
131
  encommon/webkit/test/test_numeric.py,sha256=9Jqiyo-Bh572QJSyd3gqRwYTifnqqzE7_cNCmLn0CG0,3531
132
132
  encommon/webkit/test/test_statate.py,sha256=4VvmyJhsK3TSK-hq3TzkzwPkXY-GPTU_7uJf-zG_y_s,1760
133
133
  encommon/webkit/test/test_tagues.py,sha256=LQWk6rSBoBxAu-YmUOU8uWNki5RBzk5lp0dbFpySg68,1431
134
- encommon-0.22.4.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
135
- encommon-0.22.4.dist-info/METADATA,sha256=Lza7EHPRbAHTVhizIOg3YUEHJAyAbVAx3MtNkHJaNwU,4282
136
- encommon-0.22.4.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
137
- encommon-0.22.4.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
138
- encommon-0.22.4.dist-info/RECORD,,
134
+ encommon-0.22.5.dist-info/LICENSE,sha256=otnXKCtMjPlbHs0wgZ_BWULrp3g_2dWQJ6icRk9nkgg,1071
135
+ encommon-0.22.5.dist-info/METADATA,sha256=oq1HOf6hcMsIW3pXqcJUVApAN43UpT6Bh-1NKf-LpNY,4282
136
+ encommon-0.22.5.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
137
+ encommon-0.22.5.dist-info/top_level.txt,sha256=bP8q7-5tLDNm-3XPlqn_bDENfYNug5801H_xfz3BEAM,9
138
+ encommon-0.22.5.dist-info/RECORD,,