annotate Tools/scripts/patchcheck.py @ 50786:2d453b221bec 2.6

Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r68292 | skip.montanaro | 2009-01-04 11:36:58 +0100 (So, 04 Jan 2009) | 3 lines If user configures --without-gcc give preference to $CC instead of blindly assuming the compiler will be "cc". ........ r68344 | marc-andre.lemburg | 2009-01-05 20:43:35 +0100 (Mo, 05 Jan 2009) | 7 lines Fix #4846 (Py_UNICODE_ISSPACE causes linker error) by moving the declaration into the extern "C" section. Add a few more comments and apply some minor edits to make the file contents fit the original structure again. ........ r68361 | antoine.pitrou | 2009-01-06 19:34:08 +0100 (Di, 06 Jan 2009) | 3 lines Use shutil.rmtree rather than os.rmdir. ........ r68378 | mark.dickinson | 2009-01-07 18:48:33 +0100 (Mi, 07 Jan 2009) | 2 lines Issue #4869: clarify documentation for random.expovariate. ........ r68424 | benjamin.peterson | 2009-01-09 03:53:35 +0100 (Fr, 09 Jan 2009) | 1 line specify what -3 warnings are about ........ r68426 | benjamin.peterson | 2009-01-09 04:03:05 +0100 (Fr, 09 Jan 2009) | 1 line fix spelling ........ r68429 | benjamin.peterson | 2009-01-09 04:05:14 +0100 (Fr, 09 Jan 2009) | 1 line add -3 to manpage ........ r68430 | benjamin.peterson | 2009-01-09 04:07:27 +0100 (Fr, 09 Jan 2009) | 1 line be more specific in -3 option help ........ r68450 | jeffrey.yasskin | 2009-01-09 17:47:07 +0100 (Fr, 09 Jan 2009) | 3 lines Fix issue 4884, preventing a crash in the socket code when python is compiled with llvm-gcc and run with a glibc <2.10. ........ r68457 | kristjan.jonsson | 2009-01-09 21:10:59 +0100 (Fr, 09 Jan 2009) | 1 line Issue 3677: Fix import from UNC paths on Windows. ........ r68480 | vinay.sajip | 2009-01-10 14:38:04 +0100 (Sa, 10 Jan 2009) | 1 line Minor documentation changes cross-referencing NullHandler to the documentation on configuring logging in a library. ........ r68481 | vinay.sajip | 2009-01-10 14:42:04 +0100 (Sa, 10 Jan 2009) | 1 line Corrected an incorrect self-reference. ........ r68493 | benjamin.peterson | 2009-01-10 18:18:55 +0100 (Sa, 10 Jan 2009) | 1 line rewrite verbose conditionals ........ r68495 | benjamin.peterson | 2009-01-10 18:36:44 +0100 (Sa, 10 Jan 2009) | 1 line tp_iter only exists with Py_TPFLAGS_HAVE_ITER #4901 ........ r68499 | mark.dickinson | 2009-01-10 20:14:55 +0100 (Sa, 10 Jan 2009) | 2 lines Remove an unnecessary check from test_decimal. ........ r68501 | vinay.sajip | 2009-01-10 20:22:57 +0100 (Sa, 10 Jan 2009) | 1 line Corrected minor typo and added .currentmodule directives to fix missing cross-references. ........ r68512 | benjamin.peterson | 2009-01-10 23:42:10 +0100 (Sa, 10 Jan 2009) | 1 line make tests fail if they can't be imported ........ r68514 | benjamin.peterson | 2009-01-11 00:41:59 +0100 (So, 11 Jan 2009) | 1 line move seealso to a more appropiate place ........ r68515 | benjamin.peterson | 2009-01-11 00:49:08 +0100 (So, 11 Jan 2009) | 1 line macos 9 isn't supported ........
author Georg Brandl <georg@python.org>
date Wed, 14 Jan 2009 00:00:17 +0000
parents c424099b4ce4
children 2955f337969e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45859
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
1 import os.path
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
2 import subprocess
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
3 import sys
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
4
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
5 import reindent
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
6
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
7
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
8 def status(message, modal=False, info=None):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
9 """Decorator to output status info to stdout."""
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
10 def decorated_fxn(fxn):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
11 def call_fxn(*args, **kwargs):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
12 sys.stdout.write(message + ' ... ')
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
13 sys.stdout.flush()
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
14 result = fxn(*args, **kwargs)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
15 if not modal and not info:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
16 print "done"
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
17 elif info:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
18 print info(result)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
19 else:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
20 if result:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
21 print "yes"
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
22 else:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
23 print "NO"
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
24 return result
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
25 return call_fxn
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
26 return decorated_fxn
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
27
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
28 @status("Getting the list of files that have been added/changed",
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
29 info=lambda x: "%s files" % len(x))
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
30 def changed_files():
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
31 """Run ``svn status`` and return a set of files that have been
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
32 changed/added."""
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
33 cmd = 'svn status --quiet --non-interactive --ignore-externals'
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
34 svn_st = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
35 svn_st.wait()
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
36 output = [line.strip() for line in svn_st.stdout.readlines()]
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
37 files = set()
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
38 for line in output:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
39 if not line[0] in ('A', 'M'):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
40 continue
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
41 line_parts = line.split()
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
42 path = line_parts[-1]
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
43 if os.path.isfile(path):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
44 files.add(path)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
45 return files
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
46
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
47 @status("Fixing whitespace", info=lambda x: "%s files" % x)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
48 def normalize_whitespace(file_paths):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
49 """Make sure that the whitespace for .py files have been normalized."""
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
50 reindent.makebackup = False # No need to create backups.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
51 result = map(reindent.check, (x for x in file_paths if x.endswith('.py')))
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
52 return sum(result)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
53
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
54 @status("Docs modified", modal=True)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
55 def docs_modified(file_paths):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
56 """Report if any files in the Docs directory."""
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
57 for path in file_paths:
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
58 if path.startswith("Doc"):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
59 return True
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
60 return False
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
61
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
62 @status("Misc/ACKS updated", modal=True)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
63 def credit_given(file_paths):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
64 """Check if Misc/ACKS has been changed."""
50786
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 45859
diff changeset
65 return 'Misc/ACKS' in file_paths
45859
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
66
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
67 @status("Misc/NEWS updated", modal=True)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
68 def reported_news(file_paths):
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
69 """Check if Misc/NEWS has been changed."""
50786
2d453b221bec Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480-68481,68493,68495,68499,68501,68512,68514-68515 via svnmerge from
Georg Brandl <georg@python.org>
parents: 45859
diff changeset
70 return 'Misc/NEWS' in file_paths
45859
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
71
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
72
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
73 def main():
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
74 file_paths = changed_files()
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
75 # PEP 7/8 verification.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
76 normalize_whitespace(file_paths)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
77 # Docs updated.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
78 docs_modified(file_paths)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
79 # Misc/ACKS changed.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
80 credit_given(file_paths)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
81 # Misc/NEWS changed.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
82 reported_news(file_paths)
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
83
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
84 # Test suite run and passed.
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
85 print
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
86 print "Did you run the test suite?"
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
87
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
88
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
89 if __name__ == '__main__':
c424099b4ce4 Add Tools/scripts/patchcheck.py. Invoked from ``make check``, the script does
Brett Cannon <bcannon@gmail.com>
parents:
diff changeset
90 main()