bluer-objects 6.229.1__py3-none-any.whl → 6.233.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.

@@ -3,13 +3,15 @@
3
3
  function bluer_objects_download() {
4
4
  local options=$1
5
5
  local filename=$(bluer_ai_option "$options" filename)
6
+ local policy=$(bluer_ai_option "$options" policy none)
6
7
 
7
8
  local object_name=$(bluer_ai_clarify_object $2 .)
8
9
 
9
10
  python3 -m bluer_objects.storage \
10
11
  download \
11
12
  --object_name $object_name \
12
- --filename "$filename"
13
+ --filename "$filename" \
14
+ --policy $policy
13
15
  [[ $? -ne 0 ]] && return 1
14
16
 
15
17
  local open_options=$3
@@ -63,6 +63,12 @@ function test_bluer_objects_storage_upload_download() {
63
63
  [[ $? -ne 0 ]] && return 1
64
64
  bluer_ai_hr
65
65
 
66
+ bluer_objects_download \
67
+ policy=doesnt_exist \
68
+ $object_name
69
+ [[ $? -ne 0 ]] && return 1
70
+ bluer_ai_hr
71
+
66
72
  bluer_objects_upload \
67
73
  zip \
68
74
  $object_name
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.229.1"
7
+ VERSION = "6.233.1"
8
8
 
9
9
  REPO_NAME = "bluer-objects"
10
10
 
@@ -2,12 +2,24 @@ from typing import List
2
2
 
3
3
  from bluer_options.terminal import show_usage, xtra
4
4
 
5
+ from bluer_objects.storage.policies import DownloadPolicy
6
+
5
7
 
6
8
  def help_download(
7
9
  tokens: List[str],
8
10
  mono: bool,
9
11
  ) -> str:
10
- options = "filename=<filename>"
12
+ options = "".join(
13
+ [
14
+ "filename=<filename>",
15
+ xtra(
16
+ ",policy={}".format(
17
+ "|".join(sorted([policy.name.lower() for policy in DownloadPolicy]))
18
+ ),
19
+ mono=mono,
20
+ ),
21
+ ]
22
+ )
11
23
 
12
24
  open_options = "open,QGIS"
13
25
 
@@ -4,6 +4,7 @@ from webdav3.client import Client
4
4
  from bluer_objects.storage.base import StorageInterface
5
5
  from bluer_objects import env, file, path
6
6
  from bluer_objects import objects
7
+ from bluer_objects.storage.policies import DownloadPolicy
7
8
  from bluer_objects.logger import logger
8
9
 
9
10
 
@@ -56,6 +57,7 @@ class WebDAVInterface(StorageInterface):
56
57
  object_name: str,
57
58
  filename: str = "",
58
59
  log: bool = True,
60
+ policy: DownloadPolicy = DownloadPolicy.NONE,
59
61
  ) -> bool:
60
62
  local_path = objects.path_of(
61
63
  object_name=object_name,
@@ -80,6 +82,7 @@ class WebDAVInterface(StorageInterface):
80
82
  object_name=object_name,
81
83
  filename=filename,
82
84
  log=log,
85
+ policy=policy,
83
86
  )
84
87
 
85
88
  def upload(
@@ -8,6 +8,7 @@ from tqdm import tqdm
8
8
  from bluer_objects.storage.base import StorageInterface
9
9
  from bluer_objects import env, file, path
10
10
  from bluer_objects import objects
11
+ from bluer_objects.storage.policies import DownloadPolicy
11
12
  from bluer_objects.logger import logger
12
13
 
13
14
 
@@ -136,6 +137,7 @@ class WebDAVRequestInterface(StorageInterface):
136
137
  object_name: str,
137
138
  filename: str = "",
138
139
  log: bool = True,
140
+ policy: DownloadPolicy = DownloadPolicy.NONE,
139
141
  ) -> bool:
140
142
  if filename:
141
143
  local_path = objects.path_of(
@@ -176,6 +178,7 @@ class WebDAVRequestInterface(StorageInterface):
176
178
  object_name=object_name,
177
179
  filename=filename,
178
180
  log=log,
181
+ policy=policy,
179
182
  )
180
183
 
181
184
  logger.error(f"failed to download: {response.status_code}")
@@ -193,6 +196,7 @@ class WebDAVRequestInterface(StorageInterface):
193
196
  object_name=object_name,
194
197
  filename=filename_,
195
198
  log=log,
199
+ policy=policy,
196
200
  ):
197
201
  return False
198
202
 
@@ -5,9 +5,10 @@ from webdav3.client import Client
5
5
  from tqdm import tqdm
6
6
 
7
7
  from bluer_objects.storage.base import StorageInterface
8
- from bluer_objects import env, file, path
8
+ from bluer_objects import env
9
9
  from bluer_objects import objects
10
- from bluer_objects.host import zip, unzip
10
+ from bluer_objects.host import unzip
11
+ from bluer_objects.storage.policies import DownloadPolicy
11
12
  from bluer_objects.logger import logger
12
13
 
13
14
 
@@ -65,6 +66,7 @@ class WebDAVzipInterface(StorageInterface):
65
66
  object_name: str,
66
67
  filename: str = "",
67
68
  log: bool = True,
69
+ policy: DownloadPolicy = DownloadPolicy.NONE,
68
70
  ) -> bool:
69
71
  object_path = objects.object_path(
70
72
  object_name=object_name,
@@ -99,6 +101,7 @@ class WebDAVzipInterface(StorageInterface):
99
101
  return super().download(
100
102
  object_name=object_name,
101
103
  log=log,
104
+ policy=policy,
102
105
  )
103
106
 
104
107
  def ls(
@@ -5,6 +5,7 @@ from bluer_objects.storage.base import StorageInterface
5
5
  from bluer_objects.storage.WebDAV import WebDAVInterface
6
6
  from bluer_objects.storage.WebDAVrequest import WebDAVRequestInterface
7
7
  from bluer_objects.storage.WebDAVzip import WebDAVzipInterface
8
+ from bluer_objects.storage.policies import DownloadPolicy
8
9
  from bluer_objects import env
9
10
  from bluer_objects.logger import logger
10
11
 
@@ -35,11 +36,13 @@ def download(
35
36
  object_name: str,
36
37
  filename: str = "",
37
38
  log: bool = True,
39
+ policy: DownloadPolicy = DownloadPolicy.NONE,
38
40
  ) -> bool:
39
41
  return interface.download(
40
42
  object_name=object_name,
41
43
  filename=filename,
42
44
  log=log,
45
+ policy=policy,
43
46
  )
44
47
 
45
48
 
@@ -5,6 +5,7 @@ from blueness.argparse.generic import sys_exit
5
5
 
6
6
  from bluer_objects import NAME
7
7
  from bluer_objects import storage
8
+ from bluer_objects.storage.policies import DownloadPolicy
8
9
  from bluer_objects.logger import logger
9
10
 
10
11
  NAME = module.name(__file__, NAME)
@@ -59,6 +60,12 @@ parser.add_argument(
59
60
  default=1,
60
61
  help="0 | 1",
61
62
  )
63
+ parser.add_argument(
64
+ "--policy",
65
+ type=str,
66
+ default="none",
67
+ help=" | ".join(sorted([policy.name.lower() for policy in DownloadPolicy])),
68
+ )
62
69
  args = parser.parse_args()
63
70
 
64
71
  delim = " " if args.delim == "space" else args.delim
@@ -72,6 +79,7 @@ elif args.task == "download":
72
79
  success = storage.download(
73
80
  object_name=args.object_name,
74
81
  filename=args.filename,
82
+ policy=DownloadPolicy[args.policy.upper()],
75
83
  )
76
84
  elif args.task == "ls":
77
85
  success, list_of_files = storage.ls(
@@ -3,6 +3,7 @@ import glob
3
3
  from typing import Tuple, List
4
4
 
5
5
  from bluer_objects import objects
6
+ from bluer_objects.storage.policies import DownloadPolicy
6
7
  from bluer_objects.logger import logger
7
8
 
8
9
 
@@ -18,13 +19,19 @@ class StorageInterface:
18
19
  object_name: str,
19
20
  filename: str = "",
20
21
  log: bool = True,
22
+ policy: DownloadPolicy = DownloadPolicy.NONE,
21
23
  ) -> bool:
22
24
  if log:
23
25
  logger.info(
24
- "{}.download {}{}".format(
26
+ "{}.download {}{}{}".format(
25
27
  self.__class__.__name__,
26
28
  object_name,
27
29
  f"/{filename}" if filename else "",
30
+ (
31
+ ""
32
+ if policy == DownloadPolicy.NONE
33
+ else " - policy:{}".format(policy.name.lower())
34
+ ),
28
35
  )
29
36
  )
30
37
 
@@ -0,0 +1,7 @@
1
+ from enum import Enum, auto
2
+
3
+
4
+ class DownloadPolicy(Enum):
5
+ NONE = auto()
6
+ DOESNT_EXIST = auto()
7
+ DIFFERENT = auto()
@@ -11,6 +11,7 @@ from bluer_objects.storage.base import StorageInterface
11
11
  from bluer_objects.env import ABCLI_OBJECT_ROOT
12
12
  from bluer_objects import env, file, path
13
13
  from bluer_objects import objects
14
+ from bluer_objects.storage.policies import DownloadPolicy
14
15
  from bluer_objects.logger import logger
15
16
 
16
17
 
@@ -121,6 +122,7 @@ class S3Interface(StorageInterface):
121
122
  object_name: str,
122
123
  filename: str = "",
123
124
  log: bool = True,
125
+ policy: DownloadPolicy = DownloadPolicy.NONE,
124
126
  ) -> bool:
125
127
  if filename:
126
128
  local_path = objects.path_of(
@@ -129,6 +131,11 @@ class S3Interface(StorageInterface):
129
131
  create=True,
130
132
  )
131
133
 
134
+ if policy == DownloadPolicy.DOESNT_EXIST and file.exists(local_path):
135
+ if log:
136
+ logger.info(f"✅ {filename}")
137
+ return True
138
+
132
139
  if not path.create(file.path(local_path)):
133
140
  return False
134
141
 
@@ -160,6 +167,7 @@ class S3Interface(StorageInterface):
160
167
  object_name=object_name,
161
168
  filename=filename,
162
169
  log=log,
170
+ policy=policy,
163
171
  )
164
172
 
165
173
  success, list_of_files = self.ls(
@@ -174,6 +182,7 @@ class S3Interface(StorageInterface):
174
182
  object_name=object_name,
175
183
  filename=filename_,
176
184
  log=log,
185
+ policy=policy,
177
186
  ):
178
187
  return False
179
188
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bluer_objects
3
- Version: 6.229.1
3
+ Version: 6.233.1
4
4
  Summary: 🌀 Object management in Bash.
5
5
  Home-page: https://github.com/kamangir/bluer-objects
6
6
  Author: Arash Abadpour (Kamangir)
@@ -64,6 +64,6 @@ pip install bluer-objects
64
64
 
65
65
  [![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)
66
66
 
67
- built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.229.1`](https://github.com/kamangir/bluer-objects).
67
+ built by 🌀 [`bluer README`](https://github.com/kamangir/bluer-objects/tree/main/bluer_objects/README), based on 🌀 [`bluer_objects-6.233.1`](https://github.com/kamangir/bluer-objects).
68
68
 
69
69
  built by 🌀 [`blueness-3.118.1`](https://github.com/kamangir/blueness).
@@ -1,4 +1,4 @@
1
- bluer_objects/__init__.py,sha256=IV8Ks8EwwLj3e2-ApxqEZ4PqnIM7qmgQppN6xZDkCwk,315
1
+ bluer_objects/__init__.py,sha256=ypm6tg6ZIhdQ-Qbd_QXj6Ypv7QPpEcN8C9bCQb_DeOc,315
2
2
  bluer_objects/__main__.py,sha256=Yqfov833_hJuRne19WrGhT5DWAPtdffpoMxeSXS7EGw,359
3
3
  bluer_objects/config.env,sha256=RjcpnbKfRqNyGLRB4z7M_OG9z2pOM032ck__53JqXqo,216
4
4
  bluer_objects/env.py,sha256=iw4QvaImqnavlsHwfkUScNHc7afDEJQKJSsHTtVJE78,2019
@@ -14,7 +14,7 @@ bluer_objects/.abcli/alias.sh,sha256=nYrAqpaXkL3xOTc_MQdZGSXB4kuUxxAqeXZrI5-E3e8
14
14
  bluer_objects/.abcli/bluer_objects.sh,sha256=x7qf8hSAp3dAl0Hes4J07vL6qP-mWFUkJhvUXzTJC_8,210
15
15
  bluer_objects/.abcli/clone.sh,sha256=KqC5d4MAXwo7UZGhKnfCq9k9CCSl3I1dpU1igYs0Yrs,1975
16
16
  bluer_objects/.abcli/create_test_asset.sh,sha256=ONIdad_WRjZWdW6V2RalRW2qSJwybEwzU-_KsvaJ9og,245
17
- bluer_objects/.abcli/download.sh,sha256=77Bak3TATDrDNpBWM8bvbU1MdsuTCENyqdBJNx_Wsa0,564
17
+ bluer_objects/.abcli/download.sh,sha256=SKv4JyjcWjOutK95-gurCqbRjpmcrmzxASEEdT23Ob4,650
18
18
  bluer_objects/.abcli/file.sh,sha256=djcHSFS8fqlCsoDyZKmimNTzd-jOUnxbOFpL7xq_hGk,150
19
19
  bluer_objects/.abcli/gif.sh,sha256=sZZZWAvwR7bTf6gF70b0l_1tw4-HOswh93iwUAQilEI,803
20
20
  bluer_objects/.abcli/host.sh,sha256=N-Gdsk-mR2V2MvFlwlIVwaiGkQyV1DoM5UdhQrpUsls,573
@@ -65,7 +65,7 @@ bluer_objects/.abcli/tests/mlflow_logging.sh,sha256=TVzHhk9qRthpP2xdKwu3LwK00S77
65
65
  bluer_objects/.abcli/tests/mlflow_tags.sh,sha256=pX4sEK_z2Vrb7a6Bq4qWurFVPZkvjpS10K4MLx3mf64,811
66
66
  bluer_objects/.abcli/tests/mlflow_test.sh,sha256=7MXxYq2GgD2MEJbQlpx80qLT2HaaVn_PFFMpSA_hWA4,125
67
67
  bluer_objects/.abcli/tests/storage_public_upload.sh,sha256=qwyUSejxDlV5Q1f7jyOLej_ADZt50HwbuSImFcrMWf8,589
68
- bluer_objects/.abcli/tests/storage_upload_download.sh,sha256=l5EO0TwyHw7zVBrJV8xmJub8RburdAiyg80WEH3VjrQ,1476
68
+ bluer_objects/.abcli/tests/storage_upload_download.sh,sha256=GvFZgzRzN9zlAGLM7m-_uDlDyATAUo7KQcW2yXYFaKw,1604
69
69
  bluer_objects/.abcli/tests/version.sh,sha256=k-lXozSjyFgFR58cTzUYla0Ef-upx3sSK641zI5ynfE,169
70
70
  bluer_objects/.abcli/tests/web_is_accessible.sh,sha256=3R33_LQM9PIfl8Bks4HrPHp4ug8cGv9X6LaDscsznEs,405
71
71
  bluer_objects/.abcli/tests/web_where_am_ai.sh,sha256=BJ9G_m4id8cx_UB_l_jV2xY6AfQEpG7O4IBsuVjodxk,104
@@ -92,7 +92,7 @@ bluer_objects/help/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
92
92
  bluer_objects/help/__main__.py,sha256=Dxg-JpMOIlYWZklI_J2LyiHnRui5lUwWmfM7FLRzUXA,237
93
93
  bluer_objects/help/clone.py,sha256=PDnQs7zc4sqmoBHPjVRfX7jIaePiohPGCNA5bxeerik,553
94
94
  bluer_objects/help/create_test_asset.py,sha256=oxJORm2qk4b_q7EC6-dEuNu1_pK9Ri60PcHhrE8ruxM,375
95
- bluer_objects/help/download.py,sha256=1fw3ASOXUuXcNhm8y0AK7ZBmXzWwZvdo2hK9ZVbgteA,439
95
+ bluer_objects/help/download.py,sha256=9zC_IvH4p2vMXb_qcAS176CBFp5fJe4Z9DFMPdSGBac,751
96
96
  bluer_objects/help/functions.py,sha256=ghCXmHHMVgdPDkqPHWIK7L64wb--oLYhdfJdZyboZKM,1096
97
97
  bluer_objects/help/gif.py,sha256=gKV6vNT4bEC2Ch3QIb3Yc5DqzAH_UvAVCsuvzXeF1Sc,564
98
98
  bluer_objects/help/host.py,sha256=4t4yrPGjTbnFtODcuBjfIzpA5pmmvc5s4QrjIqPPVsM,988
@@ -127,13 +127,14 @@ bluer_objects/mlflow/testing.py,sha256=cJH5Ki02fJN_Xos1j9yvwQChXvMkOa9i12vtDKmkb
127
127
  bluer_objects/mlflow/lock/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
128
128
  bluer_objects/mlflow/lock/__main__.py,sha256=xF_xq2UqAsEohSOHjxaFXaw9KopOEDg6LRDM5a4VAPQ,1138
129
129
  bluer_objects/mlflow/lock/functions.py,sha256=MOslqblNAOsRvILzLF4q6m2EAwCk4f4zEWQpsy8lVnM,3045
130
- bluer_objects/storage/WebDAV.py,sha256=s0KI5JIfvYcRfrroxsZdEjfnxX_8CiPC-fQ3f0Lrkjw,3140
131
- bluer_objects/storage/WebDAVrequest.py,sha256=H9GIVPQPjP1j-URZrxJ15Jxnf8qPgQx-dShaxaeAj1U,10101
132
- bluer_objects/storage/WebDAVzip.py,sha256=vfjk-7HF5EpQ9ad-ZGfPR_qOK57RQzAPXlWc3tIsq8A,4090
133
- bluer_objects/storage/__init__.py,sha256=CFo0m1ftBGFKBdUAy4FAilJCpXwKvVdXCrBMkmeTW1E,1735
134
- bluer_objects/storage/__main__.py,sha256=6T4gltrJ-3lihce2fm43UeWB1y09VInXHrVBnAAa_R4,2005
135
- bluer_objects/storage/base.py,sha256=CPMBGi7koKnEBVLJOeIq9T05xxfKFRg-BHjyWidlCKw,2081
136
- bluer_objects/storage/s3.py,sha256=kSvm68POErGaqSWZ0ds8zB0Fd5q4WJUZ95kQZSp3n7w,9395
130
+ bluer_objects/storage/WebDAV.py,sha256=UftrpSDzJAtTeMEORNpOTbDhmRYAzgdTNbmrAkgzPTU,3279
131
+ bluer_objects/storage/WebDAVrequest.py,sha256=Wp4rtlWif7sdu4VohxenT8YVmf-tmV9gbBYxuKFDR8M,10279
132
+ bluer_objects/storage/WebDAVzip.py,sha256=EHbERaxnLUQqWSM12dwJYybvXCIqqo66uThvNBE8BHI,4212
133
+ bluer_objects/storage/__init__.py,sha256=LY3pxxflaZ0KUSJJzlh0GEFH-HpshBntn5qs62uk0WQ,1866
134
+ bluer_objects/storage/__main__.py,sha256=GlUQjonf1K0SFdivRntJEdFFRwtF4eP1WtmNEJe5LY4,2269
135
+ bluer_objects/storage/base.py,sha256=35G51iTsU99N_JQwUS2oatbACudAsiOrQ0E6fIz2cic,2396
136
+ bluer_objects/storage/policies.py,sha256=xIuIhFjcWH7ptg_jUgfYTNnXqs9xaX4yU5qSOhmmxhI,125
137
+ bluer_objects/storage/s3.py,sha256=30i9bqj5gGZQZ9YRAqcF5piThlFilsmYqI0eFXnJ3M8,9755
137
138
  bluer_objects/testing/__init__.py,sha256=DWY5ZtvCnHG_t9BDiqy_ArLOZi-nlyAtPVMLA1PPAMU,62
138
139
  bluer_objects/testing/__main__.py,sha256=hhJV9qn0V_8FxzNDcoHCHr4A7zf9UudnNGJCAPkTBGU,750
139
140
  bluer_objects/testing/functions.py,sha256=AXAfzWLcEPkbSYTehdahshjKJ45C4IJkRs_TgrHOntc,1355
@@ -170,8 +171,8 @@ bluer_objects/tests/test_web_is_accessible.py,sha256=2Y20NAEDMblg0MKnhnqcfw3XVKE
170
171
  bluer_objects/web/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
171
172
  bluer_objects/web/__main__.py,sha256=xf2Ob54FI8JEokfGhFmiyOBdD9nBactwqmZvsKsdioU,624
172
173
  bluer_objects/web/functions.py,sha256=KNufAFOc6N3BYf83lN2rUpKUdsnzb2anWyp9koFRVUo,172
173
- bluer_objects-6.229.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
174
- bluer_objects-6.229.1.dist-info/METADATA,sha256=p-4W42G1a6WTc-TG5rTe-qbqXBa7wv6mMKkFwD2DS5w,3678
175
- bluer_objects-6.229.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
176
- bluer_objects-6.229.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
177
- bluer_objects-6.229.1.dist-info/RECORD,,
174
+ bluer_objects-6.233.1.dist-info/licenses/LICENSE,sha256=ogEPNDSH0_dhiv_lT3ifVIdgIzHAqNA_SemnxUfPBJk,7048
175
+ bluer_objects-6.233.1.dist-info/METADATA,sha256=tsgJWXBuN_bvlxP08bMlvdtv31tDQgytbzzUhwjICW8,3678
176
+ bluer_objects-6.233.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
177
+ bluer_objects-6.233.1.dist-info/top_level.txt,sha256=RX2TpddbnRkurda3G_pAdyeTztP2IhhRPx949GlEvQo,14
178
+ bluer_objects-6.233.1.dist-info/RECORD,,