Keys¶
S3Key
¶
Base class for s3 keys.
Source code in saritasa_s3_tools/keys.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
__call__(filename)
abstractmethod
¶
Abstract method for calling keys.
Source code in saritasa_s3_tools/keys.py
13 14 15 | |
clean_filename(filename)
¶
Remove garbage characters that cause problems with file names.
Source code in saritasa_s3_tools/keys.py
34 35 36 37 38 39 | |
get_random_filename(filename)
¶
Get random filename.
Generation random filename that contains unique identifier and
filename extension like: photo.jpg.
filename (str): Name of file.
new_filename (str): ``9841422d-c041-45a5-b7b3-467179f4f127.ext``.
Source code in saritasa_s3_tools/keys.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
normalize_string_value(value)
¶
Normalize string value.
- Remove leading and trailing whitespaces.
- Replace all space characters with the Space char.
- Normalize Unicode string using
NFKCform. See the details: https://docs.python.org/3/library/unicodedata.html#unicodedata.normalize
Source code in saritasa_s3_tools/keys.py
22 23 24 25 26 27 28 29 30 31 32 | |
remove_special_characters(filename)
¶
Remove characters from filename that are not allowed in some OS.
Source code in saritasa_s3_tools/keys.py
17 18 19 20 | |
validate(key)
¶
Check that input key is matching Key pattern.
Source code in saritasa_s3_tools/keys.py
61 62 63 | |
WithPrefixUUIDFileName
¶
Bases: S3Key
Generate S3 key with prefix folder and uuid filename.
Example:¶
prefix/{UUID.extension}
Source code in saritasa_s3_tools/keys.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__call__(filename)
¶
Return prefixed S3 key.
Source code in saritasa_s3_tools/keys.py
78 79 80 81 82 | |
validate(key)
¶
Check that input key is matching Key pattern.
Source code in saritasa_s3_tools/keys.py
84 85 86 87 88 89 90 | |
WithPrefixUUIDFolder
¶
Bases: S3Key
Generate S3 key with prefix folder and uuid folder.
Example:¶
prefix/{UUID}/filename
Source code in saritasa_s3_tools/keys.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
__call__(filename)
¶
Create key for destination using filename.
Source code in saritasa_s3_tools/keys.py
105 106 107 108 109 | |
validate(key)
¶
Check that input key is matching Key pattern.
Source code in saritasa_s3_tools/keys.py
111 112 113 114 115 116 117 118 119 | |