path stringlengths 14 112 | content stringlengths 0 6.32M | size int64 0 6.32M | max_lines int64 1 100k | repo_name stringclasses 2
values | autogenerated bool 1
class |
|---|---|---|---|---|---|
cosmopolitan/third_party/python/Tools/scripts/win_add2path.py | """Add Python to the search path on Windows
This is a simple script to add Python to the Windows search path. It
modifies the current user (HKCU) tree of the registry.
Copyright (c) 2008 by Christian Heimes <christian@cheimes.de>
Licensed to PSF under a Contributor Agreement.
"""
import sys
import site
import os
imp... | 1,658 | 59 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/findlinksto.py | #! /usr/bin/env python3
# findlinksto
#
# find symbolic links to a path matching a regular expression
import os
import sys
import re
import getopt
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], '')
if len(args) < 2:
raise getopt.GetoptError('not enough arguments', None)
... | 1,071 | 44 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/reindent-rst.py | #!/usr/bin/env python3
# Make a reST file compliant to our pre-commit hook.
# Currently just remove trailing whitespace.
import sys
import patchcheck
def main(argv=sys.argv):
patchcheck.normalize_docs_whitespace(argv[1:])
if __name__ == '__main__':
sys.exit(main())
| 279 | 15 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/byteyears.py | #! /usr/bin/env python3
# Print the product of age and size of each file, in suitable units.
#
# Usage: byteyears [ -a | -m | -c ] file ...
#
# Options -[amc] select atime, mtime (default) or ctime as age.
import sys, os, time
from stat import *
def main():
# Use lstat() to stat files if it exists, else stat()
... | 1,650 | 62 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/lfcr.py | #! /usr/bin/env python3
"Replace LF with CRLF in argument files. Print names of changed files."
import sys, re, os
def main():
for filename in sys.argv[1:]:
if os.path.isdir(filename):
print(filename, "Directory!")
continue
with open(filename, "rb") as f:
data... | 640 | 25 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/pathfix.py | #!/usr/bin/env python3
# Change the #! line occurring in Python scripts. The new interpreter
# pathname must be given with a -i option.
#
# Command line arguments are files or directories to be processed.
# Directories are searched recursively for files whose name looks
# like a python module.
# Symbolic links are al... | 5,207 | 178 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/ndiff.py | #! /usr/bin/env python3
# Module ndiff version 1.7.0
# Released to the public domain 08-Dec-2000,
# by Tim Peters (tim.one@home.com).
# Provided as-is; use at your own risk; no warranty; no promises; enjoy!
# ndiff.py is now simply a front-end to the difflib.ndiff() function.
# Originally, it contained the difflib.S... | 3,820 | 134 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/ptags.py | #! /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!
de... | 1,227 | 54 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/nm2def.py | #! /usr/bin/env python3
"""nm2def.py
Helpers to extract symbols from Unix libs and auto-generate
Windows definition files from them. Depends on nm(1). Tested
on Linux and Solaris only (-p option to nm is for Solaris only).
By Marc-Andre Lemburg, Aug 1998.
Additional notes: the output of nm is supposed to look like t... | 2,454 | 104 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/svneol.py | #! /usr/bin/env python3
r"""
SVN helper script.
Try to set the svn:eol-style property to "native" on every .py, .txt, .c and
.h file in the directory tree rooted at the current directory.
Files with the svn:eol-style property already set (to anything) are skipped.
svn will itself refuse to set this property on a fi... | 3,494 | 115 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/make_ctype.py | #!/usr/bin/env python3
"""Script that generates the ctype.h-replacement in stringobject.c."""
NAMES = ("LOWER", "UPPER", "ALPHA", "DIGIT", "XDIGIT", "ALNUM", "SPACE")
print("""
#define FLAG_LOWER 0x01
#define FLAG_UPPER 0x02
#define FLAG_ALPHA (FLAG_LOWER|FLAG_UPPER)
#define FLAG_DIGIT 0x04
#define FLAG_ALNUM (F... | 2,280 | 95 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/texi2html.py | #! /usr/bin/env python3
# Convert GNU texinfo files into HTML, one file per node.
# Based on Texinfo 2.14.
# Usage: texi2html [-d] [-d] [-c] inputfile outputdirectory
# The input file must be a complete texinfo file, e.g. emacs.texi.
# This creates many files (one per info node) in the output directory,
# overwriting ... | 70,176 | 2,076 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/h2py.py | #! /usr/bin/env python3
# Read #define's and translate to Python code.
# Handle #include statements.
# Handle #define macros with one argument.
# Anything that isn't recognized or doesn't translate into valid
# Python is ignored.
# Without filename arguments, acts as a filter.
# If one or more filenames are given, ou... | 5,604 | 173 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/patchcheck.py | #!/usr/bin/env python3
"""Check proposed changes for common issues."""
import re
import sys
import shutil
import os.path
import subprocess
import sysconfig
import reindent
import untabify
# Excluded directories which are copies of external libraries:
# don't check their coding style
EXCLUDE_DIRS = [os.path.join('Mod... | 9,850 | 287 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/pysource.py | #!/usr/bin/env python3
"""\
List python source files.
There are three functions to check whether a file is a Python source, listed
here with increasing complexity:
- has_python_ext() checks whether a file name ends in '.py[w]'.
- look_like_python() checks whether the file is not binary and either has
the '.py[w]' ... | 3,864 | 131 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/combinerefs.py | #! /usr/bin/env python3
"""
combinerefs path
A helper for analyzing PYTHONDUMPREFS output.
When the PYTHONDUMPREFS envar is set in a debug build, at Python shutdown
time Py_FinalizeEx() prints the list of all live objects twice: first it
prints the repr() of each object while the interpreter is still fully intact.
... | 4,418 | 129 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/find-uname.py | #!/usr/bin/env python3
"""
For each argument on the command line, look for it in the set of all Unicode
names. Arguments are treated as case-insensitive regular expressions, e.g.:
% find-uname 'small letter a$' 'horizontal line'
*** small letter a$ matches ***
LATIN SMALL LETTER A (97)
COMBINING LATI... | 1,207 | 41 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/serve.py | #!/usr/bin/env python3
'''
Small wsgiref based web server. Takes a path to serve from and an
optional port number (defaults to 8000), then tries to serve files.
Mime types are guessed from the file names, 404 errors are raised
if the file is not found. Used for the make serve target in Doc.
'''
import sys
import os
imp... | 1,161 | 36 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/pdeps.py | #! /usr/bin/env python3
# pdeps
#
# Find dependencies between a bunch of Python modules.
#
# Usage:
# pdeps file1.py file2.py ...
#
# Output:
# Four tables separated by lines like '--- Closure ---':
# 1) Direct dependencies, listing which module imports which other modules
# 2) The inverse of (1)
# 3) Indirect d... | 3,915 | 166 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/mailerdaemon.py | #!/usr/bin/env python3
"""Classes to parse mailer-daemon messages."""
import calendar
import email.message
import re
import os
import sys
class Unparseable(Exception):
pass
class ErrorMessage(email.message.Message):
def __init__(self):
email.message.Message.__init__(self)
self.sub = ''
... | 8,040 | 247 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/db2pickle.py | #!/usr/bin/env python3
"""
Synopsis: %(prog)s [-h|-g|-b|-r|-a] dbfile [ picklefile ]
Convert the database file given on the command line to a pickle
representation. The optional flags indicate the type of the database:
-a - open using dbm (any supported format)
-b - open as bsddb btree file
-d - open as... | 3,630 | 136 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/gprof2html.py | #! /usr/bin/env python3
"""Transform gprof(1) output into useful HTML."""
import html
import os
import re
import sys
import webbrowser
header = """\
<html>
<head>
<title>gprof output (%s)</title>
</head>
<body>
<pre>
"""
trailer = """\
</pre>
</body>
</html>
"""
def add_escapes(filename):
with open(filename)... | 2,229 | 86 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/generate_opcode_h.py | # This script generates the opcode.h header file.
import sys
header = """/* Auto-generated by Tools/scripts/generate_opcode_h.py */
#ifndef Py_OPCODE_H
#define Py_OPCODE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Instruction opcodes for compiled code */
"""
footer = """
/* EXCEPT_HANDLER is a special, implicit... | 1,501 | 53 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/ifdef.py | #! /usr/bin/env python3
# Selectively preprocess #ifdef / #ifndef statements.
# Usage:
# ifdef [-Dname] ... [-Uname] ... [file] ...
#
# This scans the file(s), looking for #ifdef and #ifndef preprocessor
# commands that test for one of the names mentioned in the -D and -U
# options. On standard output it writes a cop... | 3,720 | 113 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/fixdiv.py | #! /usr/bin/env python3
"""fixdiv - tool to fix division operators.
To use this tool, first run `python -Qwarnall yourscript.py 2>warnings'.
This runs the script `yourscript.py' while writing warning messages
about all uses of the classic division operator to the file
`warnings'. The warnings look like this:
<fil... | 13,882 | 379 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/md5sum.py | #! /usr/bin/env python3
"""Python utility to print MD5 checksums of argument files.
"""
bufsize = 8096
fnfilter = None
rmode = 'rb'
usage = """
usage: md5sum.py [-b] [-t] [-l] [-s bufsize] [file ...]
-b : read files in binary mode (default)
-t : read files in text mode (you almost certainly don't want... | 2,508 | 94 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/dutree.doc | Path: cwi.nl!sun4nl!mcsun!uunet!cs.utexas.edu!convex!usenet
From: tchrist@convex.COM (Tom Christiansen)
Newsgroups: comp.lang.perl
Subject: Re: The problems of Perl (Re: Question (silly?))
Message-ID: <1992Jan17.053115.4220@convex.com>
Date: 17 Jan 92 05:31:15 GMT
References: <17458@ector.cs.purdue.edu> <1992Jan16.1653... | 2,237 | 55 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/mkreal.py | #! /usr/bin/env python3
# mkreal
#
# turn a symlink to a directory into a real directory
import sys
import os
from stat import *
join = os.path.join
error = 'mkreal error'
BUFSIZE = 32*1024
def mkrealfile(name):
st = os.stat(name) # Get the mode
mode = S_IMODE(st[ST_MODE])
linkto = os.readlink(name) #... | 1,631 | 67 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/idle3 | #! /usr/bin/env python3
from idlelib.pyshell import main
if __name__ == '__main__':
main()
| 96 | 6 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/pickle2db.py | #!/usr/bin/env python3
"""
Synopsis: %(prog)s [-h|-b|-g|-r|-a|-d] [ picklefile ] dbfile
Read the given picklefile as a series of key/value pairs and write to a new
database. If the database already exists, any contents are deleted. The
optional flags indicate the type of the output database:
-a - open using db... | 4,021 | 148 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/checkpyc.py | #! /usr/bin/env python3
# Check that all ".pyc" files exist and are up-to-date
# Uses module 'os'
import sys
import os
from stat import ST_MTIME
import importlib.util
# PEP 3147 compatibility (PYC Repository Directories)
cache_from_source = (importlib.util.cache_from_source if sys.implementation.cache_tag
... | 2,215 | 70 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/pyvenv | #!/usr/bin/env python3
if __name__ == '__main__':
import sys
import pathlib
executable = pathlib.Path(sys.executable or 'python3').name
print('WARNING: the pyenv script is deprecated in favour of '
f'`{executable} -m venv`', file=sys.stderr)
rc = 1
try:
import venv
ve... | 437 | 18 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/finddiv.py | #! /usr/bin/env python3
"""finddiv - a grep-like tool that looks for division operators.
Usage: finddiv [-l] file_or_directory ...
For directory arguments, all files in the directory whose name ends in
.py are processed, and subdirectories are processed recursively.
This actually tokenizes the files to avoid false ... | 2,497 | 90 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/byext.py | #! /usr/bin/env python3
"""Show file statistics by extension."""
import os
import sys
class Stats:
def __init__(self):
self.stats = {}
def statargs(self, args):
for arg in args:
if os.path.isdir(arg):
self.statdir(arg)
elif os.path.isfile(arg):
... | 3,916 | 133 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/update_file.py | """
A script that replaces an old file with a new one, only if the contents
actually changed. If not, the new file is simply deleted.
This avoids wholesale rebuilds when a code (re)generation phase does not
actually change the in-tree generated code.
"""
import os
import sys
def main(old_path, new_path):
with ... | 762 | 29 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/fixps.py | #!/usr/bin/env python3
# Fix Python script(s) to reference the interpreter via /usr/bin/env python.
# Warning: this overwrites the file without making a backup.
import sys
import re
def main():
for filename in sys.argv[1:]:
try:
f = open(filename, 'r')
except IOError as msg:
... | 899 | 34 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/find_recursionlimit.py | #! /usr/bin/env python3
"""Find the maximum recursion limit that prevents interpreter termination.
This script finds the maximum safe recursion limit on a particular
platform. If you need to change the recursion limit on your system,
this script will tell you a safe upper bound. To use the new limit,
call sys.setrec... | 3,995 | 129 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/findnocoding.py | #!/usr/bin/env python3
"""List all those Python files that require a coding directive
Usage: findnocoding.py dir1 [dir2...]
"""
__author__ = "Oleg Broytmann, Georg Brandl"
import sys, os, re, getopt
# our pysource module finds Python source files
try:
import pysource
except ImportError:
# emulate the modul... | 2,952 | 108 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/checkpip.py | #!/usr/bin/env python3
"""
Checks that the version of the projects bundled in ensurepip are the latest
versions available.
"""
import ensurepip
import json
import urllib.request
import sys
def main():
outofdate = False
for project, version in ensurepip._PROJECTS:
data = json.loads(urllib.request.urlo... | 793 | 33 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/parseentities.py | #!/usr/bin/env python3
""" Utility for parsing HTML entity definitions available from:
http://www.w3.org/ as e.g.
http://www.w3.org/TR/REC-html40/HTMLlat1.ent
Input is read from stdin, output is written to stdout in form of a
Python snippet defining a dictionary "entitydefs" mapping literal
en... | 1,695 | 63 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/fixheader.py | #! /usr/bin/env python3
# Add some standard cpp magic to a header file
import sys
def main():
args = sys.argv[1:]
for filename in args:
process(filename)
def process(filename):
try:
f = open(filename, 'r')
except IOError as msg:
sys.stderr.write('%s: can\'t open: %s\n' % (fil... | 1,208 | 50 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/fixnotice.py | #! /usr/bin/env python3
"""(Ostensibly) fix copyright notices in files.
Actually, this script will simply replace a block of text in a file from one
string to another. It will only do this once though, i.e. not globally
throughout the file. It writes a backup file and then does an os.rename()
dance for atomicity.
... | 3,059 | 114 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/analyze_dxp.py | """
Some helper functions to analyze the output of sys.getdxp() (which is
only available if Python was built with -DDYNAMIC_EXECUTION_PROFILE).
These will tell you which opcodes have been executed most frequently
in the current process, and, if Python was also built with -DDXPAIRS,
will tell you which instruction _pair... | 4,183 | 130 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/scripts/copytime.py | #! /usr/bin/env python3
# Copy one file's atime and mtime to another
import sys
import os
from stat import ST_ATIME, ST_MTIME # Really constants 7 and 8
def main():
if len(sys.argv) != 3:
sys.stderr.write('usage: copytime source destination\n')
sys.exit(2)
file1, file2 = sys.argv[1], sys.argv... | 663 | 27 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/iobench/iobench.py | # -*- coding: utf-8 -*-
# This file should be kept compatible with both Python 2.6 and Python >= 3.0.
import itertools
import os
import platform
import re
import sys
import time
from optparse import OptionParser
out = sys.stdout
TEXT_ENCODING = 'utf8'
NEWLINES = 'lf'
# Compatibility
try:
xrange
except NameError... | 17,772 | 557 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/unittestgui/README.txt | unittestgui.py is GUI framework and application for use with Python unit
testing framework. It executes tests written using the framework provided
by the 'unittest' module.
Based on the original by Steve Purcell, from:
http://pyunit.sourceforge.net/
Updated for unittest test discovery by Mark Roddy and Python 3
su... | 556 | 17 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/unittestgui/unittestgui.py | #!/usr/bin/env python3
"""
GUI framework and application for use with Python unit testing framework.
Execute tests written using the framework provided by the 'unittest' module.
Updated for unittest test discovery by Mark Roddy and Python 3
support by Brian Curtin.
Based on the original by Steve Purcell, from:
htt... | 18,560 | 479 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/parser/unparse.py | "Usage: unparse.py <path to source file>"
import sys
import ast
import tokenize
import io
import os
# Large float and imaginary literals get turned into infinities in the AST.
# We unparse those infinities to INFSTR.
INFSTR = "1e" + repr(sys.float_info.max_10_exp + 1)
def interleave(inter, f, seq):
"""Call f on e... | 20,138 | 707 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/markov.py | #!/usr/bin/env python3
"""
Markov chain simulation of words or characters.
"""
class Markov:
def __init__(self, histsize, choice):
self.histsize = histsize
self.choice = choice
self.trans = {}
def add(self, state, next):
self.trans.setdefault(state, []).append(next)
def p... | 3,685 | 126 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/beer.py | #!/usr/bin/env python3
"""
A Python version of the classic "bottles of beer on the wall" programming
example.
By Guido van Rossum, demystified after a version by Fredrik Lundh.
"""
import sys
n = 100
if sys.argv[1:]:
n = int(sys.argv[1])
def bottle(n):
if n == 0: return "no more bottles of beer"
if n =... | 566 | 26 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/mcast.py | #!/usr/bin/env python3
"""
Send/receive UDP multicast packets.
Requires that your OS kernel supports IP multicast.
Usage:
mcast -s (sender, IPv4)
mcast -s -6 (sender, IPv6)
mcast (receivers, IPv4)
mcast -6 (receivers, IPv6)
"""
MYPORT = 8123
MYGROUP_4 = '225.0.0.250'
MYGROUP_6 = 'ff15:7079:7468:6f6e:646... | 2,223 | 83 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/rpythond.py | #!/usr/bin/env python3
"""
Remote python server.
Execute Python commands remotely and send output back.
WARNING: This version has a gaping security hole -- it accepts requests
from any host on the Internet!
"""
import sys
from socket import socket, AF_INET, SOCK_STREAM
import io
import traceback
PORT = 4127
BUFSIZE... | 1,286 | 59 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/README | This directory contains a collection of demonstration scripts for
various aspects of Python programming.
beer.py Well-known programming example: Bottles of beer.
eiffel.py Python advanced magic: A metaclass for Eiffel post/preconditions.
hanoi.py Well-known programming example: Towers of Hanoi.
life.... | 1,014 | 16 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/queens.py | #!/usr/bin/env python3
"""
N queens problem.
The (well-known) problem is due to Niklaus Wirth.
This solution is inspired by Dijkstra (Structured Programming). It is
a classic recursive backtracking approach.
"""
N = 8 # Default; command line overrides
class Queens:
def __ini... | 2,270 | 86 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/rpython.py | #!/usr/bin/env python3
"""
Remote python client.
Execute Python commands remotely and send output back.
"""
import sys
from socket import socket, AF_INET, SOCK_STREAM, SHUT_WR
PORT = 4127
BUFSIZE = 1024
def main():
if len(sys.argv) < 3:
print("usage: rpython host command")
sys.exit(2)
host =... | 778 | 39 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/vector.py | #!/usr/bin/env python3
"""
A demonstration of classes and their special methods in Python.
"""
class Vec:
"""A simple vector class.
Instances of the Vec class can be constructed from numbers
>>> a = Vec(1, 2, 3)
>>> b = Vec(3, 2, 1)
added
>>> a + b
Vec(4, 4, 4)
subtracted
>>> a... | 1,452 | 75 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/demo/eiffel.py | #!/usr/bin/env python3
"""
Support Eiffel-style preconditions and postconditions for functions.
An example for Python metaclasses.
"""
import unittest
from types import FunctionType as function
class EiffelBaseMetaClass(type):
def __new__(meta, name, bases, dict):
meta.convert_methods(dict)
ret... | 3,906 | 147 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/gdb/libpython.py | #!/usr/bin/python
'''
From gdb 7 onwards, gdb's build can be configured --with-python, allowing gdb
to be extended with Python code e.g. for library-specific data visualizations,
such as for the C++ STL types. Documentation on this API can be seen at:
http://sourceware.org/gdb/current/onlinedocs/gdb/Python-API.html
... | 65,766 | 1,960 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/bkfile.py | from builtins import open as _orig_open
def open(file, mode='r', bufsize=-1):
if 'w' not in mode:
return _orig_open(file, mode, bufsize)
import os
backup = file + '~'
try:
os.unlink(backup)
except OSError:
pass
try:
os.rename(file, backup)
except OSError:
... | 664 | 27 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/makemakefile.py | # Write the actual Makefile.
import os
def makemakefile(outfp, makevars, files, target):
outfp.write("# Makefile generated by freeze.py script\n\n")
keys = sorted(makevars.keys())
for key in keys:
outfp.write("%s=%s\n" % (key, makevars[key]))
outfp.write("\nall: %s\n\n" % target)
deps = ... | 916 | 29 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/parsesetup.py | # Parse Makefiles and Python Setup(.in) files.
import re
# Extract variable definitions from a Makefile.
# Return a dictionary mapping names to values.
# May raise IOError.
makevardef = re.compile('^([a-zA-Z0-9_]+)[ \t]*=(.*)')
def getmakevars(filename):
variables = {}
fp = open(filename)
pendingline =... | 3,008 | 112 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/makefreeze.py | import marshal
import bkfile
# Write a file containing frozen code for the modules in the dictionary.
header = """
#include "third_party/python/Include/Python.h"
static struct _frozen _PyImport_FrozenModules[] = {
"""
trailer = """\
{0, 0, 0} /* sentinel */
};
"""
# if __debug__ == 0 (i.e. -O option given), se... | 2,799 | 88 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/flag.py | initialized = True
print("Hello world!")
| 41 | 3 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/README | THE FREEZE SCRIPT
=================
(Directions for Windows are at the end of this file.)
What is Freeze?
---------------
Freeze make it possible to ship arbitrary Python programs to people
who don't have Python. The shipped file (called a "frozen" version of
your Python program) is an executable, so this only wor... | 12,652 | 297 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/freeze.py | #! /usr/bin/env python3
"""Freeze a Python script into a binary.
usage: freeze [options...] script [module]...
Options:
-p prefix: This is the prefix used when you ran ``make install''
in the Python build directory.
(If you never ran this, freeze won't work.)
The default ... | 17,065 | 492 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/checkextensions.py | # Check for a module in a set of extension directories.
# An extension directory should contain a Setup file
# and one or more .o files or a lib.a file.
import os
import parsesetup
def checkextensions(unknown, extensions):
files = []
modules = []
edict = {}
for e in extensions:
setup = os.path... | 2,630 | 91 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/hello.py | print('Hello world...')
| 24 | 2 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/makeconfig.py | import re
import sys
# Write the config.c file
never = ['marshal', '_imp', '_ast', '__main__', 'builtins',
'sys', 'gc', '_warnings']
def makeconfig(infp, outfp, modules, with_ifdef=0):
m1 = re.compile('-- ADDMODULE MARKER 1 --')
m2 = re.compile('-- ADDMODULE MARKER 2 --')
for line in infp:
... | 1,665 | 60 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/winmakemakefile.py | import sys, os
# Template used then the program is a GUI program
WINMAINTEMPLATE = """
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmd... | 4,982 | 149 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/win32.html | <HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>win32</TITLE>
<META NAME="Version" CONTENT="8.0.3410">
<META NAME="Date" CONTENT="10/11/96">
<META NAME="Template" CONTENT="D:\Program Files\Microsoft Office\Office\HTML.DO... | 7,182 | 120 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/extensions_win32.ini | ; This is a list of modules generally build as .pyd files.
;
; Each section contains enough information about a module for
; freeze to include the module as a static, built-in module
; in a frozen .EXE/.DLL.
; This is all setup for all the win32 extension modules
; released by Mark Hammond.
; You must ensure that the ... | 3,992 | 172 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/checkextensions_win32.py | """Extension management for Windows.
Under Windows it is unlikely the .obj files are of use, as special compiler options
are needed (primarily to toggle the behavior of "public" symbols.
I don't consider it worth parsing the MSVC makefiles for compiler options. Even if
we get it just right, a specific freeze applica... | 6,227 | 189 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/freeze/test/ok.py | import sys
sys.exit(0)
| 23 | 3 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/i18n/pygettext.py | #! /usr/bin/env python3
# -*- coding: iso-8859-1 -*-
# Originally written by Barry Warsaw <barry@python.org>
#
# Minimally patched to make it even more xgettext compatible
# by Peter Funk <pf@artcom-gmbh.de>
#
# 2002-11-22 Jürgen Hermann <jh@web.de>
# Added checks that _() only contains string literals, and
# command l... | 21,549 | 632 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/i18n/makelocalealias.py | #!/usr/bin/env python3
"""
Convert the X11 locale.alias file into a mapping dictionary suitable
for locale.py.
Written by Marc-Andre Lemburg <mal@genix.com>, 2004-12-10.
"""
import locale
import sys
_locale = locale
# Location of the X11 alias file.
LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
# L... | 4,851 | 151 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/i18n/msgfmt.py | #! /usr/bin/env python3
# Written by Martin v. Löwis <loewis@informatik.hu-berlin.de>
"""Generate binary message catalog from textual translation description.
This program converts a textual Uniforum-style message catalog (.po file) into
a binary GNU catalog (.mo file). This is essentially the same function as the
... | 7,082 | 239 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/tz/zdump.py | import sys
import os
import struct
from array import array
from collections import namedtuple
from datetime import datetime, timedelta
ttinfo = namedtuple('ttinfo', ['tt_gmtoff', 'tt_isdst', 'tt_abbrind'])
class TZInfo:
def __init__(self, transitions, type_indices, ttis, abbrs):
self.transitions = transit... | 2,789 | 82 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/websafe.txt | # Websafe RGB values
#000000
#000033
#000066
#000099
#0000cc
#0000ff
#003300
#003333
#003366
#003399
#0033cc
#0033ff
#006600
#006633
#006666
#006699
#0066cc
#0066ff
#009900
#009933
#009966
#009999
#0099cc
#0099ff
#00cc00
#00cc33
#00cc66
#00cc99
#00cccc
#00ccff
#00ff00
#00ff33
#00ff66
#00ff99
#00ffcc
#00ffff
#330000
#33... | 1,749 | 218 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/ChipViewer.py | """Chip viewer and widget.
In the lower left corner of the main Pynche window, you will see two
ChipWidgets, one for the selected color and one for the nearest color. The
selected color is the actual RGB value expressed as an X11 #COLOR name. The
nearest color is the named color from the X11 database that is closest ... | 4,998 | 131 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/ListViewer.py | """ListViewer class.
This class implements an input/output view on the color model. It lists every
unique color (e.g. unique r/g/b value) found in the color database. Each
color is shown by small swatch and primary color name. Some colors have
aliases -- more than one name for the same r/g/b value. These aliases a... | 6,648 | 176 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/DetailsViewer.py | """DetailsViewer class.
This class implements a pure input window which allows you to meticulously
edit the current color. You have both mouse control of the color (via the
buttons along the bottom row), and there are keyboard bindings for each of the
increment/decrement buttons.
The top three check buttons allow yo... | 10,116 | 274 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/README | Pynche - The PYthonically Natural Color and Hue Editor
Contact: Barry A. Warsaw
Email: bwarsaw@python.org
Version: 1.3
Introduction
Pynche is a color editor based largely on a similar program that I
originally wrote back in 1987 for the Sunview window system. That
editor was called ICE, the Interactiv... | 15,774 | 399 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/TypeinViewer.py | """TypeinViewer class.
The TypeinViewer is what you see at the lower right of the main Pynche
widget. It contains three text entry fields, one each for red, green, blue.
Input into these windows is highly constrained; it only allows you to enter
values that are legal for a color axis. This usually means 0-255 for de... | 6,102 | 162 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/Switchboard.py | """Switchboard class.
This class is used to coordinate updates among all Viewers. Every Viewer must
conform to the following interface:
- it must include a method called update_yourself() which takes three
arguments; the red, green, and blue values of the selected color.
- When a Viewer selects a colo... | 4,797 | 139 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/pynche.pyw | #! /usr/bin/env python
"""Run this file under Windows to inhibit the console window.
Run the file pynche.py under Unix or when debugging under Windows.
"""
import Main
Main.main()
| 181 | 8 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/PyncheWidget.py | """Main Pynche (Pythonically Natural Color and Hue Editor) widget.
This window provides the basic decorations, primarily including the menubar.
It is used to bring up other windows.
"""
import sys
import os
from tkinter import *
from tkinter import messagebox, filedialog
import ColorDB
# Milliseconds between interru... | 10,615 | 314 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/namedcolors.txt | # named colors from http://www.lightlink.com/xine/bells/namedcolors.html
White #FFFFFF
Red #FF0000
Green #00FF00
Blue #0000FF
Magenta ... | 5,716 | 101 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/ColorDB.py | """Color Database.
This file contains one class, called ColorDB, and several utility functions.
The class must be instantiated by the get_colordb() function in this file,
passing it a filename to read a database out of.
The get_colordb() function will try to examine the file to figure out what the
format of the file ... | 8,773 | 272 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/Main.py | """Pynche -- The PYthon Natural Color and Hue Editor.
Contact: %(AUTHNAME)s
Email: %(AUTHEMAIL)s
Version: %(__version__)s
Pynche is based largely on a similar color editor I wrote years ago for the
SunView window system. That editor was called ICE: the Interactive Color
Editor. I'd always wanted to port the edito... | 6,406 | 230 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/webcolors.txt | # De-facto NS & MSIE recognized HTML color names
AliceBlue #f0f8ff
AntiqueWhite #faebd7
Aqua #00ffff
Aquamarine #7fffd4
Azure #f0ffff
Beige #f5f5dc
Bisque #ffe4c4
Black #000000
BlanchedAlmond #ffebcd
Blue #0000ff
BlueViolet #8a2be2
Brown #a52a2a
BurlyWood #deb887
Cade... | 3,088 | 142 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/TextViewer.py | """TextViewer class.
The TextViewer allows you to see how the selected color would affect various
characteristics of a Tk text widget. This is an output viewer only.
In the top part of the window is a standard text widget with some sample text
in it. You are free to edit this text in any way you want (BAW: allow yo... | 6,869 | 189 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/html40colors.txt | # HTML 4.0 color names
Black #000000
Silver #c0c0c0
Gray #808080
White #ffffff
Maroon #800000
Red #ff0000
Purple #800080
Fuchsia #ff00ff
Green #008000
Lime #00ff00
Olive #808000
Yellow #ffff00
Navy #000080
Blue #0000ff
Teal #008080
Aqua #00ffff
| 245 | 18 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/pynche | #! /usr/bin/env python
"""Run this file under Unix, or when debugging under Windows.
Run the file pynche.pyw under Windows to inhibit the console window.
"""
import Main
Main.main()
| 183 | 8 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/StripViewer.py | """Strip viewer and related widgets.
The classes in this file implement the StripViewer shown in the top two thirds
of the main Pynche window. It consists of three StripWidgets which display
the variations in red, green, and blue respectively of the currently selected
r/g/b color value.
Each StripWidget shows the co... | 15,477 | 434 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/__init__.py | # Dummy file to make this directory a package.
| 47 | 2 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/pyColorChooser.py | """Color chooser implementing (almost) the tkColorColor interface
"""
import os
import Main
import ColorDB
class Chooser:
"""Ask for a color"""
def __init__(self,
master = None,
databasefile = None,
initfile = None,
ignore = None,
... | 3,759 | 126 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/X/rgb.txt | ! $XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp $
255 250 250 snow
248 248 255 ghost white
248 248 255 GhostWhite
245 245 245 white smoke
245 245 245 WhiteSmoke
220 220 220 gainsboro
255 250 240 floral white
255 250 240 FloralWhite
253 245 230 old lace
253 245 230 OldLace
250 240 230 linen
250 235 ... | 17,375 | 754 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pynche/X/xlicense.txt | X Window System License - X11R6.4
Copyright (c) 1998 The Open Group
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modi... | 1,352 | 30 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pybench/With.py | from pybench import Test
class WithFinally(Test):
version = 2.0
operations = 20
rounds = 80000
class ContextManager(object):
def __enter__(self):
pass
def __exit__(self, exc, val, tb):
pass
def test(self):
cm = self.ContextManager()
for i... | 4,096 | 190 | jart/cosmopolitan | false |
cosmopolitan/third_party/python/Tools/pybench/LICENSE | pybench License
---------------
This copyright notice and license applies to all files in the pybench
directory of the pybench distribution.
Copyright (c), 1997-2006, Marc-Andre Lemburg (mal@lemburg.com)
Copyright (c), 2000-2006, eGenix.com Software GmbH (info@egenix.com)
All Rights Reserved.
Per... | 1,146 | 26 | jart/cosmopolitan | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.