Initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
class EnvironmentService:
|
||||
def __init__(self):
|
||||
self.LINE_COMMENTED = '#'
|
||||
self.VALUE_SEPARATOR = '='
|
||||
|
||||
def LoadEnvFile(self, filepath:str):
|
||||
with open(filepath, 'r') as file:
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if line and not line.startswith(self.LINE_COMMENTED) and self.VALUE_SEPARATOR in line:
|
||||
key,value = line.split(self.VALUE_SEPARATOR, 1)
|
||||
self.Set(key, value) # os.environ[key] = value
|
||||
|
||||
def Get(self, key:str):
|
||||
return os.getenv(key)
|
||||
|
||||
def Set(self, key: str, value):
|
||||
os.environ[key] = value
|
||||
Reference in New Issue
Block a user