Clean up the list-mods function, including a new --terse option

parent 65467140
......@@ -211,6 +211,7 @@ def _get_parser():
clean = subparsers.add_parser("clean", help="remove all modules fetched for direct and indirect children of this module")
listmod = subparsers.add_parser("list-mods", help="List all modules together with their files")
listmod.add_argument("--with-files", help="list modules together with their files", default=False, action="store_true", dest="withfiles")
listmod.add_argument("--terse", help="do not print comments", default=False, action="store_true", dest="terse")
listfiles = subparsers.add_parser("list-files", help="List all files in a form of a space-separated string")
listfiles.add_argument("--delimiter", help="set delimitier for the list of files", dest="delimiter", default=' ')
merge_cores = subparsers.add_parser("merge-cores", help="Merges entire synthesizable content of an project into a pair of VHDL/Verilog files")
......
......@@ -40,32 +40,26 @@ def _convert_to_source_name(source_code):
class ListModules(Action):
def run(self):
if self.options.withfiles:
for m in self.modules_pool:
if not m.isfetched:
print("#!UNFETCHED")
print(m.url+'\n')
for m in self.modules_pool:
if not m.isfetched:
if not self.options.terse: print("# MODULE UNFETCHED! -> %s" % m.url)
else:
if not self.options.terse: print("# MODULE START -> %s" % m.url)
if m.source in [fetch.SVN, fetch.GIT]:
if not self.options.terse: print("# * URL: "+m.url)
elif m.source == fetch.GITSUBMODULE:
if not self.options.terse: print("# * This is a submodule of: %s" % m.parent.url)
if m.source in [fetch.SVN, fetch.GIT, fetch.LOCAL] and m.parent:
if not self.options.terse: print("# * The parent for this module is: %s" % m.parent.url)
else:
print(path.relpath(m.path))
if m.source in [fetch.SVN, fetch.GIT]:
print("# "+m.url)
elif m.source == fetch.GITSUBMODULE:
print("# submodule of: %s" % m.parent.url)
if m.source in [fetch.SVN, fetch.GIT, fetch.LOCAL] and m.parent:
print("# parent: %s" % m.parent.url)
else:
print("# root module")
if not self.options.terse: print("# * This is the root module")
print("%s\t%s" % (path.relpath(m.path), _convert_to_source_name(m.source)))
if self.options.withfiles:
if not len(m.files):
print(" # no files")
if not self.options.terse: print("# * This module has no files")
else:
for f in m.files:
print(" " + path.relpath(f.path, m.path))
print("")
else:
print("#path\tsource")
for m in self.modules_pool:
if not m.isfetched:
print("# UNFETCHED! -> %s" % m.url)
else:
print("%s\t%s" % (path.relpath(m.path), _convert_to_source_name(m.source)))
print("%s\t%s" % (path.relpath(f.path), "file"))
if not self.options.terse: print("# MODULE END -> %s" % m.url)
if not self.options.terse: print("")
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