Parcourir la source

Merge pull request #6 from myint/setup

Add missing main()
Matthew Wang il y a 12 ans
Parent
révision
74ef6434c9
1 fichiers modifiés avec 7 ajouts et 5 suppressions
  1. 7
    5
      src/cdiff.py

+ 7
- 5
src/cdiff.py Voir le fichier

471
                 yield line
471
                 yield line
472
 
472
 
473
 
473
 
474
-def markup_to_pager(stream):
474
+def markup_to_pager(stream, opts):
475
     markup = DiffMarkup(stream)
475
     markup = DiffMarkup(stream)
476
     color_diff = markup.markup(side_by_side=opts.side_by_side,
476
     color_diff = markup.markup(side_by_side=opts.side_by_side,
477
             width=opts.width)
477
             width=opts.width)
510
         return line
510
         return line
511
 
511
 
512
 
512
 
513
-if __name__ == '__main__':
513
+def main():
514
     import optparse
514
     import optparse
515
 
515
 
516
     supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
516
     supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
550
 
550
 
551
     # Don't let empty diff pass thru
551
     # Don't let empty diff pass thru
552
     if not stream:
552
     if not stream:
553
-        sys.exit(0)
553
+        return
554
 
554
 
555
     if diff_hdl is not sys.stdin:
555
     if diff_hdl is not sys.stdin:
556
         diff_hdl.close()
556
         diff_hdl.close()
557
 
557
 
558
     if sys.stdout.isatty():
558
     if sys.stdout.isatty():
559
         try:
559
         try:
560
-            markup_to_pager(stream)
560
+            markup_to_pager(stream, opts)
561
         except IOError:
561
         except IOError:
562
             e = sys.exc_info()[1]
562
             e = sys.exc_info()[1]
563
             if e.errno == errno.EPIPE:
563
             if e.errno == errno.EPIPE:
566
         # pipe out stream untouched to make sure it is still a patch
566
         # pipe out stream untouched to make sure it is still a patch
567
         sys.stdout.write(''.join(stream))
567
         sys.stdout.write(''.join(stream))
568
 
568
 
569
-    sys.exit(0)
569
+
570
+if __name__ == '__main__':
571
+    main()
570
 
572
 
571
 # vim:set et sts=4 sw=4 tw=80:
573
 # vim:set et sts=4 sw=4 tw=80: