From 85c01c9a9063bdb97988d9f43f624265e6f39785 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 15 Mar 2021 02:27:55 -0600 Subject: [PATCH] bpo-24498: Remove ptags.py and eptags.py from Tools/scripts ctags directly supports Python. --- .../2021-03-15-02-27-18.bpo-24498.QbwmeZ.rst | 1 + Tools/scripts/README | 2 - Tools/scripts/eptags.py | 57 ------------------- Tools/scripts/ptags.py | 54 ------------------ 4 files changed, 1 insertion(+), 113 deletions(-) create mode 100644 Misc/NEWS.d/next/Tools-Demos/2021-03-15-02-27-18.bpo-24498.QbwmeZ.rst delete mode 100755 Tools/scripts/eptags.py delete mode 100755 Tools/scripts/ptags.py diff --git a/Misc/NEWS.d/next/Tools-Demos/2021-03-15-02-27-18.bpo-24498.QbwmeZ.rst b/Misc/NEWS.d/next/Tools-Demos/2021-03-15-02-27-18.bpo-24498.QbwmeZ.rst new file mode 100644 index 00000000000000..02f34bd1af4566 --- /dev/null +++ b/Misc/NEWS.d/next/Tools-Demos/2021-03-15-02-27-18.bpo-24498.QbwmeZ.rst @@ -0,0 +1 @@ +Remove ptags.py and eptags.py from the Tools/scripts directory. diff --git a/Tools/scripts/README b/Tools/scripts/README index 7fc51a10ee902c..164aace53a50da 100644 --- a/Tools/scripts/README +++ b/Tools/scripts/README @@ -14,7 +14,6 @@ crlf.py Change CRLF line endings to LF (Windows to Unix) db2pickle.py Dump a database file to a pickle diff.py Print file diffs in context, unified, or ndiff formats dutree.py Format du(1) output as a tree sorted by size -eptags.py Create Emacs TAGS file for Python modules finddiv.py A grep-like tool that looks for division operators findlinksto.py Recursively find symbolic links to a given path prefix findnocoding.py Find source files which need an encoding declaration @@ -50,7 +49,6 @@ pathfix.py Change #!/usr/local/bin/python into something else pdeps.py Print dependencies between Python modules pickle2db.py Load a pickle generated by db2pickle.py to a database pindent.py Indent Python code, giving block-closing comments -ptags.py Create vi tags file for Python modules pydoc3 Python documentation browser pysource.py Find Python source files reindent.py Change .py files to use 4-space indents diff --git a/Tools/scripts/eptags.py b/Tools/scripts/eptags.py deleted file mode 100755 index 7f8059ba71adf3..00000000000000 --- a/Tools/scripts/eptags.py +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/bin/env python3 -"""Create a TAGS file for Python programs, usable with GNU Emacs. - -usage: eptags pyfiles... - -The output TAGS file is usable with Emacs version 18, 19, 20. -Tagged are: - - functions (even inside other defs or classes) - - classes - -eptags warns about files it cannot open. -eptags will not give warnings about duplicate tags. - -BUGS: - Because of tag duplication (methods with the same name in different - classes), TAGS files are not very useful for most object-oriented - python projects. -""" -import sys,re - -expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\(]' -matcher = re.compile(expr) - -def treat_file(filename, outfp): - """Append tags found in file named 'filename' to the open file 'outfp'""" - try: - fp = open(filename, 'r') - except OSError: - sys.stderr.write('Cannot open %s\n'%filename) - return - with fp: - charno = 0 - lineno = 0 - tags = [] - size = 0 - while 1: - line = fp.readline() - if not line: - break - lineno = lineno + 1 - m = matcher.search(line) - if m: - tag = m.group(0) + '\177%d,%d\n' % (lineno, charno) - tags.append(tag) - size = size + len(tag) - charno = charno + len(line) - outfp.write('\f\n%s,%d\n' % (filename,size)) - for tag in tags: - outfp.write(tag) - -def main(): - with open('TAGS', 'w') as outfp: - for filename in sys.argv[1:]: - treat_file(filename, outfp) - -if __name__=="__main__": - main() diff --git a/Tools/scripts/ptags.py b/Tools/scripts/ptags.py deleted file mode 100755 index eedd411702c199..00000000000000 --- a/Tools/scripts/ptags.py +++ /dev/null @@ -1,54 +0,0 @@ -#! /usr/bin/env python3 - -# ptags -# -# Create a tags file for Python programs, usable with vi. -# Tagged are: -# - functions (even inside other defs or classes) -# - classes -# - filenames -# Warns about files it cannot open. -# No warnings about duplicate tags. - -import sys, re, os - -tags = [] # Modified global variable! - -def main(): - args = sys.argv[1:] - for filename in args: - treat_file(filename) - if tags: - with open('tags', 'w') as fp: - tags.sort() - for s in tags: fp.write(s) - - -expr = r'^[ \t]*(def|class)[ \t]+([a-zA-Z0-9_]+)[ \t]*[:\(]' -matcher = re.compile(expr) - -def treat_file(filename): - try: - fp = open(filename, 'r') - except: - sys.stderr.write('Cannot open %s\n' % filename) - return - with fp: - base = os.path.basename(filename) - if base[-3:] == '.py': - base = base[:-3] - s = base + '\t' + filename + '\t' + '1\n' - tags.append(s) - while 1: - line = fp.readline() - if not line: - break - m = matcher.match(line) - if m: - content = m.group(0) - name = m.group(2) - s = name + '\t' + filename + '\t/^' + content + '/\n' - tags.append(s) - -if __name__ == '__main__': - main()