Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
99233412
Commit
99233412
authored
Jul 15, 2014
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18974: Tools/scripts/diff.py now uses argparse instead of optparse.
parent
24fb2d40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
Misc/NEWS
Misc/NEWS
+2
-0
Tools/scripts/diff.py
Tools/scripts/diff.py
+18
-16
No files found.
Misc/NEWS
View file @
99233412
...
...
@@ -759,6 +759,8 @@ Tests
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.
Patch by Zachary Ware.
...
...
Tools/scripts/diff.py
View file @
99233412
...
...
@@ -8,7 +8,7 @@
"""
import
sys
,
os
,
time
,
difflib
,
opt
parse
import
sys
,
os
,
time
,
difflib
,
arg
parse
from
datetime
import
datetime
,
timezone
def
file_mtime
(
path
):
...
...
@@ -18,23 +18,25 @@ def file_mtime(path):
def
main
():
usage
=
"usage: %prog [options] fromfile tofile"
parser
=
optparse
.
OptionParser
(
usage
)
parser
.
add_option
(
"-c"
,
action
=
"store_true"
,
default
=
False
,
help
=
'Produce a context format diff (default)'
)
parser
.
add_option
(
"-u"
,
action
=
"store_true"
,
default
=
False
,
help
=
'Produce a unified format diff'
)
parser
.
add_option
(
"-m"
,
action
=
"store_true"
,
default
=
False
,
help
=
'Produce HTML side by side diff (can use -c and -l in conjunction)'
)
parser
.
add_option
(
"-n"
,
action
=
"store_true"
,
default
=
False
,
help
=
'Produce a ndiff format diff'
)
parser
.
add_option
(
"-l"
,
"--lines"
,
type
=
"int"
,
default
=
3
,
help
=
'Set number of context lines (default 3)'
)
(
options
,
args
)
=
parser
.
parse_args
()
if
len
(
args
)
==
0
:
parser
.
print_help
()
sys
.
exit
(
1
)
if
len
(
args
)
!=
2
:
parser
.
error
(
"need to specify both a fromfile and tofile"
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'-c'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Produce a context format diff (default)'
)
parser
.
add_argument
(
'-u'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Produce a unified format diff'
)
parser
.
add_argument
(
'-m'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Produce HTML side by side diff '
'(can use -c and -l in conjunction)'
)
parser
.
add_argument
(
'-n'
,
action
=
'store_true'
,
default
=
False
,
help
=
'Produce a ndiff format diff'
)
parser
.
add_argument
(
'-l'
,
'--lines'
,
type
=
int
,
default
=
3
,
help
=
'Set number of context lines (default 3)'
)
parser
.
add_argument
(
'fromfile'
)
parser
.
add_argument
(
'tofile'
)
options
=
parser
.
parse_args
()
n
=
options
.
lines
fromfile
,
tofile
=
args
fromfile
=
options
.
fromfile
tofile
=
options
.
tofile
fromdate
=
file_mtime
(
fromfile
)
todate
=
file_mtime
(
tofile
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment