yta-programming-env 0.3.1__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yta-programming-env
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Youtube Autonomous Programming Dependencies Module
5
5
  License-File: LICENSE
6
6
  Author: danialcala94
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "yta-programming-env"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "Youtube Autonomous Programming Dependencies Module"
5
5
  authors = [
6
6
  {name = "danialcala94",email = "danielalcalavalera@gmail.com"}
@@ -54,7 +54,6 @@ class Environment:
54
54
  )
55
55
  )
56
56
 
57
-
58
57
  @staticmethod
59
58
  def get_current_project_env(
60
59
  variable: str,
@@ -72,3 +71,47 @@ class Environment:
72
71
  ParameterValidator.validate_mandatory_string('variable', variable, do_accept_empty = False)
73
72
 
74
73
  return Environment.get_current_project_env_dict(env_filename).get(variable, default_value)
74
+
75
+ @staticmethod
76
+ def get_env(
77
+ variable: str,
78
+ default_value: Union[str, bool, float, int, None] = None,
79
+ ) -> Union[str, bool, float, int, None]:
80
+ """
81
+ Get the `variable` from the `os` environment by doing
82
+ a `os.getenv(variable)`.
83
+ """
84
+ return os.getenv(variable, default_value)
85
+
86
+ @staticmethod
87
+ def set_env(
88
+ variable: str,
89
+ value: Union[str, bool, float, int]
90
+ ) -> Union[str, None]:
91
+ """
92
+ Set the value of the `variable` in the environment by
93
+ doing `os.environ[variable] = value`.
94
+
95
+ The environment variables are always strings.
96
+
97
+ This method will return the value the environment
98
+ variable had before setting the new one, if existing.
99
+ """
100
+ previous_value = os.getenv(variable, None)
101
+
102
+ os.environ[variable] = str(value)
103
+
104
+ return previous_value
105
+
106
+ @staticmethod
107
+ def remove_env(
108
+ variable: str
109
+ ) -> Union[str, bool, float, int, None]:
110
+ """
111
+ Unset the `variable` in the environment by doing
112
+ `os.environ.pop[variable]`.
113
+
114
+ This method will return the last value before
115
+ unsetting it, if existing.
116
+ """
117
+ return os.environ.pop(variable, None)