pyflyby 1.9.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pyflyby might be problematic. Click here for more details.
- pyflyby/__init__.py +56 -0
- pyflyby/__main__.py +9 -0
- pyflyby/_autoimp.py +2114 -0
- pyflyby/_cmdline.py +531 -0
- pyflyby/_comms.py +221 -0
- pyflyby/_dbg.py +1339 -0
- pyflyby/_docxref.py +379 -0
- pyflyby/_file.py +738 -0
- pyflyby/_flags.py +230 -0
- pyflyby/_format.py +182 -0
- pyflyby/_idents.py +233 -0
- pyflyby/_import_sorting.py +165 -0
- pyflyby/_importclns.py +642 -0
- pyflyby/_importdb.py +588 -0
- pyflyby/_imports2s.py +639 -0
- pyflyby/_importstmt.py +662 -0
- pyflyby/_interactive.py +2605 -0
- pyflyby/_livepatch.py +793 -0
- pyflyby/_log.py +199 -0
- pyflyby/_modules.py +515 -0
- pyflyby/_parse.py +1441 -0
- pyflyby/_py.py +2078 -0
- pyflyby/_util.py +459 -0
- pyflyby/_version.py +7 -0
- pyflyby/autoimport.py +20 -0
- pyflyby/importdb.py +19 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/canonical.py +10 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/common.py +27 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/forget.py +10 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/mandatory.py +10 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/numpy.py +156 -0
- pyflyby-1.9.4.data/data/etc/pyflyby/std.py +335 -0
- pyflyby-1.9.4.data/data/libexec/pyflyby/colordiff +34 -0
- pyflyby-1.9.4.data/data/libexec/pyflyby/diff-colorize +148 -0
- pyflyby-1.9.4.data/data/share/doc/pyflyby/LICENSE.txt +23 -0
- pyflyby-1.9.4.data/data/share/doc/pyflyby/TODO.txt +115 -0
- pyflyby-1.9.4.data/data/share/doc/pyflyby/testing.txt +13 -0
- pyflyby-1.9.4.data/data/share/emacs/site-lisp/pyflyby.el +108 -0
- pyflyby-1.9.4.data/scripts/collect-exports +76 -0
- pyflyby-1.9.4.data/scripts/collect-imports +58 -0
- pyflyby-1.9.4.data/scripts/find-import +38 -0
- pyflyby-1.9.4.data/scripts/list-bad-xrefs +34 -0
- pyflyby-1.9.4.data/scripts/prune-broken-imports +34 -0
- pyflyby-1.9.4.data/scripts/pyflyby-diff +34 -0
- pyflyby-1.9.4.data/scripts/reformat-imports +27 -0
- pyflyby-1.9.4.data/scripts/replace-star-imports +37 -0
- pyflyby-1.9.4.data/scripts/tidy-imports +191 -0
- pyflyby-1.9.4.data/scripts/transform-imports +47 -0
- pyflyby-1.9.4.dist-info/LICENSE.txt +23 -0
- pyflyby-1.9.4.dist-info/METADATA +507 -0
- pyflyby-1.9.4.dist-info/RECORD +54 -0
- pyflyby-1.9.4.dist-info/WHEEL +5 -0
- pyflyby-1.9.4.dist-info/entry_points.txt +3 -0
- pyflyby-1.9.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import matplotlib
|
|
2
|
+
from matplotlib import pyplot
|
|
3
|
+
import matplotlib.colors
|
|
4
|
+
from matplotlib.colors import ColorConverter
|
|
5
|
+
from matplotlib.font_manager import FontProperties
|
|
6
|
+
from matplotlib.patches import Rectangle
|
|
7
|
+
from matplotlib.pyplot import (clf, draw, figure, gca, gcf, ioff,
|
|
8
|
+
legend, plot, savefig, scatter, show,
|
|
9
|
+
subplot, title, xlabel, ylabel, ylim)
|
|
10
|
+
from matplotlib.ticker import (Formatter, Locator, NullFormatter,
|
|
11
|
+
NullLocator)
|
|
12
|
+
import numexpr
|
|
13
|
+
import numpy as np, numpy as npy, numpy
|
|
14
|
+
from numpy import (Inf, NAN, NaN, abs as aabs, absolute,
|
|
15
|
+
add, all as aall, allclose, alltrue,
|
|
16
|
+
amax, amin, angle, any as aany,
|
|
17
|
+
append as aappend, apply_along_axis,
|
|
18
|
+
apply_over_axes, arange, arccos,
|
|
19
|
+
arccosh, arcsin, arcsinh, arctan,
|
|
20
|
+
arctan2, arctanh, argmax, argmin,
|
|
21
|
+
argsort, argwhere, around, array,
|
|
22
|
+
array2string, array_equal, array_equiv,
|
|
23
|
+
array_repr, array_split, array_str,
|
|
24
|
+
asanyarray, asarray, asarray_chkfinite,
|
|
25
|
+
ascontiguousarray, asfarray,
|
|
26
|
+
asfortranarray, asmatrix, asscalar,
|
|
27
|
+
atleast_1d, atleast_2d, atleast_3d,
|
|
28
|
+
average, bartlett, base_repr,
|
|
29
|
+
binary_repr, bincount, bitwise_and,
|
|
30
|
+
bitwise_not, bitwise_or, bitwise_xor,
|
|
31
|
+
blackman, bmat, bool8, bool_,
|
|
32
|
+
broadcast, broadcast_arrays, byte,
|
|
33
|
+
byte_bounds, c_, can_cast, cdouble,
|
|
34
|
+
ceil, cfloat, character, chararray,
|
|
35
|
+
choose, clip, clongdouble, clongfloat,
|
|
36
|
+
column_stack, common_type,
|
|
37
|
+
compare_chararrays, compat, complex128,
|
|
38
|
+
complex64, complex_, complexfloating,
|
|
39
|
+
concatenate, conj, conjugate, convolve,
|
|
40
|
+
copy, copysign, corrcoef, correlate,
|
|
41
|
+
cos, cosh, cov, cross, csingle,
|
|
42
|
+
ctypeslib, cumprod, cumproduct, cumsum,
|
|
43
|
+
deg2rad, degrees, diag, diag_indices,
|
|
44
|
+
diag_indices_from, diagflat, diagonal,
|
|
45
|
+
diff, digitize, disp, divide, dot,
|
|
46
|
+
double, dsplit, dstack, dtype, ediff1d,
|
|
47
|
+
einsum, emath, empty, empty_like,
|
|
48
|
+
equal, exp, exp2, expand_dims, expm1,
|
|
49
|
+
extract, eye, fabs,
|
|
50
|
+
fastCopyAndTranspose, fill_diagonal,
|
|
51
|
+
find_common_type, fix, flatiter,
|
|
52
|
+
flatnonzero, fliplr, flipud, float32,
|
|
53
|
+
float64, float_, floating, floor,
|
|
54
|
+
floor_divide, fmax, fmin, fmod, frexp,
|
|
55
|
+
frombuffer, fromfile, fromfunction,
|
|
56
|
+
fromiter, frompyfunc, fromregex,
|
|
57
|
+
fromstring, gradient, greater,
|
|
58
|
+
greater_equal, hamming, hanning,
|
|
59
|
+
heaviside, histogram, histogram2d,
|
|
60
|
+
histogramdd, hsplit, hstack, hypot,
|
|
61
|
+
i0, identity, iinfo, imag, in1d,
|
|
62
|
+
index_exp, indices, inexact, inf,
|
|
63
|
+
inner, int0, int16, int32, int64,
|
|
64
|
+
int8, int_, intc, integer, interp,
|
|
65
|
+
intersect1d, intp, invert, ipmt, irr,
|
|
66
|
+
iscomplex, iscomplexobj, isfinite,
|
|
67
|
+
isfortran, isinf, isnan, isneginf,
|
|
68
|
+
isposinf, isreal, isrealobj, isscalar,
|
|
69
|
+
issctype, issubclass_, issubdtype,
|
|
70
|
+
issubsctype, iterable, ix_, kaiser,
|
|
71
|
+
kron, ldexp, left_shift, less,
|
|
72
|
+
less_equal, lexsort, linalg, linspace,
|
|
73
|
+
little_endian, loadtxt, log,
|
|
74
|
+
log as logarithm, log10, log1p, log2,
|
|
75
|
+
logaddexp, logaddexp2, logical_and,
|
|
76
|
+
logical_not, logical_or, logical_xor,
|
|
77
|
+
logspace, longcomplex, longdouble,
|
|
78
|
+
longfloat, longlong, mafromtxt,
|
|
79
|
+
mask_indices, mat, matrix, maximum,
|
|
80
|
+
mean, median, memmap, meshgrid, mgrid,
|
|
81
|
+
minimum, mintypecode, mirr, mod, modf,
|
|
82
|
+
msort, multiply, nan, nan_to_num,
|
|
83
|
+
nanargmax, nanargmin, nanmax, nanmin,
|
|
84
|
+
nansum, nbytes, ndarray, ndenumerate,
|
|
85
|
+
ndim, ndindex, negative, newaxis,
|
|
86
|
+
newbuffer, nextafter, nonzero,
|
|
87
|
+
not_equal, nper, npv, number, object0,
|
|
88
|
+
object_, ogrid, ones, ones_like,
|
|
89
|
+
outer, packbits, pi, piecewise,
|
|
90
|
+
pkgload, place, pmt, poly, poly1d,
|
|
91
|
+
polyadd, polyder, polydiv, polyfit,
|
|
92
|
+
polyint, polymul, polynomial, polysub,
|
|
93
|
+
polyval, power, ppmt, prod, product,
|
|
94
|
+
ptp, putmask, pv, r_, rad2deg,
|
|
95
|
+
radians, rank, rate, ravel, real,
|
|
96
|
+
real_if_close, recarray, recfromcsv,
|
|
97
|
+
recfromtxt, reciprocal, record,
|
|
98
|
+
remainder, repeat, reshape, resize,
|
|
99
|
+
restoredot, right_shift, rint, roll,
|
|
100
|
+
rollaxis, roots, rot90, round, round_,
|
|
101
|
+
row_stack, s_, searchsorted,
|
|
102
|
+
select as aselect, setbufsize,
|
|
103
|
+
setdiff1d, setxor1d, shape, short,
|
|
104
|
+
show_config, sign, signbit,
|
|
105
|
+
signedinteger, sin, sinc, single,
|
|
106
|
+
singlecomplex, sinh, size as asize,
|
|
107
|
+
sometrue, sort as asort, sort,
|
|
108
|
+
sort_complex, spacing, split, sqrt,
|
|
109
|
+
square, squeeze, std, str_, string0,
|
|
110
|
+
string_, subtract, sum, swapaxes, take,
|
|
111
|
+
tan, tanh, tensordot, testing, tile,
|
|
112
|
+
trace, transpose, trapz, tri, tril,
|
|
113
|
+
tril_indices, tril_indices_from,
|
|
114
|
+
trim_zeros, triu, triu_indices,
|
|
115
|
+
triu_indices_from, true_divide, trunc,
|
|
116
|
+
ubyte, ufunc, uint, uint0, uint16,
|
|
117
|
+
uint32, uint64, uint8, uintc, uintp,
|
|
118
|
+
ulonglong, unicode0, unicode_, union1d,
|
|
119
|
+
unique, unpackbits, unravel_index,
|
|
120
|
+
unsignedinteger, unwrap, ushort,
|
|
121
|
+
vander, var, vdot, vectorize, void,
|
|
122
|
+
void0, vsplit, vstack, where, zeros,
|
|
123
|
+
zeros_like)
|
|
124
|
+
from numpy.core.umath_tests import inner1d
|
|
125
|
+
from numpy.fft import (fft, fft2, fftn, ifft, ifft2, ifftn,
|
|
126
|
+
irfft, irfft2, irfftn, rfft, rfft2,
|
|
127
|
+
rfftn)
|
|
128
|
+
from numpy.lib import recfunctions as recf, recfunctions
|
|
129
|
+
from numpy.lib.stride_tricks import as_strided
|
|
130
|
+
import numpy.linalg
|
|
131
|
+
from numpy.linalg import cholesky, det, eigh, inv, pinv, svd
|
|
132
|
+
from numpy.random import (normal, rand, randint, randn,
|
|
133
|
+
random as arandom, shuffle)
|
|
134
|
+
import numpy.testing
|
|
135
|
+
import numpy.version
|
|
136
|
+
import pandas, pandas as pd
|
|
137
|
+
from pandas import DataFrame, Series, TimeSeries
|
|
138
|
+
import pylab as pl, pylab
|
|
139
|
+
import scipy
|
|
140
|
+
from scipy import integrate, optimize, special, stats
|
|
141
|
+
import scipy.cluster.hierarchy
|
|
142
|
+
import scipy.integrate
|
|
143
|
+
import scipy.interpolate
|
|
144
|
+
from scipy.interpolate import InterpolatedUnivariateSpline, interp1d
|
|
145
|
+
import scipy.linalg
|
|
146
|
+
import scipy.optimize
|
|
147
|
+
from scipy.optimize import (curve_fit, fmin_l_bfgs_b, fsolve,
|
|
148
|
+
leastsq)
|
|
149
|
+
from scipy.optimize.zeros import bisect
|
|
150
|
+
import scipy.special
|
|
151
|
+
from scipy.special import gamma, gammainc, gammaincinv, ndtri
|
|
152
|
+
import scipy.stats
|
|
153
|
+
from scipy.stats import (chisqprob, distributions,
|
|
154
|
+
scoreatpercentile, uniform)
|
|
155
|
+
from scipy.stats.distributions \
|
|
156
|
+
import norm
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import UserDict
|
|
2
|
+
from UserDict import DictMixin
|
|
3
|
+
from UserList import UserList
|
|
4
|
+
from _strptime import TimeRE
|
|
5
|
+
import abc
|
|
6
|
+
import argparse
|
|
7
|
+
import ast
|
|
8
|
+
import atexit
|
|
9
|
+
import base64
|
|
10
|
+
from base64 import b64decode, b64encode
|
|
11
|
+
import binascii
|
|
12
|
+
from binascii import hexlify, unhexlify
|
|
13
|
+
import bisect
|
|
14
|
+
import bootstrap
|
|
15
|
+
import bz2
|
|
16
|
+
import cProfile
|
|
17
|
+
import cgi
|
|
18
|
+
import collections
|
|
19
|
+
from collections import defaultdict, deque, namedtuple
|
|
20
|
+
import collections.abc
|
|
21
|
+
from collections.abc import Collection, Iterable, Iterator, Sequence
|
|
22
|
+
import commands
|
|
23
|
+
import contextlib
|
|
24
|
+
from contextlib import closing, contextmanager, nested
|
|
25
|
+
import copy
|
|
26
|
+
import csv
|
|
27
|
+
import ctypes
|
|
28
|
+
from ctypes import CDLL
|
|
29
|
+
import datetime
|
|
30
|
+
import decimal
|
|
31
|
+
from decimal import Decimal
|
|
32
|
+
import decorator
|
|
33
|
+
import difflib
|
|
34
|
+
from difflib import SequenceMatcher, context_diff
|
|
35
|
+
import dis
|
|
36
|
+
import email
|
|
37
|
+
from email import encoders
|
|
38
|
+
from email.encoders import encode_base64
|
|
39
|
+
from email.message import Message
|
|
40
|
+
from email.mime.audio import MIMEAudio
|
|
41
|
+
from email.utils import COMMASPACE, formatdate
|
|
42
|
+
import errno
|
|
43
|
+
from errno import (E2BIG, EACCES, EADDRINUSE,
|
|
44
|
+
EADDRNOTAVAIL, EAFNOSUPPORT, EAGAIN,
|
|
45
|
+
EALREADY, EBADF, EBADMSG, EBUSY,
|
|
46
|
+
ECHILD, ECONNABORTED, ECONNREFUSED,
|
|
47
|
+
ECONNRESET, EDEADLK, EDESTADDRREQ,
|
|
48
|
+
EDOM, EDQUOT, EEXIST, EFAULT, EFBIG,
|
|
49
|
+
EHOSTDOWN, EHOSTUNREACH, EIDRM, EILSEQ,
|
|
50
|
+
EINPROGRESS, EINTR, EINVAL, EIO,
|
|
51
|
+
EISCONN, EISDIR, ELOOP, EMFILE, EMLINK,
|
|
52
|
+
EMSGSIZE, EMULTIHOP, ENAMETOOLONG,
|
|
53
|
+
ENETDOWN, ENETRESET, ENETUNREACH,
|
|
54
|
+
ENFILE, ENOBUFS, ENODATA, ENODEV,
|
|
55
|
+
ENOENT, ENOEXEC, ENOLCK, ENOLINK,
|
|
56
|
+
ENOMEM, ENOMSG, ENOPROTOOPT, ENOSPC,
|
|
57
|
+
ENOSR, ENOSTR, ENOSYS, ENOTBLK,
|
|
58
|
+
ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTSOCK,
|
|
59
|
+
ENOTSUP, ENOTTY, ENXIO, EOPNOTSUPP,
|
|
60
|
+
EOVERFLOW, EPERM, EPFNOSUPPORT, EPIPE,
|
|
61
|
+
EPROTO, EPROTONOSUPPORT, EPROTOTYPE,
|
|
62
|
+
ERANGE, EREMOTE, EROFS, ESHUTDOWN,
|
|
63
|
+
ESOCKTNOSUPPORT, ESPIPE, ESRCH, ESTALE,
|
|
64
|
+
ETIME, ETIMEDOUT, ETOOMANYREFS,
|
|
65
|
+
ETXTBSY, EUSERS, EWOULDBLOCK, EXDEV)
|
|
66
|
+
import exceptions
|
|
67
|
+
import fcntl
|
|
68
|
+
import filecmp
|
|
69
|
+
import fileinput
|
|
70
|
+
import functional
|
|
71
|
+
import functools
|
|
72
|
+
from functools import (partial, reduce, total_ordering,
|
|
73
|
+
update_wrapper, wraps)
|
|
74
|
+
import gc
|
|
75
|
+
import getpass
|
|
76
|
+
from getpass import getuser
|
|
77
|
+
import glob
|
|
78
|
+
import grp
|
|
79
|
+
from grp import getgrall, getgrgid, getgrnam
|
|
80
|
+
import gzip
|
|
81
|
+
import h5py
|
|
82
|
+
import hashlib
|
|
83
|
+
from hashlib import (md5, sha1, sha224, sha256, sha384,
|
|
84
|
+
sha512)
|
|
85
|
+
import heapq
|
|
86
|
+
import imp
|
|
87
|
+
import inspect
|
|
88
|
+
from inspect import ArgSpec, getargspec
|
|
89
|
+
import io
|
|
90
|
+
import itertools
|
|
91
|
+
from itertools import (chain, count, groupby, islice, product,
|
|
92
|
+
repeat, tee)
|
|
93
|
+
import json
|
|
94
|
+
from keyword import iskeyword
|
|
95
|
+
import linecache
|
|
96
|
+
import locale
|
|
97
|
+
import logging
|
|
98
|
+
from lxml import etree
|
|
99
|
+
import marshal
|
|
100
|
+
import math
|
|
101
|
+
import matplotlib
|
|
102
|
+
import mimetypes
|
|
103
|
+
import misc.double
|
|
104
|
+
import mmap
|
|
105
|
+
import new
|
|
106
|
+
import numbers
|
|
107
|
+
from numbers import (Complex, Integral, Number, Rational,
|
|
108
|
+
Real)
|
|
109
|
+
import operator
|
|
110
|
+
from operator import add, indexOf, itemgetter, mul
|
|
111
|
+
import optparse
|
|
112
|
+
from optparse import (BadOptionError, OptParseError,
|
|
113
|
+
OptionParser, OptionValueError)
|
|
114
|
+
import os
|
|
115
|
+
from os import (chmod, close, getcwd, getenv, geteuid,
|
|
116
|
+
getpid, getuid, makedirs, mkdir,
|
|
117
|
+
mkfifo, path, remove, rename, system,
|
|
118
|
+
unlink)
|
|
119
|
+
import os.path
|
|
120
|
+
from os.path import (abspath, basename, dirname, exists,
|
|
121
|
+
getsize, isfile, normpath, realpath)
|
|
122
|
+
import parser
|
|
123
|
+
import pdb
|
|
124
|
+
import pickle
|
|
125
|
+
from pickle import PickleError, UnpicklingError
|
|
126
|
+
import pickletools
|
|
127
|
+
import pkg_resources
|
|
128
|
+
from pkg_resources import load_entry_point
|
|
129
|
+
import pkgutil
|
|
130
|
+
import pprint
|
|
131
|
+
import psutil
|
|
132
|
+
import pwd
|
|
133
|
+
from pwd import getpwall, getpwnam, getpwuid
|
|
134
|
+
import random
|
|
135
|
+
from random import shuffle
|
|
136
|
+
import re
|
|
137
|
+
import resource
|
|
138
|
+
import select
|
|
139
|
+
import shlex
|
|
140
|
+
import shutil
|
|
141
|
+
from shutil import (copyfile, copyfileobj, copystat,
|
|
142
|
+
copytree, rmtree)
|
|
143
|
+
import signal
|
|
144
|
+
import six
|
|
145
|
+
from io import StringIO
|
|
146
|
+
from six.moves import (builtins, cPickle, configparser,
|
|
147
|
+
copyreg, email_mime_base,
|
|
148
|
+
email_mime_image, email_mime_multipart,
|
|
149
|
+
email_mime_text, http_client, map,
|
|
150
|
+
queue, zip)
|
|
151
|
+
from urllib.parse import urlencode
|
|
152
|
+
from six.moves.urllib.request import urlopen
|
|
153
|
+
import smtplib
|
|
154
|
+
from smtplib import (SMTP, SMTPAuthenticationError,
|
|
155
|
+
SMTPConnectError, SMTPDataError,
|
|
156
|
+
SMTPException, SMTPHeloError,
|
|
157
|
+
SMTPRecipientsRefused,
|
|
158
|
+
SMTPResponseException,
|
|
159
|
+
SMTPSenderRefused,
|
|
160
|
+
SMTPServerDisconnected, SMTP_SSL)
|
|
161
|
+
import socket
|
|
162
|
+
from socket import (AF_APPLETALK, AF_ASH, AF_ATMPVC,
|
|
163
|
+
AF_ATMSVC, AF_AX25, AF_BRIDGE,
|
|
164
|
+
AF_DECnet, AF_ECONET, AF_INET,
|
|
165
|
+
AF_INET6, AF_IPX, AF_IRDA, AF_KEY,
|
|
166
|
+
AF_LLC, AF_NETBEUI, AF_NETLINK,
|
|
167
|
+
AF_NETROM, AF_PACKET, AF_PPPOX,
|
|
168
|
+
AF_ROSE, AF_ROUTE, AF_SECURITY, AF_SNA,
|
|
169
|
+
AF_TIPC, AF_UNIX, AF_UNSPEC,
|
|
170
|
+
AF_WANPIPE, AF_X25, AI_ADDRCONFIG,
|
|
171
|
+
AI_ALL, AI_CANONNAME, AI_NUMERICHOST,
|
|
172
|
+
AI_NUMERICSERV, AI_PASSIVE,
|
|
173
|
+
AI_V4MAPPED, CAPI, EAI_ADDRFAMILY,
|
|
174
|
+
EAI_AGAIN, EAI_BADFLAGS, EAI_FAIL,
|
|
175
|
+
EAI_FAMILY, EAI_MEMORY, EAI_NODATA,
|
|
176
|
+
EAI_NONAME, EAI_OVERFLOW, EAI_SERVICE,
|
|
177
|
+
EAI_SOCKTYPE, EAI_SYSTEM,
|
|
178
|
+
INADDR_ALLHOSTS_GROUP, INADDR_ANY,
|
|
179
|
+
INADDR_BROADCAST, INADDR_LOOPBACK,
|
|
180
|
+
INADDR_MAX_LOCAL_GROUP, INADDR_NONE,
|
|
181
|
+
INADDR_UNSPEC_GROUP, IPPORT_RESERVED,
|
|
182
|
+
IPPORT_USERRESERVED, IPPROTO_AH,
|
|
183
|
+
IPPROTO_DSTOPTS, IPPROTO_EGP,
|
|
184
|
+
IPPROTO_ESP, IPPROTO_FRAGMENT,
|
|
185
|
+
IPPROTO_GRE, IPPROTO_HOPOPTS,
|
|
186
|
+
IPPROTO_ICMP, IPPROTO_ICMPV6,
|
|
187
|
+
IPPROTO_IDP, IPPROTO_IGMP, IPPROTO_IP,
|
|
188
|
+
IPPROTO_IPIP, IPPROTO_IPV6,
|
|
189
|
+
IPPROTO_NONE, IPPROTO_PIM, IPPROTO_PUP,
|
|
190
|
+
IPPROTO_RAW, IPPROTO_ROUTING,
|
|
191
|
+
IPPROTO_RSVP, IPPROTO_TCP, IPPROTO_TP,
|
|
192
|
+
IPPROTO_UDP, IPV6_CHECKSUM,
|
|
193
|
+
IPV6_DSTOPTS, IPV6_HOPLIMIT,
|
|
194
|
+
IPV6_HOPOPTS, IPV6_JOIN_GROUP,
|
|
195
|
+
IPV6_LEAVE_GROUP, IPV6_MULTICAST_HOPS,
|
|
196
|
+
IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP,
|
|
197
|
+
IPV6_NEXTHOP, IPV6_PKTINFO,
|
|
198
|
+
IPV6_RECVDSTOPTS, IPV6_RECVHOPLIMIT,
|
|
199
|
+
IPV6_RECVHOPOPTS, IPV6_RECVPKTINFO,
|
|
200
|
+
IPV6_RECVRTHDR, IPV6_RECVTCLASS,
|
|
201
|
+
IPV6_RTHDR, IPV6_RTHDRDSTOPTS,
|
|
202
|
+
IPV6_RTHDR_TYPE_0, IPV6_TCLASS,
|
|
203
|
+
IPV6_UNICAST_HOPS, IPV6_V6ONLY,
|
|
204
|
+
IP_ADD_MEMBERSHIP,
|
|
205
|
+
IP_DEFAULT_MULTICAST_LOOP,
|
|
206
|
+
IP_DEFAULT_MULTICAST_TTL,
|
|
207
|
+
IP_DROP_MEMBERSHIP, IP_HDRINCL,
|
|
208
|
+
IP_MAX_MEMBERSHIPS, IP_MULTICAST_IF,
|
|
209
|
+
IP_MULTICAST_LOOP, IP_MULTICAST_TTL,
|
|
210
|
+
IP_OPTIONS, IP_RECVOPTS,
|
|
211
|
+
IP_RECVRETOPTS, IP_RETOPTS, IP_TOS,
|
|
212
|
+
IP_TTL, MSG_CTRUNC, MSG_DONTROUTE,
|
|
213
|
+
MSG_DONTWAIT, MSG_EOR, MSG_OOB,
|
|
214
|
+
MSG_PEEK, MSG_TRUNC, MSG_WAITALL,
|
|
215
|
+
NETLINK_DNRTMSG, NETLINK_FIREWALL,
|
|
216
|
+
NETLINK_IP6_FW, NETLINK_NFLOG,
|
|
217
|
+
NETLINK_ROUTE, NETLINK_USERSOCK,
|
|
218
|
+
NETLINK_XFRM, NI_DGRAM, NI_MAXHOST,
|
|
219
|
+
NI_MAXSERV, NI_NAMEREQD, NI_NOFQDN,
|
|
220
|
+
NI_NUMERICHOST, NI_NUMERICSERV,
|
|
221
|
+
PACKET_BROADCAST, PACKET_FASTROUTE,
|
|
222
|
+
PACKET_HOST, PACKET_LOOPBACK,
|
|
223
|
+
PACKET_MULTICAST, PACKET_OTHERHOST,
|
|
224
|
+
PACKET_OUTGOING, PF_PACKET, SHUT_RD,
|
|
225
|
+
SHUT_RDWR, SHUT_WR, SOCK_DGRAM,
|
|
226
|
+
SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET,
|
|
227
|
+
SOCK_STREAM, SOL_IP, SOL_SOCKET,
|
|
228
|
+
SOL_TCP, SOL_TIPC, SOL_UDP, SOMAXCONN,
|
|
229
|
+
SO_ACCEPTCONN, SO_ATTACH_FILTER,
|
|
230
|
+
SO_BINDTODEVICE, SO_BROADCAST,
|
|
231
|
+
SO_BSDCOMPAT, SO_DEBUG,
|
|
232
|
+
SO_DETACH_FILTER, SO_DONTROUTE,
|
|
233
|
+
SO_ERROR, SO_KEEPALIVE, SO_LINGER,
|
|
234
|
+
SO_NO_CHECK, SO_OOBINLINE, SO_PASSCRED,
|
|
235
|
+
SO_PASSSEC, SO_PEERCRED, SO_PEERNAME,
|
|
236
|
+
SO_PEERSEC, SO_PRIORITY, SO_RCVBUF,
|
|
237
|
+
SO_RCVBUFFORCE, SO_RCVLOWAT,
|
|
238
|
+
SO_RCVTIMEO, SO_REUSEADDR,
|
|
239
|
+
SO_SECURITY_AUTHENTICATION,
|
|
240
|
+
SO_SECURITY_ENCRYPTION_NETWORK,
|
|
241
|
+
SO_SECURITY_ENCRYPTION_TRANSPORT,
|
|
242
|
+
SO_SNDBUF, SO_SNDBUFFORCE, SO_SNDLOWAT,
|
|
243
|
+
SO_SNDTIMEO, SO_TIMESTAMP,
|
|
244
|
+
SO_TIMESTAMPNS, SO_TYPE, SocketType,
|
|
245
|
+
TCP_CONGESTION, TCP_CORK,
|
|
246
|
+
TCP_DEFER_ACCEPT, TCP_INFO,
|
|
247
|
+
TCP_KEEPCNT, TCP_KEEPIDLE,
|
|
248
|
+
TCP_KEEPINTVL, TCP_LINGER2, TCP_MAXSEG,
|
|
249
|
+
TCP_MD5SIG, TCP_MD5SIG_MAXKEYLEN,
|
|
250
|
+
TCP_NODELAY, TCP_QUICKACK, TCP_SYNCNT,
|
|
251
|
+
TCP_WINDOW_CLAMP, TIPC_ADDR_ID,
|
|
252
|
+
TIPC_ADDR_NAME, TIPC_ADDR_NAMESEQ,
|
|
253
|
+
TIPC_CFG_SRV, TIPC_CLUSTER_SCOPE,
|
|
254
|
+
TIPC_CONN_TIMEOUT,
|
|
255
|
+
TIPC_CRITICAL_IMPORTANCE,
|
|
256
|
+
TIPC_DEST_DROPPABLE,
|
|
257
|
+
TIPC_HIGH_IMPORTANCE, TIPC_IMPORTANCE,
|
|
258
|
+
TIPC_LOW_IMPORTANCE,
|
|
259
|
+
TIPC_MEDIUM_IMPORTANCE,
|
|
260
|
+
TIPC_NODE_SCOPE, TIPC_PUBLISHED,
|
|
261
|
+
TIPC_SRC_DROPPABLE,
|
|
262
|
+
TIPC_SUBSCR_TIMEOUT, TIPC_SUB_CANCEL,
|
|
263
|
+
TIPC_SUB_PORTS, TIPC_SUB_SERVICE,
|
|
264
|
+
TIPC_TOP_SRV, TIPC_WAIT_FOREVER,
|
|
265
|
+
TIPC_WITHDRAWN, TIPC_ZONE_SCOPE,
|
|
266
|
+
gaierror, getaddrinfo, getfqdn,
|
|
267
|
+
gethostbyaddr, gethostbyname,
|
|
268
|
+
gethostbyname_ex, gethostname,
|
|
269
|
+
getnameinfo, getprotobyname,
|
|
270
|
+
getservbyname, getservbyport, htonl,
|
|
271
|
+
htons, inet_aton, inet_ntoa, inet_ntop,
|
|
272
|
+
inet_pton, ntohl, ntohs,
|
|
273
|
+
setdefaulttimeout, socketpair)
|
|
274
|
+
import sqlite3
|
|
275
|
+
import ssl
|
|
276
|
+
import stat
|
|
277
|
+
from stat import (ST_MTIME, S_IFMT, S_IMODE, S_ISBLK,
|
|
278
|
+
S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK,
|
|
279
|
+
S_ISREG, S_ISSOCK)
|
|
280
|
+
import string
|
|
281
|
+
import struct
|
|
282
|
+
import subprocess
|
|
283
|
+
from subprocess import (CalledProcessError, PIPE, Popen, call,
|
|
284
|
+
check_call)
|
|
285
|
+
import symbol
|
|
286
|
+
import sys
|
|
287
|
+
from sys import exit, getsizeof, stderr, stdout
|
|
288
|
+
import tempfile
|
|
289
|
+
from tempfile import (NamedTemporaryFile,
|
|
290
|
+
SpooledTemporaryFile, TemporaryFile,
|
|
291
|
+
mkdtemp, mkstemp, mktemp)
|
|
292
|
+
import termios
|
|
293
|
+
import textwrap
|
|
294
|
+
from textwrap import dedent
|
|
295
|
+
import threading
|
|
296
|
+
from threading import (BoundedSemaphore, Condition, Lock,
|
|
297
|
+
RLock, Semaphore, Thread, Timer,
|
|
298
|
+
currentThread, current_thread)
|
|
299
|
+
import time
|
|
300
|
+
from time import (asctime, ctime, gmtime, localtime,
|
|
301
|
+
mktime, sleep, strftime, strptime)
|
|
302
|
+
import timeit
|
|
303
|
+
import token
|
|
304
|
+
import traceback
|
|
305
|
+
import types
|
|
306
|
+
from types import (BooleanType, BufferType,
|
|
307
|
+
BuiltinFunctionType, BuiltinMethodType,
|
|
308
|
+
ClassType, CodeType, ComplexType,
|
|
309
|
+
DictProxyType, DictType,
|
|
310
|
+
DictionaryType, EllipsisType, FileType,
|
|
311
|
+
FloatType, FrameType, FunctionType,
|
|
312
|
+
GeneratorType, GetSetDescriptorType,
|
|
313
|
+
InstanceType, IntType, LambdaType,
|
|
314
|
+
ListType, LongType,
|
|
315
|
+
MemberDescriptorType, MethodType,
|
|
316
|
+
ModuleType, NoneType,
|
|
317
|
+
NotImplementedType, ObjectType,
|
|
318
|
+
SliceType, StringType, StringTypes,
|
|
319
|
+
TracebackType, TupleType, TypeType,
|
|
320
|
+
UnboundMethodType, UnicodeType,
|
|
321
|
+
XRangeType)
|
|
322
|
+
import typing
|
|
323
|
+
from typing import NamedTuple, Optional, Protocol
|
|
324
|
+
import unittest
|
|
325
|
+
import urllib
|
|
326
|
+
import urllib2
|
|
327
|
+
import warnings
|
|
328
|
+
import weakref
|
|
329
|
+
from weakref import (CallableProxyType, ProxyType,
|
|
330
|
+
ProxyTypes, ReferenceType,
|
|
331
|
+
WeakKeyDictionary, WeakValueDictionary,
|
|
332
|
+
getweakrefcount, getweakrefs)
|
|
333
|
+
from xml.dom import minidom
|
|
334
|
+
import xml.parsers.expat
|
|
335
|
+
import zlib
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env -S bash -e
|
|
2
|
+
|
|
3
|
+
# License for THIS FILE ONLY: CC0 Public Domain Dedication
|
|
4
|
+
# http://creativecommons.org/publicdomain/zero/1.0/
|
|
5
|
+
|
|
6
|
+
# Get the directory containing to the symlink target of the script.
|
|
7
|
+
if script=$(readlink -e "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
|
8
|
+
scriptdir=$(dirname "$script")
|
|
9
|
+
elif script=$(realpath "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
|
10
|
+
scriptdir=$(dirname "$script")
|
|
11
|
+
elif script=$(greadlink -e "$0" 2>/dev/null) && [[ "$script" -ef "$0" ]]; then
|
|
12
|
+
scriptdir=$(dirname "$script")
|
|
13
|
+
else
|
|
14
|
+
scriptdir=$(
|
|
15
|
+
d=$(dirname "$0")
|
|
16
|
+
b=$(basename "$0")
|
|
17
|
+
cd "$d"
|
|
18
|
+
if l=$(readlink "$b"); then
|
|
19
|
+
ld=$(dirname "$l")
|
|
20
|
+
cd "$ld"
|
|
21
|
+
fi
|
|
22
|
+
pwd
|
|
23
|
+
)
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
libexecdir="$scriptdir/../libexec/pyflyby"
|
|
27
|
+
|
|
28
|
+
PATH="$scriptdir:$libexecdir:$PATH"
|
|
29
|
+
|
|
30
|
+
if [[ -t 1 ]] && type -p diff-colorize >/dev/null; then
|
|
31
|
+
diff -u "$@" | diff-colorize
|
|
32
|
+
else
|
|
33
|
+
diff -u "$@"
|
|
34
|
+
fi
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import fileinput
|
|
5
|
+
import os
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
# TERM could be e.g. xterm-256color or screen-256color.
|
|
10
|
+
has_256_color = ('-256col' in os.environ.get('TERM', ''))
|
|
11
|
+
|
|
12
|
+
index_color = int(os.environ.get('DIFF_INDEX_COLOR',
|
|
13
|
+
has_256_color and 32 or 36))
|
|
14
|
+
old_mode_color = int(os.environ.get('DIFF_OLD_MODE_COLOR',
|
|
15
|
+
has_256_color and 88 or 31))
|
|
16
|
+
new_mode_color = int(os.environ.get('DIFF_NEW_MODE_COLOR',
|
|
17
|
+
has_256_color and 28 or 32))
|
|
18
|
+
removed_color = int(os.environ.get('DIFF_REMOVED_COLOR',
|
|
19
|
+
has_256_color and 160 or 31))
|
|
20
|
+
added_color = int(os.environ.get('DIFF_ADDED_COLOR',
|
|
21
|
+
has_256_color and 2 or 32))
|
|
22
|
+
hunk_start_color = int(os.environ.get('DIFF_HUNK_START_COLOR',
|
|
23
|
+
has_256_color and 32 or 36))
|
|
24
|
+
trailing_whitespace_color = int(has_256_color and 236 or 8)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
RESET_FORMAT = '\033[0m'
|
|
28
|
+
COLOR_FORMAT_256 = '\033[38;5;%um'
|
|
29
|
+
COLOR_FORMAT_16 = '\033[38;%um'
|
|
30
|
+
BG_COLOR_FORMAT_256 = '\033[48;5;%um'
|
|
31
|
+
BG_COLOR_FORMAT_16 = '\033[48;%um'
|
|
32
|
+
COLOR_FORMAT = has_256_color and COLOR_FORMAT_256 or COLOR_FORMAT_16
|
|
33
|
+
BG_COLOR_FORMAT = has_256_color and BG_COLOR_FORMAT_256 or BG_COLOR_FORMAT_16
|
|
34
|
+
BEGIN_REVERSE_FORMAT = '\033[7m'
|
|
35
|
+
END_REVERSE_FORMAT = '\033[27m'
|
|
36
|
+
|
|
37
|
+
USAGE = """
|
|
38
|
+
Usage: diff ... | diff-colorize
|
|
39
|
+
or: diff-colorize < foo.diff
|
|
40
|
+
|
|
41
|
+
Reads unified or git-style diff data from standard input, colorizes it, and
|
|
42
|
+
writes the result to standard output.
|
|
43
|
+
""".strip()
|
|
44
|
+
|
|
45
|
+
# You can customize the color numbers used by setting these variables in your environment:
|
|
46
|
+
# * DIFF_INDEX_COLOR (lines starting with "Index: " or "diff --git ")
|
|
47
|
+
# * DIFF_OLD_MODE_COLOR (lines starting with "old mode"; these only appear in git-style diffs)
|
|
48
|
+
# * DIFF_NEW_MODE_COLOR (lines starting with "new mode"; these only appear in git-style diffs)
|
|
49
|
+
# * DIFF_REMOVED_COLOR (lines starting with "-")
|
|
50
|
+
# * DIFF_ADDED_COLOR (lines starting with "+")
|
|
51
|
+
# * DIFF_HUNK_START_COLOR (lines starting with "@@")
|
|
52
|
+
|
|
53
|
+
# Everything in the unified diff format is identified by a prefix. The prefixes are:
|
|
54
|
+
# 'Index: ': File marker (unified diff)
|
|
55
|
+
# 'diff --git': File marker (git-style diff)
|
|
56
|
+
# 'old mode': File permissions mode before change
|
|
57
|
+
# 'new mode': File permissions mode after change
|
|
58
|
+
# '---': Defining '-' (giving the name and modification date of the file before change)
|
|
59
|
+
# '+++': Defining '+' (giving the name and modification date of the file after change)
|
|
60
|
+
# '-': Line before change (i.e., removed)
|
|
61
|
+
# '+': Line after change (i.e., added)
|
|
62
|
+
# ' ': Line that hasn't changed
|
|
63
|
+
# '@@': Hunk start (@@ -start,length +start, length @@)
|
|
64
|
+
#
|
|
65
|
+
# We need to look for these prefixes in order, in order to handle '---'/'+++' before '-'/'+'. Hence the OrderedDict.
|
|
66
|
+
class OrderedDict(dict):
|
|
67
|
+
def __init__(self, input=None):
|
|
68
|
+
if input is None:
|
|
69
|
+
self.keys = []
|
|
70
|
+
super(OrderedDict, self).__init__()
|
|
71
|
+
elif isinstance(input, dict):
|
|
72
|
+
self.keys = list(input)
|
|
73
|
+
super(OrderedDict, self).__init__(input)
|
|
74
|
+
else:
|
|
75
|
+
self.keys = [k for k, v in input]
|
|
76
|
+
super(OrderedDict, self).__init__(input)
|
|
77
|
+
def __iter__(self):
|
|
78
|
+
return iter(self.keys)
|
|
79
|
+
def __setitem__(self, k, v):
|
|
80
|
+
if k not in self:
|
|
81
|
+
self.keys.append(k)
|
|
82
|
+
super(OrderedDict, self).__setitem__(k, v)
|
|
83
|
+
def __delitem__(self, k):
|
|
84
|
+
super(OrderedDict, self).__delitem__(k)
|
|
85
|
+
self.keys.remove(k)
|
|
86
|
+
|
|
87
|
+
# Each value includes not only the terminal-config characters, but also the key, somewhere within it (possibly between two terminal-config strings).
|
|
88
|
+
# Theoretically, you could replace the key with some other string or leave it out entirely, if you wanted to, but I wouldn't recommend it.
|
|
89
|
+
prefixes = OrderedDict()
|
|
90
|
+
prefixes['---'] = (
|
|
91
|
+
COLOR_FORMAT % (removed_color,)
|
|
92
|
+
+ BEGIN_REVERSE_FORMAT
|
|
93
|
+
+ '---'
|
|
94
|
+
+ END_REVERSE_FORMAT
|
|
95
|
+
)
|
|
96
|
+
prefixes['+++'] = (
|
|
97
|
+
COLOR_FORMAT % (added_color,)
|
|
98
|
+
+ BEGIN_REVERSE_FORMAT
|
|
99
|
+
+ '+++'
|
|
100
|
+
+ END_REVERSE_FORMAT
|
|
101
|
+
)
|
|
102
|
+
prefixes['-'] = (
|
|
103
|
+
COLOR_FORMAT % (removed_color,)
|
|
104
|
+
+ BEGIN_REVERSE_FORMAT
|
|
105
|
+
+ '-'
|
|
106
|
+
+ END_REVERSE_FORMAT
|
|
107
|
+
)
|
|
108
|
+
prefixes['+'] = (
|
|
109
|
+
COLOR_FORMAT % (added_color,)
|
|
110
|
+
+ BEGIN_REVERSE_FORMAT
|
|
111
|
+
+ '+'
|
|
112
|
+
+ END_REVERSE_FORMAT
|
|
113
|
+
)
|
|
114
|
+
prefixes['old mode'] = ( # Git-style diffs only
|
|
115
|
+
COLOR_FORMAT % (old_mode_color,)
|
|
116
|
+
+ BEGIN_REVERSE_FORMAT
|
|
117
|
+
+ 'old mode'
|
|
118
|
+
+ END_REVERSE_FORMAT
|
|
119
|
+
)
|
|
120
|
+
prefixes['new mode'] = ( # Git-style diffs only
|
|
121
|
+
COLOR_FORMAT % (new_mode_color,)
|
|
122
|
+
+ BEGIN_REVERSE_FORMAT
|
|
123
|
+
+ 'new mode'
|
|
124
|
+
+ END_REVERSE_FORMAT
|
|
125
|
+
)
|
|
126
|
+
prefixes['Index: '] = COLOR_FORMAT % (index_color,) + 'Index: '
|
|
127
|
+
prefixes['diff --git '] = COLOR_FORMAT % (index_color,) + 'diff --git '
|
|
128
|
+
prefixes['@@'] = (
|
|
129
|
+
COLOR_FORMAT % (hunk_start_color,)
|
|
130
|
+
# + BEGIN_REVERSE_FORMAT
|
|
131
|
+
+ '@@'
|
|
132
|
+
)
|
|
133
|
+
trailing_whitespace_repl = r'\1%s\2' % (BG_COLOR_FORMAT % (trailing_whitespace_color,),)
|
|
134
|
+
|
|
135
|
+
if sys.stdin.isatty():
|
|
136
|
+
# Standard input is a TTY, meaning that the user ran 'diff-colorize' at the shell prompt, without redirecting anything into it. Print usage info and exit.
|
|
137
|
+
sys.exit(USAGE)
|
|
138
|
+
|
|
139
|
+
for line in fileinput.input():
|
|
140
|
+
for prefix_to_test in prefixes:
|
|
141
|
+
if line.startswith(prefix_to_test):
|
|
142
|
+
sys.stdout.write(prefixes[prefix_to_test])
|
|
143
|
+
line = line[len(prefix_to_test):]
|
|
144
|
+
line = re.sub('([^ \t])([ \t]+)$', trailing_whitespace_repl, line)
|
|
145
|
+
|
|
146
|
+
sys.stdout.write(line)
|
|
147
|
+
|
|
148
|
+
sys.stdout.write(RESET_FORMAT)
|