Env manipulation¶
env manipulator
Better live env manipulation than standard python library.
Classes:
Name | Description |
---|---|
ENVManipulator |
placeholder |
ENVManipulator
¶
Source code in app/dcsp/app/functions/env_manipulation.py
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 64 65 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 91 92 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 120 121 122 123 124 125 126 127 128 |
|
__init__(env_path=c.ENV_PATH_PLACEHOLDERS)
¶
Initialise the env path
Initialise the env path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env_path
|
str
|
location of the env file. Sets to c.ENV_PATH_PLACEHOLDERS if not sets. |
ENV_PATH_PLACEHOLDERS
|
Source code in app/dcsp/app/functions/env_manipulation.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
add(variable, value)
¶
Add or change a variable in the env file
Add or change a variable in the env file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable
|
str
|
name of variable. |
required |
value
|
str
|
value to set. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in app/dcsp/app/functions/env_manipulation.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
delete(variable_to_delete)
¶
Remove a variable from the env file
Removes the variable from the env file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variable_to_delete
|
str
|
as name. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if was present and deleted, False if was never present. |
Source code in app/dcsp/app/functions/env_manipulation.py
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 64 |
|
delete_all()
¶
Remove all variables from env file
Removes all the variables from the env file, keeping the file itself however.
Source code in app/dcsp/app/functions/env_manipulation.py
66 67 68 69 70 71 72 73 |
|
read(key_to_read)
¶
Reads a variable from env file
Reads a variable from an env file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_to_read
|
str
|
the variable to read. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
value of the variable. This will return empty string ("") if the variable has not been set. |
Source code in app/dcsp/app/functions/env_manipulation.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
read_all()
¶
Reads all variables from env file
Reads all variable from an env file and returns with keys in alphabetical order.
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str, str]: returns all variables in the env file. This will return empty string ("") if the variable has not been set. |
Source code in app/dcsp/app/functions/env_manipulation.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|