pypomes-core 0.1.0__tar.gz
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.
- pypomes_core-0.1.0/.gitignore +10 -0
- pypomes_core-0.1.0/LICENSE +21 -0
- pypomes_core-0.1.0/PKG-INFO +17 -0
- pypomes_core-0.1.0/README.md +0 -0
- pypomes_core-0.1.0/pyproject.toml +31 -0
- pypomes_core-0.1.0/src/pypomes-core/__init__.py +71 -0
- pypomes_core-0.1.0/src/pypomes-core/datetime_pomes.py +62 -0
- pypomes_core-0.1.0/src/pypomes-core/dict_pomes.py +705 -0
- pypomes_core-0.1.0/src/pypomes-core/email_pomes.py +36 -0
- pypomes_core-0.1.0/src/pypomes-core/encoding_pomes.py +99 -0
- pypomes_core-0.1.0/src/pypomes-core/env_pomes.py +72 -0
- pypomes_core-0.1.0/src/pypomes-core/exception_pomes.py +31 -0
- pypomes_core-0.1.0/src/pypomes-core/file_pomes.py +24 -0
- pypomes_core-0.1.0/src/pypomes-core/json_pomes.py +48 -0
- pypomes_core-0.1.0/src/pypomes-core/list_pomes.py +167 -0
- pypomes_core-0.1.0/src/pypomes-core/str_pomes.py +68 -0
- pypomes_core-0.1.0/src/pypomes-core/xml_pomes.py +72 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 GT Nunes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pypomes-core
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A collection of Python pomes, pennyeach (core modules)
|
|
5
|
+
Project-URL: Homepage, https://github.com/TheWiseCoder/PyPomes-Core
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/TheWiseCoder/PyPomes-Core/issues
|
|
7
|
+
Author-email: GT Nunes <wisecoder01@gmail.com>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: flask>=2.3.2
|
|
14
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
15
|
+
Requires-Dist: setuptools>=68.0.0
|
|
16
|
+
Requires-Dist: wheel>=0.40.0
|
|
17
|
+
Requires-Dist: xmltodict3>=0.0.4
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"hatchling"
|
|
4
|
+
]
|
|
5
|
+
build-backend = "hatchling.build"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "pypomes-core"
|
|
9
|
+
version = "0.1.0"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name="GT Nunes", email="wisecoder01@gmail.com" },
|
|
12
|
+
]
|
|
13
|
+
description = "A collection of Python pomes, pennyeach (core modules)"
|
|
14
|
+
readme = "README.md"
|
|
15
|
+
requires-python = ">=3.10"
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"Flask>=2.3.2",
|
|
23
|
+
"python-dateutil>=2.8.2",
|
|
24
|
+
"setuptools>=68.0.0",
|
|
25
|
+
"wheel>=0.40.0",
|
|
26
|
+
"xmltodict3>=0.0.4"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Homepage" = "https://github.com/TheWiseCoder/PyPomes-Core"
|
|
31
|
+
"Bug Tracker" = "https://github.com/TheWiseCoder/PyPomes-Core/issues"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from .datetime_pomes import (
|
|
2
|
+
DATE_FORMAT_STD, DATE_FORMAT_COMPACT, DATE_FORMAT_INV,
|
|
3
|
+
DATETIME_FORMAT_STD, DATETIME_FORMAT_COMPACT, DATETIME_FORMAT_INV,
|
|
4
|
+
date_reformat, date_parse, datetime_parse
|
|
5
|
+
)
|
|
6
|
+
from .dict_pomes import (
|
|
7
|
+
dict_has_key_chain, dict_get_value, dict_set_value, dict_reduce,
|
|
8
|
+
dict_listify, dict_transform, dict_merge, dict_coalesce, dict_get_key,
|
|
9
|
+
dict_get_keys, dict_from_object, dict_from_form, dict_from_list, dict_replace_value, dict_pop_value
|
|
10
|
+
)
|
|
11
|
+
from .email_pomes import (
|
|
12
|
+
EMAIL_ACCOUNT, EMAIL_PWD, EMAIL_PORT, EMAIL_SERVER, email_send,
|
|
13
|
+
)
|
|
14
|
+
from .encoding_pomes import (
|
|
15
|
+
encode_ascii_hex, decode_ascii_hex
|
|
16
|
+
)
|
|
17
|
+
from .env_pomes import (
|
|
18
|
+
APP_PREFIX, env_get_str, env_get_int, env_get_bool, env_get_float
|
|
19
|
+
)
|
|
20
|
+
from .exception_pomes import (
|
|
21
|
+
exc_format
|
|
22
|
+
)
|
|
23
|
+
from .file_pomes import (
|
|
24
|
+
file_from_request
|
|
25
|
+
)
|
|
26
|
+
from .json_pomes import (
|
|
27
|
+
jsonify_dict, jsonify_iterable
|
|
28
|
+
)
|
|
29
|
+
from .list_pomes import (
|
|
30
|
+
list_compare, list_flatten, list_unflatten,
|
|
31
|
+
list_find_coupled, list_elem_starting_with, list_transform,
|
|
32
|
+
)
|
|
33
|
+
from .str_pomes import (
|
|
34
|
+
str_between, str_split_on_mark, str_find_whitespace
|
|
35
|
+
)
|
|
36
|
+
from .xml_pomes import (
|
|
37
|
+
xml_to_dict, xml_normalize_keys
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
# datetime_pomes
|
|
42
|
+
DATE_FORMAT_STD, DATE_FORMAT_COMPACT, DATE_FORMAT_INV,
|
|
43
|
+
DATETIME_FORMAT_STD, DATETIME_FORMAT_COMPACT, DATETIME_FORMAT_INV,
|
|
44
|
+
date_reformat, date_parse, datetime_parse,
|
|
45
|
+
# dict_pomes
|
|
46
|
+
dict_has_key_chain, dict_get_value, dict_set_value, dict_reduce,
|
|
47
|
+
dict_listify, dict_transform, dict_merge, dict_coalesce, dict_get_key,
|
|
48
|
+
dict_get_keys, dict_from_object, dict_from_form, dict_from_list, dict_replace_value, dict_pop_value,
|
|
49
|
+
# email_pomes
|
|
50
|
+
EMAIL_ACCOUNT, EMAIL_PWD, EMAIL_PORT, EMAIL_SERVER, email_send,
|
|
51
|
+
# encoding_pomes
|
|
52
|
+
encode_ascii_hex, decode_ascii_hex,
|
|
53
|
+
# env_pomes
|
|
54
|
+
APP_PREFIX, env_get_str, env_get_int, env_get_bool, env_get_float,
|
|
55
|
+
# exception_pomes
|
|
56
|
+
exc_format,
|
|
57
|
+
# file_pomes
|
|
58
|
+
file_from_request,
|
|
59
|
+
# json_pomes
|
|
60
|
+
jsonify_dict, jsonify_iterable,
|
|
61
|
+
# list_pomes
|
|
62
|
+
list_compare, list_flatten, list_unflatten,
|
|
63
|
+
list_find_coupled, list_elem_starting_with, list_transform,
|
|
64
|
+
# str_pomes
|
|
65
|
+
str_between, str_split_on_mark, str_find_whitespace,
|
|
66
|
+
# xml_pomes
|
|
67
|
+
xml_to_dict, xml_normalize_keys
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
__version__ = "0.1.0"
|
|
71
|
+
__version_info__ = (0, 1, 0)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from datetime import date, datetime
|
|
2
|
+
from dateutil import parser
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
# some useful date/datetime formats
|
|
6
|
+
DATE_FORMAT_STD: Final[str] = "%m/%d/%Y"
|
|
7
|
+
DATE_FORMAT_COMPACT: Final[str] = "%Y%m%d"
|
|
8
|
+
DATE_FORMAT_INV: Final[str] = "%Y-%m-%d"
|
|
9
|
+
DATETIME_FORMAT_STD: Final[str] = "%m/%d/%Y %H:%M:%S"
|
|
10
|
+
DATETIME_FORMAT_COMPACT: Final[str] = "%Y%m%d%H%M%S"
|
|
11
|
+
DATETIME_FORMAT_INV: Final[str] = "%Y-%m-%d %H:%M:%S"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def date_reformat(dt_str: str, to_format: str, **kwargs: any) -> str:
|
|
15
|
+
"""
|
|
16
|
+
Convert the date in *dt_str* to the format especified in *to_format*.
|
|
17
|
+
The argument *dt_str* must represent a valid date, with or without time-of-day information.
|
|
18
|
+
The argument *to_format* must be a valid format for *date* ou *datetime*.
|
|
19
|
+
|
|
20
|
+
:param dt_str: The date to convert.
|
|
21
|
+
:param to_format: The format for the conversion.
|
|
22
|
+
:param kwargs: Optional arguments for the parser in python-dateutil ('dayfirst' is a common argument).
|
|
23
|
+
:return: The converted date.
|
|
24
|
+
"""
|
|
25
|
+
result: str | None = None
|
|
26
|
+
ts: datetime = parser.parse(dt_str, **kwargs)
|
|
27
|
+
if ts is not None:
|
|
28
|
+
result = datetime.strftime(ts, to_format)
|
|
29
|
+
|
|
30
|
+
return result
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def date_parse(dt_str: str, **kwargs: any) -> date:
|
|
34
|
+
"""
|
|
35
|
+
Obtain and return the *date* object corresponding to *dt_str*.
|
|
36
|
+
Return *None* se *dt_str* does not contain a valid date.
|
|
37
|
+
|
|
38
|
+
:param dt_str: The date, in a supported format.
|
|
39
|
+
:param kwargs: Optional arguments for the parser in python-dateutil ('dayfirst' is a common argument).
|
|
40
|
+
:return: The corresponding date object, or None.
|
|
41
|
+
"""
|
|
42
|
+
result: date | None = None
|
|
43
|
+
if dt_str is not None:
|
|
44
|
+
result = parser.parse(dt_str, **kwargs).date()
|
|
45
|
+
|
|
46
|
+
return result
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def datetime_parse(dt_str: str, **kwargs: any) -> datetime:
|
|
50
|
+
"""
|
|
51
|
+
Obtain and return the *datetime* object corresponding to *dt_str*.
|
|
52
|
+
Return *None* se *dt_str* does not contain a valid date.
|
|
53
|
+
|
|
54
|
+
:param dt_str: The date, in a supported format.
|
|
55
|
+
:param kwargs: Optional arguments for the parser in python-dateutil ('dayfirst' is a common argument).
|
|
56
|
+
:return: The corresponding datetime object, or None.
|
|
57
|
+
"""
|
|
58
|
+
result: datetime | None = None
|
|
59
|
+
if dt_str is not None:
|
|
60
|
+
result = parser.parse(dt_str, **kwargs)
|
|
61
|
+
|
|
62
|
+
return result
|