summaryrefslogtreecommitdiffstats
path: root/Tools/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/scripts')
-rwxr-xr-xTools/scripts/crlf.py12
-rwxr-xr-xTools/scripts/findnocoding.py4
-rw-r--r--Tools/scripts/patchcheck.py17
-rwxr-xr-xTools/scripts/pysetup34
-rw-r--r--Tools/scripts/pysource.py2
5 files changed, 16 insertions, 23 deletions
diff --git a/Tools/scripts/crlf.py b/Tools/scripts/crlf.py
index 0622282..f231d29 100755
--- a/Tools/scripts/crlf.py
+++ b/Tools/scripts/crlf.py
@@ -8,16 +8,16 @@ def main():
if os.path.isdir(filename):
print(filename, "Directory!")
continue
- data = open(filename, "rb").read()
- if '\0' in data:
+ with open(filename, "rb") as f:
+ data = f.read()
+ if b'\0' in data:
print(filename, "Binary!")
continue
- newdata = data.replace("\r\n", "\n")
+ newdata = data.replace(b"\r\n", b"\n")
if newdata != data:
print(filename)
- f = open(filename, "wb")
- f.write(newdata)
- f.close()
+ with open(filename, "wb") as f:
+ f.write(newdata)
if __name__ == '__main__':
main()
diff --git a/Tools/scripts/findnocoding.py b/Tools/scripts/findnocoding.py
index 77607ce..c42fa7c 100755
--- a/Tools/scripts/findnocoding.py
+++ b/Tools/scripts/findnocoding.py
@@ -2,7 +2,7 @@
"""List all those Python files that require a coding directive
-Usage: nocoding.py dir1 [dir2...]
+Usage: findnocoding.py dir1 [dir2...]
"""
__author__ = "Oleg Broytmann, Georg Brandl"
@@ -50,7 +50,7 @@ def has_correct_encoding(text, codec):
def needs_declaration(fullpath):
try:
- infile = open(fullpath, 'rU')
+ infile = open(fullpath)
except IOError: # Oops, the file was removed - ignore it
return None
diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py
index e767eda..d42bc8a 100644
--- a/Tools/scripts/patchcheck.py
+++ b/Tools/scripts/patchcheck.py
@@ -36,23 +36,14 @@ def status(message, modal=False, info=None):
def changed_files():
"""Get the list of changed or added files from the VCS."""
if os.path.isdir('.hg'):
- vcs = 'hg'
cmd = 'hg status --added --modified --no-status'
- elif os.path.isdir('.svn'):
- vcs = 'svn'
- cmd = 'svn status --quiet --non-interactive --ignore-externals'
else:
sys.exit('need a checkout to get modified files')
st = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
try:
st.wait()
- if vcs == 'hg':
- return [x.decode().rstrip() for x in st.stdout]
- else:
- output = (x.decode().rstrip().rsplit(None, 1)[-1]
- for x in st.stdout if x[0] in b'AM')
- return set(path for path in output if os.path.isfile(path))
+ return [x.decode().rstrip() for x in st.stdout]
finally:
st.stdout.close()
@@ -72,10 +63,8 @@ def report_modified_files(file_paths):
def normalize_whitespace(file_paths):
"""Make sure that the whitespace for .py files have been normalized."""
reindent.makebackup = False # No need to create backups.
- fixed = []
- for path in (x for x in file_paths if x.endswith('.py')):
- if reindent.check(path):
- fixed.append(path)
+ fixed = [path for path in file_paths if path.endswith('.py') and
+ reindent.check(path)]
return fixed
diff --git a/Tools/scripts/pysetup3 b/Tools/scripts/pysetup3
new file mode 100755
index 0000000..e6a908d
--- /dev/null
+++ b/Tools/scripts/pysetup3
@@ -0,0 +1,4 @@
+#!/usr/bin/env python3
+import sys
+from packaging.run import main
+sys.exit(main())
diff --git a/Tools/scripts/pysource.py b/Tools/scripts/pysource.py
index 048131e..c7dbe60 100644
--- a/Tools/scripts/pysource.py
+++ b/Tools/scripts/pysource.py
@@ -42,7 +42,7 @@ def _open(fullpath):
return None
try:
- return open(fullpath, 'rU')
+ return open(fullpath)
except IOError as err: # Access denied, or a special file - ignore it
print_debug("%s: access denied: %s" % (fullpath, err))
return None