Commit afc58c0b authored by Tristan Gingold's avatar Tristan Gingold

module: refactor to reduce code size.

parent 09a1ab5b
...@@ -87,10 +87,8 @@ class ActionCore(Action): ...@@ -87,10 +87,8 @@ class ActionCore(Action):
if result is False: if result is False:
raise Exception("Unable to fetch module %s", str(module.url)) raise Exception("Unable to fetch module %s", str(module.url))
module.parse_manifest() module.parse_manifest()
new_modules.extend(module.local) for m in module.modules:
new_modules.extend(module.svn) new_modules.extend(module.modules[m])
new_modules.extend(module.git)
new_modules.extend(module.gitsm)
return new_modules return new_modules
fetch_queue = [m for m in self] fetch_queue = [m for m in self]
......
...@@ -36,10 +36,7 @@ class ModuleContent(ModuleCore): ...@@ -36,10 +36,7 @@ class ModuleContent(ModuleCore):
# Manifest Files Properties # Manifest Files Properties
self.files = None self.files = None
# Manifest Modules Properties # Manifest Modules Properties
self.local = [] self.modules = {'local': [], 'git': [], 'gitsm': [], 'svn': []}
self.git = []
self.gitsm = []
self.svn = []
self.incl_makefiles = [] self.incl_makefiles = []
super(ModuleContent, self).__init__() super(ModuleContent, self).__init__()
...@@ -83,61 +80,21 @@ class ModuleContent(ModuleCore): ...@@ -83,61 +80,21 @@ class ModuleContent(ModuleCore):
if "modules" not in self.manifest_dict: if "modules" not in self.manifest_dict:
return return
fetchto = self._get_fetchto() fetchto = self._get_fetchto()
if "local" in self.manifest_dict["modules"]: for m in self.modules:
local_paths = path_mod.flatten_list( if m not in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["local"]) continue
local_mods = [] paths = path_mod.flatten_list(self.manifest_dict["modules"][m])
for path in local_paths: self.manifest_dict["modules"][m] = paths
if path_mod.is_abs_path(path): mods = []
raise Exception("Found an absolute path (" + path + for path in paths:
") in a manifest(" + self.path + ")") if m == 'local':
path = path_mod.rel2abs(path, self.path) if path_mod.is_abs_path(path):
local_mods.append(self.pool.new_module(parent=self, raise Exception("Found an absolute path (" + path +
url=path, ") in a manifest(" + self.path + ")")
source='local', path = path_mod.rel2abs(path, self.path)
fetchto=fetchto)) mods.append(self.pool.new_module(
self.local = local_mods parent=self, url=path, source=m, fetchto=fetchto))
else: self.modules[m] = mods
self.local = []
if "svn" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["svn"] = path_mod.flatten_list(
self.manifest_dict["modules"]["svn"])
svn_mods = []
for url in self.manifest_dict["modules"]["svn"]:
svn_mods.append(self.pool.new_module(parent=self,
url=url,
source='svn',
fetchto=fetchto))
self.svn = svn_mods
else:
self.svn = []
if "git" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["git"] = path_mod.flatten_list(
self.manifest_dict["modules"]["git"])
git_mods = []
for url in self.manifest_dict["modules"]["git"]:
git_mods.append(self.pool.new_module(parent=self,
url=url,
source='git',
fetchto=fetchto))
self.git = git_mods
else:
self.git = []
if "gitsm" in self.manifest_dict["modules"]:
self.manifest_dict["modules"]["gitsm"] = path_mod.flatten_list(
self.manifest_dict["modules"]["gitsm"])
gitsm_mods = []
for url in self.manifest_dict["modules"]["gitsm"]:
gitsm_mods.append(self.pool.new_module(parent=self,
url=url,
source='gitsm',
fetchto=fetchto))
self.gitsm = gitsm_mods
else:
self.gitsm = []
def process_git_submodules(self): def process_git_submodules(self):
"""Get the submodules if found in the Manifest path""" """Get the submodules if found in the Manifest path"""
...@@ -150,10 +107,10 @@ class ModuleContent(ModuleCore): ...@@ -150,10 +107,10 @@ class ModuleContent(ModuleCore):
path = git_submodule_dict[submodule_key]["path"] path = git_submodule_dict[submodule_key]["path"]
path = os.path.join(git_toplevel, path) path = os.path.join(git_toplevel, path)
fetchto = os.path.sep.join(path.split(os.path.sep)[:-1]) fetchto = os.path.sep.join(path.split(os.path.sep)[:-1])
self.git.append(self.pool.new_module(parent=self, self.modules['git'].append(self.pool.new_module(parent=self,
url=url, url=url,
fetchto=fetchto, fetchto=fetchto,
source='git')) source='git'))
def _process_manifest_makefiles(self): def _process_manifest_makefiles(self):
"""Get the extra makefiles defined in the HDLMake module""" """Get the extra makefiles defined in the HDLMake module"""
......
...@@ -61,14 +61,8 @@ class Module(ModuleContent): ...@@ -61,14 +61,8 @@ class Module(ModuleContent):
def submodules(self): def submodules(self):
"""Get a list with all the submodules this module instance requires""" """Get a list with all the submodules this module instance requires"""
def __nonull(submodule_list): return self.modules['local'] + self.modules['git'] \
"""Returns a list with the submodules, being empty if null""" + self.modules['gitsm'] + self.modules['svn']
if not submodule_list:
return []
else:
return submodule_list
return __nonull(self.local) + __nonull(self.git) \
+ __nonull(self.gitsm) + __nonull(self.svn)
def remove_dir_from_disk(self): def remove_dir_from_disk(self):
"""Delete the module dir if it is already fetched and available""" """Delete the module dir if it is already fetched and available"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment