gh-68686: Retire eptag ptag scripts (#98064)

* Retire eptag ptag scripts

* 📜🤖 Added by blurb_it.

* fix news entry error

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
Joannah Nanjekye 2022-10-08 07:57:47 -07:00 committed by GitHub
parent 83eb827247
commit 4ed00be98f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 1 additions and 112 deletions

View file

@ -5,7 +5,6 @@ useful while building, extending or managing Python.
abitype.py Converts a C file to use the PEP 384 type definition API
combinerefs.py A helper for analyzing PYTHONDUMPREFS output
diff.py Print file diffs in context, unified, or ndiff formats
eptags.py Create Emacs TAGS file for Python modules
gprof2html.py Transform gprof(1) output into useful HTML
idle3 Main program to start IDLE
md5sum.py Print MD5 checksums of argument files

View file

@ -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()

View file

@ -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()