mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Issue #18974: Tools/scripts/diff.py now uses argparse instead of optparse.
This commit is contained in:
parent
24fb2d4012
commit
992334127e
2 changed files with 20 additions and 16 deletions
|
@ -759,6 +759,8 @@ Tests
|
||||||
Tools/Demos
|
Tools/Demos
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
- Issue #18974: Tools/scripts/diff.py now uses argparse instead of optparse.
|
||||||
|
|
||||||
- Issue #21906: Make Tools/scripts/md5sum.py work in Python 3.
|
- Issue #21906: Make Tools/scripts/md5sum.py work in Python 3.
|
||||||
Patch by Zachary Ware.
|
Patch by Zachary Ware.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys, os, time, difflib, optparse
|
import sys, os, time, difflib, argparse
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
def file_mtime(path):
|
def file_mtime(path):
|
||||||
|
@ -18,23 +18,25 @@ def file_mtime(path):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
usage = "usage: %prog [options] fromfile tofile"
|
parser = argparse.ArgumentParser()
|
||||||
parser = optparse.OptionParser(usage)
|
parser.add_argument('-c', action='store_true', default=False,
|
||||||
parser.add_option("-c", action="store_true", default=False, help='Produce a context format diff (default)')
|
help='Produce a context format diff (default)')
|
||||||
parser.add_option("-u", action="store_true", default=False, help='Produce a unified format diff')
|
parser.add_argument('-u', action='store_true', default=False,
|
||||||
parser.add_option("-m", action="store_true", default=False, help='Produce HTML side by side diff (can use -c and -l in conjunction)')
|
help='Produce a unified format diff')
|
||||||
parser.add_option("-n", action="store_true", default=False, help='Produce a ndiff format diff')
|
parser.add_argument('-m', action='store_true', default=False,
|
||||||
parser.add_option("-l", "--lines", type="int", default=3, help='Set number of context lines (default 3)')
|
help='Produce HTML side by side diff '
|
||||||
(options, args) = parser.parse_args()
|
'(can use -c and -l in conjunction)')
|
||||||
|
parser.add_argument('-n', action='store_true', default=False,
|
||||||
if len(args) == 0:
|
help='Produce a ndiff format diff')
|
||||||
parser.print_help()
|
parser.add_argument('-l', '--lines', type=int, default=3,
|
||||||
sys.exit(1)
|
help='Set number of context lines (default 3)')
|
||||||
if len(args) != 2:
|
parser.add_argument('fromfile')
|
||||||
parser.error("need to specify both a fromfile and tofile")
|
parser.add_argument('tofile')
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
n = options.lines
|
n = options.lines
|
||||||
fromfile, tofile = args
|
fromfile = options.fromfile
|
||||||
|
tofile = options.tofile
|
||||||
|
|
||||||
fromdate = file_mtime(fromfile)
|
fromdate = file_mtime(fromfile)
|
||||||
todate = file_mtime(tofile)
|
todate = file_mtime(tofile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue