projects.py: Add option -d (debug)

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2016-02-01 15:18:43 +00:00
commit f0e320698a

View file

@ -16,8 +16,9 @@ def re_section(name):
re.DOTALL)
# --------------------------------------------------------------------- helpers
def warning(*objs):
print("WARNING: ", *objs, file=sys.stderr)
def debug(*objs):
if args.debug:
print("DEBUG: ", *objs, file=sys.stderr)
def proj_dir(name):
return projs_root + '/' + name
@ -42,7 +43,7 @@ def get_section(path, section):
return r.rstrip()
def read_value(path, section, key):
warning("opening ", path)
debug("opening ", path)
try:
file = open(path)
except:
@ -104,7 +105,7 @@ def add_modules_from_project_txt(buf, visited, spec, section, key, add_self, sco
# return
visited.add(spec)
deps = get_value(name, section, key)
warning("name = ", name, "section = ", section, "key = ", key, "deps = ", deps, "scope = ", scope, "visited = ", visited)
debug("name = ", name, "section = ", section, "key = ", key, "deps = ", deps, "scope = ", scope, "visited = ", visited)
if deps and scope > 0:
if scope == 1:
subscope = 0
@ -242,7 +243,6 @@ def cmd_proj_dir(args_):
# -------------------------------------------------------------------- here we go
warning("running ", ' '.join(sys.argv))
global_args = []
skip = 0
for a in sys.argv[1::]:
@ -256,13 +256,20 @@ for a in sys.argv[1::]:
if a[0] != '-':
break
topdir = None
top_name = None
parser = argparse.ArgumentParser(description='Project metadata evaluation')
parser.add_argument('cmd', default='', help='Command')
parser.add_argument('--debug', '-d', nargs='?', const=True, default=False, help='Output debug information to stderr')
parser.add_argument('--topdir', '-t', nargs='?', help='Project Path')
parser.add_argument('--prefix', '-p', nargs='?', default = expanduser("~") +
'/local/src/cvs.stable/proj', help='Projects Path Prefix')
parser.add_argument('arg', nargs='*', help='Command arguments')
args=parser.parse_args(global_args)
debug("running ", ' '.join(sys.argv))
projs_root = args.prefix
if args.topdir:
topdir = args.topdir