Commits

Lars Yencken committed a8801a3

Adds a --skip option to skip the first n parses.

  • Participants
  • Parent commits a6b8214

Comments (0)

Files changed (1)

File parse_vis.py

 
 import shell_color
 
-def parse_vis(filename, fmt='pdf'):
+def parse_vis(filename, fmt='pdf', skip=0):
+    parses = _iter_parses(filename)
+
+    if skip > 0:
+        # skip the first n parses
+        parses = itertools.islice(parses, skip, None)
+
     n = 0
-    for graph, tokens in _iter_parses(filename):
+    for graph, tokens in parses:
         _dump_dot(graph, filename + '.dot')
         _render_dot(filename + '.dot', fmt)
         _display_tokens(tokens)
 
     parser = optparse.OptionParser(usage)
 
+    parser.add_option('-s', '--skip', action='store', dest='skip', type='int',
+            default=0, help='Skip the first n parses in the stream.')
+
     return parser
 
 def main(argv):
         parser.print_help()
         sys.exit(1)
 
-    parse_vis(*args)
+    parse_vis(*args, skip=options.skip)
 
 #----------------------------------------------------------------------------#