8 def status(message
, modal
=False, info
=None):
9 """Decorator to output status info to stdout."""
10 def decorated_fxn(fxn
):
11 def call_fxn(*args
, **kwargs
):
12 sys
.stdout
.write(message
+ ' ... ')
14 result
= fxn(*args
, **kwargs
)
15 if not modal
and not info
:
28 @status("Getting the list of files that have been added/changed",
29 info
=lambda x
: "%s files" % len(x
))
31 """Run ``svn status`` and return a set of files that have been
33 cmd
= 'svn status --quiet --non-interactive --ignore-externals'
34 svn_st
= subprocess
.Popen(cmd
, shell
=True, stdout
=subprocess
.PIPE
)
36 output
= [line
.strip() for line
in svn_st
.stdout
.readlines()]
39 if not line
[0] in ('A', 'M'):
41 line_parts
= line
.split()
43 if os
.path
.isfile(path
):
47 @status("Fixing whitespace", info
=lambda x
: "%s files" % x
)
48 def normalize_whitespace(file_paths
):
49 """Make sure that the whitespace for .py files have been normalized."""
50 reindent
.makebackup
= False # No need to create backups.
51 result
= map(reindent
.check
, (x
for x
in file_paths
if x
.endswith('.py')))
54 @status("Docs modified", modal
=True)
55 def docs_modified(file_paths
):
56 """Report if any files in the Docs directory."""
57 for path
in file_paths
:
58 if path
.startswith("Doc"):
62 @status("Misc/ACKS updated", modal
=True)
63 def credit_given(file_paths
):
64 """Check if Misc/ACKS has been changed."""
65 return 'Misc/ACKS' in file_paths
67 @status("Misc/NEWS updated", modal
=True)
68 def reported_news(file_paths
):
69 """Check if Misc/NEWS has been changed."""
70 return 'Misc/NEWS' in file_paths
74 file_paths
= changed_files()
75 # PEP 7/8 verification.
76 normalize_whitespace(file_paths
)
78 docs_modified(file_paths
)
80 credit_given(file_paths
)
82 reported_news(file_paths
)
84 # Test suite run and passed.
86 print "Did you run the test suite?"
89 if __name__
== '__main__':