Progress option for wmlscope.

This commit is contained in:
Eric S. Raymond 2010-07-19 15:04:06 +00:00
parent ad6a9c96a7
commit b1fe81d099
2 changed files with 13 additions and 5 deletions

View file

@ -476,7 +476,7 @@ class CrossRef:
self.unit_ids[uid].append(Reference(namespace, filename, n+1))
latch_unit= False
dfp.close()
def __init__(self, dirpath=[], exclude="", warnlevel=0):
def __init__(self, dirpath=[], exclude="", warnlevel=0, progress=False):
"Build cross-reference object from the specified filelist."
self.filelist = Forest(dirpath, exclude)
self.dirpath = filter(lambda x: not re.search(exclude, x), dirpath)
@ -487,12 +487,14 @@ class CrossRef:
self.properties = {}
self.unit_ids = {}
all_in = []
if self.warnlevel >=2:
if self.warnlevel >=2 or progress:
print "*** Beginning definition-gathering pass..."
for (namespace, filename) in self.filelist.generator():
all_in.append((namespace, filename))
if self.warnlevel > 1:
print filename + ":"
if progress:
print filename
if isresource(filename):
self.fileref[filename] = Reference(namespace, filename)
elif iswml(filename):
@ -510,9 +512,11 @@ class CrossRef:
self.missing = []
formals = []
state = "outside"
if self.warnlevel >=2:
if self.warnlevel >=2 or progress:
print "*** Beginning reference-gathering pass..."
for (ns, fn) in all_in:
if progress:
print filename
if iswml(fn):
rfp = open(fn)
attack_name = None

View file

@ -364,7 +364,7 @@ Usage: macroscope [options] dirpath
try:
# Process options
(options, arguments) = getopt.getopt(sys.argv[1:], "cCdhe:f:lr:t:uw:",
(options, arguments) = getopt.getopt(sys.argv[1:], "cCdhe:f:lpr:t:uw:",
[
'crossreference',
'collisions',
@ -375,6 +375,7 @@ Usage: macroscope [options] dirpath
'from=',
'help',
'listfiles',
'progress',
'refcount=',
'typelist=',
'unchecked',
@ -390,6 +391,7 @@ Usage: macroscope [options] dirpath
collisions = False
typelist = None
unchecked = False
progress = False
for (switch, val) in options:
if switch in ('-h', '--help'):
help()
@ -411,6 +413,8 @@ Usage: macroscope [options] dirpath
forceused.append(val)
elif switch in ('-l', '--listfiles'):
listfiles = True
elif switch in ('-d', '--progress'):
progress = True
elif switch in ('-r', '--refcount'):
refcount_restrict = int(val)
elif switch == '--unchecked':
@ -432,7 +436,7 @@ Usage: macroscope [options] dirpath
print "# Invocation: %s" % " ".join(sys.argv)
print "# Working directory: %s" % os.getcwd()
starttime = time.time()
xref = CrossRefLister(dirpath, "|".join(exclude), warnlevel)
xref = CrossRefLister(dirpath, "|".join(exclude), warnlevel, progress)
if not extracthelp:
print "#Cross-reference time: %d seconds" % (time.time()-starttime)
if extracthelp: