| Server IP : 142.11.234.102 / Your IP : 216.73.216.89 Web Server : Apache System : Linux dal-shared-66.hostwindsdns.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64 User : krnuyqrm ( 1183) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/root/opt/alt/python27/lib64/python2.7/site-packages/guppy/etc/ |
Upload File : |
#._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