53 lines
1.2 KiB
Python
53 lines
1.2 KiB
Python
import os
|
|
import os.path
|
|
import json
|
|
import yaml
|
|
from os import path
|
|
from typing import List
|
|
from Project import Project
|
|
|
|
class Context:
|
|
__instance = None
|
|
|
|
__projectList=[]
|
|
__envorinments={}
|
|
|
|
|
|
def envExists(self, env):
|
|
if env in self.__environments:
|
|
return True
|
|
else:
|
|
return False
|
|
|
|
def getAllEnvironments(self):
|
|
return self.__environments
|
|
|
|
def getEnvironment(self, env):
|
|
if self.envExists(env):
|
|
return self.__environments[env]
|
|
else:
|
|
raise ValueError('Environment not found: '+ env)
|
|
|
|
def __buildEnvorinment(self, environmentReader):
|
|
self.__environments = environmentReader.read()
|
|
|
|
def build(self, restFactory, environmentReader):
|
|
# self.__buildProjectList(projects_root_path, restFactory)
|
|
self.restFactory=restFactory
|
|
self.__buildEnvorinment(environmentReader)
|
|
|
|
|
|
|
|
@staticmethod
|
|
def getInstance():
|
|
""" Static access method. """
|
|
if Context.__instance == None:
|
|
Context()
|
|
return Context.__instance
|
|
|
|
def __init__(self):
|
|
""" Virtually private constructor. """
|
|
if Context.__instance != None:
|
|
raise Exception("This class is a singleton!")
|
|
else:
|
|
Context.__instance = self |