bluer-objects 6.103.1__py3-none-any.whl → 6.107.1__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.

Potentially problematic release.


This version of bluer-objects might be problematic. Click here for more details.

bluer_objects/__init__.py CHANGED
@@ -4,7 +4,7 @@ ICON = "🌀"
4
4
 
5
5
  DESCRIPTION = f"{ICON} Object management in Bash."
6
6
 
7
- VERSION = "6.103.1"
7
+ VERSION = "6.107.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
@@ -149,21 +149,14 @@ def load_matrix(
149
149
  def load_text(
150
150
  filename,
151
151
  ignore_error=False,
152
- count=-1,
153
152
  log=False,
154
153
  ) -> Tuple[bool, List[str]]:
155
154
  success = True
156
155
  text = []
157
156
 
158
157
  try:
159
- if count == -1:
160
- with open(filename, "r") as fp:
161
- text = fp.read()
162
- text = text.split("\n")
163
- else:
164
- # https://stackoverflow.com/a/1767589/10917551
165
- with open(filename) as fp:
166
- text = [next(fp) for _ in range(count)]
158
+ with open(filename, "r") as fp:
159
+ text = fp.read().splitlines()
167
160
  except:
168
161
  success = False
169
162
  if not ignore_error:
@@ -13,7 +13,6 @@ from bluer_options.host import is_jupyter
13
13
  from bluer_objects import NAME
14
14
  from bluer_objects.file.classes import JsonEncoder
15
15
  from bluer_objects.file.functions import path as file_path
16
- from bluer_objects.file.load import load_text
17
16
  from bluer_objects.path import create as path_create
18
17
  from bluer_objects.logger import logger
19
18
 
@@ -214,32 +213,15 @@ def save_matrix(
214
213
  def save_text(
215
214
  filename: str,
216
215
  text: List[str],
217
- if_different: bool = False,
218
216
  log: bool = False,
219
- remove_empty_lines: bool = False,
220
217
  ) -> bool:
221
- if remove_empty_lines:
222
- text = [
223
- line
224
- for line, next_line in zip(text, text[1:] + ["x"])
225
- if line.strip() or next_line.strip()
226
- ]
227
-
228
- if if_different:
229
- _, content = load_text(filename, ignore_error=True)
230
-
231
- if "|".join([line for line in content if line]) == "|".join(
232
- [line for line in text if line]
233
- ):
234
- return True
235
-
236
218
  if not prepare_for_saving(filename):
237
219
  return False
238
220
 
239
221
  success = True
240
222
  try:
241
223
  with open(filename, "w") as fp:
242
- fp.writelines([string + "\n" for string in text])
224
+ fp.writelines(string + "\n" for string in text)
243
225
  except:
244
226
  success = False
245
227
 
@@ -0,0 +1,46 @@
1
+ import pytest
2
+
3
+ from bluer_options import string
4
+
5
+ from bluer_objects import file, objects
6
+ from bluer_objects.file.load import load_text
7
+ from bluer_objects.file.save import save_text
8
+ from bluer_objects.tests.test_objects import test_object
9
+
10
+
11
+ @pytest.mark.parametrize(
12
+ [
13
+ "filename",
14
+ ],
15
+ [
16
+ ["test.json"],
17
+ ["test.yaml"],
18
+ ["test.yaml"],
19
+ ],
20
+ )
21
+ def test_file_load_save_text(
22
+ test_object,
23
+ filename: str,
24
+ ):
25
+ filename_input = objects.path_of(
26
+ object_name=test_object,
27
+ filename=filename,
28
+ )
29
+ success, text_input = load_text(filename_input)
30
+ assert success
31
+
32
+ filename_test = file.add_suffix(
33
+ filename_input,
34
+ string.random(),
35
+ )
36
+ assert save_text(
37
+ filename_test,
38
+ text_input,
39
+ )
40
+
41
+ success, text_output = load_text(filename_test)
42
+ assert success
43
+
44
+ assert len(text_input) == len(text_output)
45
+ for line_input, line_output in zip(text_input, text_output):
46
+ assert line_input == line_output
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluer_objects
3
- Version: 6.103.1
3
+ Version: 6.107.1
4
4
  Summary: 🌀 Object management in Bash.
5
5
  Home-page: https://github.com/kamangir/bluer-objects
6
6
  Author: Arash Abadpour (Kamangir)
@@ -63,6 +63,6 @@ pip install bluer-objects
63
63
 
64
64
  [![pylint](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/bluer-objects/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/bluer-objects.svg)](https://pypi.org/project/bluer-objects/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/bluer-objects)](https://pypistats.org/packages/bluer-objects)
65
65
 
66
- built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.103.1`](https://github.com/kamangir/bluer-objects).
66
+ built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.107.1`](https://github.com/kamangir/bluer-objects).
67
67
 
68
68
  built by 🌀 [`blueness-3.118.1`](https://github.com/kamangir/blueness).
@@ -1,4 +1,4 @@
1
- bluer_objects/__init__.py,sha256=l5ZTPs6AveML8TYHvGI4_JJmsBGTpj05VyBncLTC1L8,315
1
+ bluer_objects/__init__.py,sha256=rJ5ww8HpbXyQL_nx9tdXZDwCTjouiSu4k9Sko60RGVM,315
2
2
  bluer_objects/__main__.py,sha256=Yqfov833_hJuRne19WrGhT5DWAPtdffpoMxeSXS7EGw,359
3
3
  bluer_objects/config.env,sha256=cMVT0kVQ00xGUoQyUqC8jpqkhR13Kpkl1-0sKQlxQAI,85
4
4
  bluer_objects/env.py,sha256=J5LklWyWT-Yvvoe8MVCZQ3iqRqyDutq6IbNYNj9A1VM,1183
@@ -66,8 +66,8 @@ bluer_objects/file/__init__.py,sha256=c_79ipBkKl6OFDimOev0vnaVdpUk-Bl3oJUapOreMX
66
66
  bluer_objects/file/__main__.py,sha256=v2IXWvZeh_B2sGYWzv1CiUY-7HWHXXghZM5M4IPjbu4,1277
67
67
  bluer_objects/file/classes.py,sha256=TRgeRP2yxInPkBnywhuB4BsoBcBRA3UmQzX1dI43UxU,872
68
68
  bluer_objects/file/functions.py,sha256=CiHZLK9Mz8M3-U_dpQSlfEIAl52zPBWyQDepLoll6Ow,6389
69
- bluer_objects/file/load.py,sha256=bNwHSPFqww9c1mUJJCZqBpOF-6rR6xftecvxWB6Ziks,4518
70
- bluer_objects/file/save.py,sha256=a41ghjdCm25hnSsgvlsJ_Z8Jk9MCe431D4UC3E8bSTU,5530
69
+ bluer_objects/file/load.py,sha256=1zt5xC95HFr89G9lsi3gCJMSvC4Bt0vVeeUEf3NjpOQ,4281
70
+ bluer_objects/file/save.py,sha256=dl-3qfrh3ZmD42_JFmaBXWcoXdZ-cipt_LTGrHyaV7I,4997
71
71
  bluer_objects/graphics/__init__.py,sha256=Dd0kQqN7Ldvp1N9oyIirPZ6W3IdUtfPj2u21Bf4W_MI,213
72
72
  bluer_objects/graphics/__main__.py,sha256=A221gpkUDYd_S2eYz8i6KwaPumg8myaR7L5j464wC54,1909
73
73
  bluer_objects/graphics/frame.py,sha256=WcSn-0oqDw48Akmn_bwcjDC9U_kKqRYRoGWYPoKyFvY,321
@@ -119,6 +119,7 @@ bluer_objects/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
119
119
  bluer_objects/tests/test_README.py,sha256=5D4UV8VcjbeAPThsYVynYtVFuP8gwMAhIjEWuOQZsWs,89
120
120
  bluer_objects/tests/test_env.py,sha256=Gjjb9FoQ6MPvFwX8pdx74aND8Ye_Bb-8XpaaKOZtw-4,547
121
121
  bluer_objects/tests/test_file_load_save.py,sha256=mNCo3ay55ktc5L6SPpNyrpsJrGfVpYi66EgunlAN-Uw,2406
122
+ bluer_objects/tests/test_file_load_save_text.py,sha256=3XnBGlv3KZvheHY-RlX1Su6LOBkkn57pkf9_dXR81r8,1017
122
123
  bluer_objects/tests/test_fullname.py,sha256=xWFf9qqzDQ-4RxRyvyR9GWZyU5qNrKxru94UUKMJfPk,80
123
124
  bluer_objects/tests/test_graphics.py,sha256=mEuk0rWLwr7b2nv4FH6f-RphwfqP23xe2pkjhWe0HgU,238
124
125
  bluer_objects/tests/test_graphics_frame.py,sha256=wRW3MjnfS8edNHiWi_BFJBULoLs1JlJhpFeuCoW5I6A,267
@@ -136,8 +137,8 @@ bluer_objects/tests/test_path.py,sha256=JjONWyhZyMM_u1SzD1RI_iZ5vYJDUe-B51fbbHcz
136
137
  bluer_objects/tests/test_storage.py,sha256=2tJ6Hev9ShId9Qn-0FXDw41HWjcl3wymcB_Bv1FJWi4,1127
137
138
  bluer_objects/tests/test_testing.py,sha256=d2NH435yqJBl9wmfMqGGd-f0Y0jsL2QhHUXkty9AwPA,235
138
139
  bluer_objects/tests/test_version.py,sha256=Lyf3PMcA22e17BNRk_2VgPrtao6dWEgVoXo68Uds8SE,75
139
- bluer_objects-6.103.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
140
- bluer_objects-6.103.1.dist-info/METADATA,sha256=jtcIhVIzQCwRR3Rxj-us7_yS8-ccb5ZBkvZhnn5W3N8,3554
141
- bluer_objects-6.103.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
142
- bluer_objects-6.103.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
143
- bluer_objects-6.103.1.dist-info/RECORD,,
140
+ bluer_objects-6.107.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
141
+ bluer_objects-6.107.1.dist-info/METADATA,sha256=VHCtDaSYE3R4wQONP0xEzOa98ZSX1oV0ycaZU7S8zKc,3554
142
+ bluer_objects-6.107.1.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
143
+ bluer_objects-6.107.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
144
+ bluer_objects-6.107.1.dist-info/RECORD,,