PyS3Uploader 0.3.0__py3-none-any.whl → 0.3.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 PyS3Uploader might be problematic. Click here for more details.
- pys3uploader/__init__.py +0 -2
- pys3uploader/uploader.py +18 -3
- pys3uploader/utils.py +31 -0
- pys3uploader/version.py +1 -0
- {pys3uploader-0.3.0.dist-info → pys3uploader-0.3.1.dist-info}/METADATA +1 -1
- pys3uploader-0.3.1.dist-info/RECORD +12 -0
- pys3uploader-0.3.0.dist-info/RECORD +0 -11
- {pys3uploader-0.3.0.dist-info → pys3uploader-0.3.1.dist-info}/LICENSE +0 -0
- {pys3uploader-0.3.0.dist-info → pys3uploader-0.3.1.dist-info}/WHEEL +0 -0
- {pys3uploader-0.3.0.dist-info → pys3uploader-0.3.1.dist-info}/top_level.txt +0 -0
pys3uploader/__init__.py
CHANGED
pys3uploader/uploader.py
CHANGED
|
@@ -18,6 +18,7 @@ from pys3uploader.utils import (
|
|
|
18
18
|
convert_seconds,
|
|
19
19
|
convert_to_folder_structure,
|
|
20
20
|
getenv,
|
|
21
|
+
size_converter,
|
|
21
22
|
urljoin,
|
|
22
23
|
)
|
|
23
24
|
|
|
@@ -196,13 +197,27 @@ class Uploader:
|
|
|
196
197
|
# Indicates that the object path already exists in S3
|
|
197
198
|
if object_size := self.object_size_map.get(objectpath):
|
|
198
199
|
if object_size == file_size:
|
|
199
|
-
self.logger.info(
|
|
200
|
+
self.logger.info(
|
|
201
|
+
"S3 object %s exists, and size [%d bytes / %s] matches, skipping..",
|
|
202
|
+
objectpath,
|
|
203
|
+
object_size,
|
|
204
|
+
size_converter(object_size),
|
|
205
|
+
)
|
|
200
206
|
return False
|
|
201
207
|
self.logger.info(
|
|
202
|
-
"S3 object %s exists, but size mismatch. Local: [%d], S3: [%d]",
|
|
208
|
+
"S3 object %s exists, but size mismatch. Local: [%d bytes / %s], S3: [%d bytes / %s]",
|
|
209
|
+
objectpath,
|
|
210
|
+
file_size,
|
|
211
|
+
object_size,
|
|
212
|
+
size_converter(object_size),
|
|
203
213
|
)
|
|
204
214
|
else:
|
|
205
|
-
self.logger.debug(
|
|
215
|
+
self.logger.debug(
|
|
216
|
+
"S3 object '%s' of size [%d bytes / %s] doesn't exist, uploading..",
|
|
217
|
+
objectpath,
|
|
218
|
+
file_size,
|
|
219
|
+
size_converter(file_size),
|
|
220
|
+
)
|
|
206
221
|
return True
|
|
207
222
|
|
|
208
223
|
def _uploader(self, filepath: str, objectpath: str) -> None:
|
pys3uploader/utils.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import math
|
|
1
2
|
import os
|
|
2
3
|
from typing import Dict, Set
|
|
3
4
|
|
|
@@ -145,3 +146,33 @@ def convert_seconds(seconds: int | float, n_elem: int = 2) -> str:
|
|
|
145
146
|
|
|
146
147
|
list_ = time_parts[:n_elem]
|
|
147
148
|
return ", and ".join([", ".join(list_[:-1]), list_[-1]] if len(list_) > 2 else list_)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def format_nos(input_: float) -> int | float:
|
|
152
|
+
"""Removes ``.0`` float values.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
input_: Strings or integers with ``.0`` at the end.
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
int | float:
|
|
159
|
+
Int if found, else returns the received float value.
|
|
160
|
+
"""
|
|
161
|
+
return int(input_) if isinstance(input_, float) and input_.is_integer() else input_
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def size_converter(byte_size: int | float) -> str:
|
|
165
|
+
"""Gets the current memory consumed and converts it to human friendly format.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
byte_size: Receives byte size as argument.
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
str:
|
|
172
|
+
Converted understandable size.
|
|
173
|
+
"""
|
|
174
|
+
if not byte_size:
|
|
175
|
+
return "0 B"
|
|
176
|
+
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
|
|
177
|
+
index = int(math.floor(math.log(byte_size, 1024)))
|
|
178
|
+
return f"{format_nos(round(byte_size / pow(1024, index), 2))} {size_name[index]}"
|
pys3uploader/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.3.1"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
pys3uploader/__init__.py,sha256=EqMScWbJNV4UWeMg4fMko2KB18xL2CO3a3o_od0H0Lc,124
|
|
2
|
+
pys3uploader/exceptions.py,sha256=hH3jlMOe8yjBatQK9EdndWZz4QESU74KSY_iDhQ37SY,2585
|
|
3
|
+
pys3uploader/logger.py,sha256=igwMubdTQ_GrMkwie5DAIvmxIcgj6a9UA_EGFrwFYiQ,2571
|
|
4
|
+
pys3uploader/tree.py,sha256=DiQ2ekMMaj2m_P3-iKkEqSuJCJZ_UZxcAwHtAoPVa5c,1824
|
|
5
|
+
pys3uploader/uploader.py,sha256=FW2Mg1yoMV6Qaq9F2n-EXnP1vqi3AGtWUuIWVMev65o,14644
|
|
6
|
+
pys3uploader/utils.py,sha256=T-TIUtzQ6sYEfZqwxH_t-Cfhw5wuzr_REQ-OBkdcg00,5357
|
|
7
|
+
pys3uploader/version.py,sha256=sEAhGxRzEBE5t0VjAcJ-336II62pGIQ0eLrs42I-sGU,18
|
|
8
|
+
pys3uploader-0.3.1.dist-info/LICENSE,sha256=8k-hEraOzyum0GvmmK65YxNRTFXK7eIFHJ0OshJXeTk,1068
|
|
9
|
+
pys3uploader-0.3.1.dist-info/METADATA,sha256=-moIOf7765V6qYgXcOpJtawcnlriAlUOQ2a-abgGt5o,8039
|
|
10
|
+
pys3uploader-0.3.1.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
11
|
+
pys3uploader-0.3.1.dist-info/top_level.txt,sha256=lVIFMMoUx7dj_myetBmOUQTJiOzz5VyDqchnQElmrWw,13
|
|
12
|
+
pys3uploader-0.3.1.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
pys3uploader/__init__.py,sha256=QszR24KVfcJXbrJI0oxZCIaMs5GOtwnIbtfrY2Zj7Nk,143
|
|
2
|
-
pys3uploader/exceptions.py,sha256=hH3jlMOe8yjBatQK9EdndWZz4QESU74KSY_iDhQ37SY,2585
|
|
3
|
-
pys3uploader/logger.py,sha256=igwMubdTQ_GrMkwie5DAIvmxIcgj6a9UA_EGFrwFYiQ,2571
|
|
4
|
-
pys3uploader/tree.py,sha256=DiQ2ekMMaj2m_P3-iKkEqSuJCJZ_UZxcAwHtAoPVa5c,1824
|
|
5
|
-
pys3uploader/uploader.py,sha256=-PRwu2RvzExjLTKbw9oQuFcyNI0Uxi1IsoJu6e6wayY,14258
|
|
6
|
-
pys3uploader/utils.py,sha256=NbF28CYviK_St5qd1EOumMVyus9BvQON7clUFeR_SEQ,4473
|
|
7
|
-
pys3uploader-0.3.0.dist-info/LICENSE,sha256=8k-hEraOzyum0GvmmK65YxNRTFXK7eIFHJ0OshJXeTk,1068
|
|
8
|
-
pys3uploader-0.3.0.dist-info/METADATA,sha256=0eS5eoAsatnmMi_wanq_kzHTZGVTvwo2c4pR_CIa3T4,8039
|
|
9
|
-
pys3uploader-0.3.0.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
|
10
|
-
pys3uploader-0.3.0.dist-info/top_level.txt,sha256=lVIFMMoUx7dj_myetBmOUQTJiOzz5VyDqchnQElmrWw,13
|
|
11
|
-
pys3uploader-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|