diff --git a/tools/java-event-log-tags.py b/tools/java-event-log-tags.py index f364751c4..37cd71220 100755 --- a/tools/java-event-log-tags.py +++ b/tools/java-event-log-tags.py @@ -51,30 +51,37 @@ for o, a in opts: print >> sys.stderr, "unhandled option %s" % (o,) sys.exit(1) -if len(args) != 2: - print "need exactly two input files, not %d" % (len(args),) +if len(args) != 1 and len(args) != 2: + print "need one or two input files, not %d" % (len(args),) print __doc__ sys.exit(1) fn = args[0] tagfile = event_log_tags.TagFile(fn) -# Load the merged tag file (which should have numbers assigned for all -# tags. Use the numbers from the merged file to fill in any missing -# numbers from the input file. -merged_fn = args[1] -merged_tagfile = event_log_tags.TagFile(merged_fn) -merged_by_name = dict([(t.tagname, t) for t in merged_tagfile.tags]) -for t in tagfile.tags: - if t.tagnum is None: - if t.tagname in merged_by_name: - t.tagnum = merged_by_name[t.tagname].tagnum - else: - # We're building something that's not being included in the - # product, so its tags don't appear in the merged file. Assign - # them all an arbitrary number so we can emit the java and - # compile the (unused) package. - t.tagnum = 999999 +if len(args) > 1: + # Load the merged tag file (which should have numbers assigned for all + # tags. Use the numbers from the merged file to fill in any missing + # numbers from the input file. + merged_fn = args[1] + merged_tagfile = event_log_tags.TagFile(merged_fn) + merged_by_name = dict([(t.tagname, t) for t in merged_tagfile.tags]) + for t in tagfile.tags: + if t.tagnum is None: + if t.tagname in merged_by_name: + t.tagnum = merged_by_name[t.tagname].tagnum + else: + # We're building something that's not being included in the + # product, so its tags don't appear in the merged file. Assign + # them all an arbitrary number so we can emit the java and + # compile the (unused) package. + t.tagnum = 999999 +else: + # Not using the merged tag file, so all tags must have manually assigned + # numbers + for t in tagfile.tags: + if t.tagnum is None: + tagfilef.AddError("tag \"%s\" has no number" % (tagname,), tag.linenum) if "java_package" not in tagfile.options: tagfile.AddError("java_package option not specified", linenum=0)