[DEV] change the configuration file
This commit is contained in:
@@ -30,8 +30,9 @@ class Config():
|
||||
self.load()
|
||||
|
||||
|
||||
def load(self):
|
||||
config_property = tools.file_read_data(env.get_island_path_config())
|
||||
# set it deprecated at 2020/07
|
||||
def load_old(self):
|
||||
config_property = tools.file_read_data(env.get_island_path_config_old())
|
||||
element_config = config_property.split("\n")
|
||||
for line in element_config:
|
||||
if len(line) == 0 \
|
||||
@@ -48,9 +49,39 @@ class Config():
|
||||
debug.warning("island config error: can not parse: '" + str(line) + "'")
|
||||
return True
|
||||
|
||||
def convert_config_file(self):
|
||||
debug.warning("INTERNAL: Convert your configuration file: " + str(env.get_island_path_config_old()) + " -> " + str(env.get_island_path_config()))
|
||||
self.load_old()
|
||||
self.store()
|
||||
tools.remove_file(env.get_island_path_config_old())
|
||||
|
||||
def load(self):
|
||||
# transform the old format of configuration (use json now ==> simple
|
||||
if os.path.exists(env.get_island_path_config_old()) == True:
|
||||
self.convert_config_file()
|
||||
if os.path.exists(env.get_island_path_config()) == False:
|
||||
return True
|
||||
self._volatiles = []
|
||||
with open(env.get_island_path_config()) as json_file:
|
||||
data = json.load(json_file)
|
||||
if "repo" in data.keys():
|
||||
self._repo = data["repo"]
|
||||
if "branch" in data.keys():
|
||||
self._branch = data["branch"]
|
||||
if "manifest_name" in data.keys():
|
||||
self._manifest_name = data["manifest_name"]
|
||||
return True
|
||||
return False
|
||||
|
||||
def store(self):
|
||||
data = "repo=" + self._repo + "\nbranch=" + self._branch + "\nfile=" + self._manifest_name
|
||||
tools.file_write_data(env.get_island_path_config(), data)
|
||||
data = {}
|
||||
data["repo"] = self._repo
|
||||
data["branch"] = self._branch
|
||||
data["manifest_name"] = self._manifest_name
|
||||
with open(env.get_island_path_config(), 'w') as outfile:
|
||||
json.dump(data, outfile, indent=4)
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_manifest(self, value):
|
||||
self._repo = value
|
||||
|
Reference in New Issue
Block a user