/usr/share/pyshared/guppy/etc/etc.py is in python-guppy 0.1.9-2ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #._cv_part guppy.etc.etc
from StringIO import StringIO
def reptable(tb):
if not tb:
return 0, []
maxlens = [0]*len(tb[0])
for r in tb:
if r == '-':
continue
for i, e in enumerate(r):
maxlens[i] = max(maxlens[i], len(str(e))+1)
sumlens = len(maxlens)
for s in maxlens:
sumlens += s
out = []
for r in tb:
if r == '-':
out.append( '-'*min(sumlens, 75) )
else:
so = ''
for i, e in enumerate(r):
s = str(e)
if s.startswith('!>'):
s = s[2:]
fillright = 1
elif s.isdigit():
fillright = 1
else:
fillright = 0
ml = maxlens[i]-1
fill = ' '*(ml -len(s))
if fillright:
s = fill + s
else:
if 1 or i + 1 < len(r):
s = s + fill
so += s + ' '
out.append(so)
return maxlens, out
def ptable(tb, f=None):
if f is None:
import sys
f = sys.stdout
_, lines = reptable(tb)
for line in lines:
line = line.rstrip()
print >>f, line
def strtable(tb):
f = StringIO()
ptable(tb, f)
return f.getvalue()
def str2int(s, msg = 'Hexadecimal literal in the form [-]0x... expected'):
# xxx clumsy -- there should be a builtin function for this !
if s.startswith('-'):
sign = -1
s = s [1:]
else:
sign = 1
if not s.startswith('0x'):
raise ValueError, msg
s = s[2:]
if s.endswith('l') or s.endswith('L'):
s = s[:-1]
return int(s, 16) * sign
|