yta-programming-env 0.2.0__tar.gz → 0.3.1__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.
- {yta_programming_env-0.2.0 → yta_programming_env-0.3.1}/PKG-INFO +6 -5
- {yta_programming_env-0.2.0 → yta_programming_env-0.3.1}/pyproject.toml +9 -7
- yta_programming_env-0.3.1/src/yta_programming_env/__init__.py +74 -0
- yta_programming_env-0.2.0/src/yta_programming_env/__init__.py +0 -49
- {yta_programming_env-0.2.0 → yta_programming_env-0.3.1}/LICENSE +0 -0
- {yta_programming_env-0.2.0 → yta_programming_env-0.3.1}/README.md +0 -0
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: yta-programming-env
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: Youtube Autonomous Programming Dependencies Module
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Author: danialcala94
|
|
7
7
|
Author-email: danielalcalavalera@gmail.com
|
|
8
|
-
Requires-Python: >=3.
|
|
8
|
+
Requires-Python: >=3.8,<3.14
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
10
11
|
Classifier: Programming Language :: Python :: 3.9
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
-
Requires-Dist: python-dotenv (>=1.0.
|
|
16
|
-
Requires-Dist: yta_programming_path (>=0.0
|
|
17
|
-
Requires-Dist: yta_validation (>=0.
|
|
16
|
+
Requires-Dist: python-dotenv (>=1.0.1,<9999.0.0)
|
|
17
|
+
Requires-Dist: yta_programming_path (>=0.3.0,<1.0.0)
|
|
18
|
+
Requires-Dist: yta_validation (>=0.2.1,<1.0.0)
|
|
18
19
|
Description-Content-Type: text/markdown
|
|
19
20
|
|
|
20
21
|
# Youtube Autonomous Programming Environment add-on
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "yta-programming-env"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.3.1"
|
|
4
4
|
description = "Youtube Autonomous Programming Dependencies Module"
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "danialcala94",email = "danielalcalavalera@gmail.com"}
|
|
7
7
|
]
|
|
8
8
|
readme = "README.md"
|
|
9
|
-
requires-python = ">=3.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
requires-python = ">=3.8,<3.14"
|
|
10
|
+
|
|
11
|
+
[tool.poetry.dependencies]
|
|
12
|
+
# Mandatory
|
|
13
|
+
yta_validation = { version = ">=0.2.1,<1.0.0", optional = false }
|
|
14
|
+
yta_programming_path = { version = ">=0.3.0,<1.0.0", optional = false }
|
|
15
|
+
python-dotenv = { version = ">=1.0.1,<9999.0.0", optional = false }
|
|
16
|
+
# Optional
|
|
15
17
|
|
|
16
18
|
[tool.poetry]
|
|
17
19
|
packages = [{include = "yta_programming_env", from = "src"}]
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from yta_programming_path import DevPathHandler
|
|
2
|
+
from yta_validation.parameter import ParameterValidator
|
|
3
|
+
from dotenv import load_dotenv, dotenv_values
|
|
4
|
+
from typing import Union
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Environment:
|
|
10
|
+
"""
|
|
11
|
+
Class to handle the environment of the project in
|
|
12
|
+
which you are executing this code perfectly.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
@staticmethod
|
|
16
|
+
def load_current_project_dotenv(
|
|
17
|
+
env_filename: str = '.env',
|
|
18
|
+
do_override: bool = True
|
|
19
|
+
):
|
|
20
|
+
"""
|
|
21
|
+
Load the `env_filename` (by default '.env')
|
|
22
|
+
environment configuration file from the current
|
|
23
|
+
project. The current project is the one in which
|
|
24
|
+
the code is being executed, not the library in which
|
|
25
|
+
it is written.
|
|
26
|
+
|
|
27
|
+
The `env_filename` will be read and the variables on
|
|
28
|
+
it will be loaded and ready to be accessed.
|
|
29
|
+
|
|
30
|
+
If the `do_override` is `True`, the previously
|
|
31
|
+
existing configuration variables will be overriden by
|
|
32
|
+
the new values.
|
|
33
|
+
"""
|
|
34
|
+
load_dotenv(
|
|
35
|
+
dotenv_path = os.path.join(DevPathHandler.get_project_abspath(), env_filename),
|
|
36
|
+
override = do_override
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def get_current_project_env_dict(
|
|
41
|
+
env_filename: str = '.env'
|
|
42
|
+
) -> dict:
|
|
43
|
+
"""
|
|
44
|
+
Get the variables of the `env_filename` environment
|
|
45
|
+
configuration file as a dict.
|
|
46
|
+
|
|
47
|
+
This method doesn't load the variables in memory, it
|
|
48
|
+
just read the values from the file.
|
|
49
|
+
"""
|
|
50
|
+
return dotenv_values(
|
|
51
|
+
dotenv_path = os.path.join(
|
|
52
|
+
DevPathHandler.get_project_abspath(),
|
|
53
|
+
env_filename
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@staticmethod
|
|
59
|
+
def get_current_project_env(
|
|
60
|
+
variable: str,
|
|
61
|
+
default_value: Union[str, bool, float, int, None] = None,
|
|
62
|
+
env_filename: str = '.env'
|
|
63
|
+
):
|
|
64
|
+
"""
|
|
65
|
+
Load the `env_filename` environment configuration file
|
|
66
|
+
and get the value of the `variable`, if existing.
|
|
67
|
+
|
|
68
|
+
This method will do a `load_dotenv` call, which will
|
|
69
|
+
try to load the `env_filename` in memory and then use
|
|
70
|
+
the `os.getenv` method.
|
|
71
|
+
"""
|
|
72
|
+
ParameterValidator.validate_mandatory_string('variable', variable, do_accept_empty = False)
|
|
73
|
+
|
|
74
|
+
return Environment.get_current_project_env_dict(env_filename).get(variable, default_value)
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
from yta_programming_path import DevPathHandler
|
|
2
|
-
from yta_validation.parameter import ParameterValidator
|
|
3
|
-
from dotenv import load_dotenv
|
|
4
|
-
from typing import Union
|
|
5
|
-
|
|
6
|
-
import os
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Environment:
|
|
10
|
-
"""
|
|
11
|
-
Class to handle the environment of the project in
|
|
12
|
-
which you are executing this code perfectly.
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
@staticmethod
|
|
16
|
-
def load_current_project_dotenv(
|
|
17
|
-
):
|
|
18
|
-
"""
|
|
19
|
-
Load the current project environment '.env' configuration
|
|
20
|
-
file. The current project is the one in which the code
|
|
21
|
-
is being executed (the code in which you call this method,
|
|
22
|
-
not the library in which it is written).
|
|
23
|
-
|
|
24
|
-
Any project in which you are importing this library, the
|
|
25
|
-
'.env' file on its main folder will be loaded.
|
|
26
|
-
"""
|
|
27
|
-
load_dotenv(os.path.join(DevPathHandler.get_project_abspath(), '.env'))
|
|
28
|
-
|
|
29
|
-
@staticmethod
|
|
30
|
-
def get_current_project_env(
|
|
31
|
-
variable: str,
|
|
32
|
-
default_value: Union[str, bool, float, int, None] = None
|
|
33
|
-
):
|
|
34
|
-
"""
|
|
35
|
-
Load the current project environment '.env' configuration
|
|
36
|
-
file and get the value of the 'variable' if existing.
|
|
37
|
-
|
|
38
|
-
This method makes a 'load_dotenv' call within the current
|
|
39
|
-
project absolute path any time you call it, so it ensures
|
|
40
|
-
the value is correctly loaded if available.
|
|
41
|
-
|
|
42
|
-
You don't need to do 'load_dotenv()' to call this method,
|
|
43
|
-
it will do for you =).
|
|
44
|
-
"""
|
|
45
|
-
ParameterValidator.validate_mandatory_string('variable', variable, do_accept_empty = False)
|
|
46
|
-
|
|
47
|
-
Environment.load_current_project_dotenv()
|
|
48
|
-
|
|
49
|
-
return os.getenv(variable, default_value)
|
|
File without changes
|
|
File without changes
|