PyS3Uploader 0.2.0__py3-none-any.whl → 0.4.0a1__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.

s3/utils.py DELETED
@@ -1,70 +0,0 @@
1
- import os
2
- from typing import Dict, Set
3
-
4
-
5
- class UploadResults(dict):
6
- """Object to store results of S3 upload.
7
-
8
- >>> UploadResults
9
-
10
- """
11
-
12
- success: int = 0
13
- failed: int = 0
14
-
15
-
16
- def getenv(*args, default: str = None) -> str:
17
- """Returns the key-ed environment variable or the default value."""
18
- for key in args:
19
- if value := os.environ.get(key.upper()) or os.environ.get(key.lower()):
20
- return value
21
- return default
22
-
23
-
24
- def urljoin(*args) -> str:
25
- """Joins given arguments into a url. Trailing but not leading slashes are stripped for each argument.
26
-
27
- Returns:
28
- str:
29
- Joined url.
30
- """
31
- return "/".join(map(lambda x: str(x).rstrip("/").lstrip("/"), args))
32
-
33
-
34
- def convert_to_folder_structure(sequence: Set[str]) -> str:
35
- """Convert objects in a s3 buckets into a folder like representation.
36
-
37
- Args:
38
- sequence: Takes either a mutable or immutable sequence as an argument.
39
-
40
- Returns:
41
- str:
42
- String representation of the architecture.
43
- """
44
- folder_structure = {}
45
- for item in sequence:
46
- parts = item.split("/")
47
- current_level = folder_structure
48
- for part in parts:
49
- current_level = current_level.setdefault(part, {})
50
-
51
- def generate_folder_structure(structure: Dict[str, dict], indent: str = "") -> str:
52
- """Generates the folder like structure.
53
-
54
- Args:
55
- structure: Structure of folder objects as key-value pairs.
56
- indent: Required indentation for the ASCII.
57
- """
58
- result = ""
59
- for i, (key, value) in enumerate(structure.items()):
60
- if i == len(structure) - 1:
61
- result += indent + "└── " + key + "\n"
62
- sub_indent = indent + " "
63
- else:
64
- result += indent + "├── " + key + "\n"
65
- sub_indent = indent + "│ "
66
- if value:
67
- result += generate_folder_structure(value, sub_indent)
68
- return result
69
-
70
- return generate_folder_structure(folder_structure)
File without changes
File without changes