diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
commit | a73a964e51247ed169d322c725a3a18859f109a3 (patch) | |
tree | 3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Doc/tools/anno-api.py | |
parent | e64efe273fcb921a61bf27d33b230c4e64fcd425 (diff) |
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Doc/tools/anno-api.py')
-rwxr-xr-x | sys/src/cmd/python/Doc/tools/anno-api.py | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/sys/src/cmd/python/Doc/tools/anno-api.py b/sys/src/cmd/python/Doc/tools/anno-api.py deleted file mode 100755 index 68e2ad9ce..000000000 --- a/sys/src/cmd/python/Doc/tools/anno-api.py +++ /dev/null @@ -1,71 +0,0 @@ -#! /usr/bin/env python -"""Add reference count annotations to the Python/C API Reference.""" -__version__ = '$Revision: 17623 $' - -import getopt -import os -import sys - -import refcounts - - -PREFIX_1 = r"\begin{cfuncdesc}{PyObject*}{" -PREFIX_2 = r"\begin{cfuncdesc}{PyVarObject*}{" - - -def main(): - rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, - "api", "refcounts.dat") - outfile = "-" - opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) - for opt, arg in opts: - if opt in ("-o", "--output"): - outfile = arg - elif opt in ("-r", "--refcounts"): - rcfile = arg - rcdict = refcounts.load(rcfile) - if outfile == "-": - output = sys.stdout - else: - output = open(outfile, "w") - if not args: - args = ["-"] - for infile in args: - if infile == "-": - input = sys.stdin - else: - input = open(infile) - while 1: - line = input.readline() - if not line: - break - prefix = None - if line.startswith(PREFIX_1): - prefix = PREFIX_1 - elif line.startswith(PREFIX_2): - prefix = PREFIX_2 - if prefix: - s = line[len(prefix):].split('}', 1)[0] - try: - info = rcdict[s] - except KeyError: - sys.stderr.write("No refcount data for %s\n" % s) - else: - if info.result_type in ("PyObject*", "PyVarObject*"): - if info.result_refs is None: - rc = "Always \NULL{}" - else: - rc = info.result_refs and "New" or "Borrowed" - rc = rc + " reference" - line = (r"\begin{cfuncdesc}[%s]{%s}{" - % (rc, info.result_type)) \ - + line[len(prefix):] - output.write(line) - if infile != "-": - input.close() - if outfile != "-": - output.close() - - -if __name__ == "__main__": - main() |