##// END OF EJS Templates
ipipe patch 5 from Walter Doerwald, featuring:...
ipipe patch 5 from Walter Doerwald, featuring: Change the way padding is done in ibrowse: Instead of creating a string long enough to fill the rest of the colum even if this column is much to long for the screen, only create a pad string large enough for the visible part. This speeds up scrolling with very long columns. Implement a workaround for eval() not accepting non-dicts as namespaces. (Patch contributed by Torsten Marek) xiter() now directly supports dictproxies, so e.g. "int.__dict__ | ibrowse" works. xrepr() has been rewritten as a generator (and all __xrepr__() methods too): This has two advantages: 1) xrepr() of large datastructure are usable now, because the generator is abandoned after "enough" output has been generated (defaults to 200 characters). 2) xrepr() methods can now return styles for each part of their output. xrepr() is used everywhere now: in the header and footer (like before) but also in the table cells. For this two new xrepr() modes habe been added: "cell" for an object in a ibrowse table cell and "default" which must be used as the mode in recursive calls to xrepr() (this returns a representation that has the most similarity to a normal repr()). Removed the special treatment of lists and tuples in xattrs(). If you want to see the list or tuple simply enter it. This is again done to keep ibrowse useable even with large data structures. Add a class List as a replacement for the old functionality (icsv needs this).

File last commit:

r222:0f9c593b
r225:a1ae16ad
Show More
upgrade_dir.py
88 lines | 2.6 KiB | text/x-python | PythonLexer
#!/usr/bin/env python
""" A script/util to upgrade all files in a directory
This is rather conservative in its approach, only copying/overwriting
new and unedited files.
To be used by "upgrade" feature.
"""
from path import path
import md5,pickle
def showdiff(old,new):
import difflib
d = difflib.Differ()
lines = d.compare(old.lines(),new.lines())
realdiff = False
for l in lines:
print l,
if not realdiff and not l[0].isspace():
realdiff = True
return realdiff
def upgrade_dir(srcdir, tgtdir):
""" Copy over all files in srcdir to tgtdir w/ native line endings
Creates .upgrade_report in tgtdir that stores md5sums of all files
to notice changed files b/w upgrades.
"""
def pr(s):
print s
def ignorable(p):
if p.lower().startswith('.svn') or p.startswith('ipythonrc'):
return True
return False
modded = []
files = [path(srcdir).relpathto(p) for p in path(srcdir).walkfiles()]
#print files
rep = tgtdir / '.upgrade_report'
try:
rpt = pickle.load(rep.open())
except:
rpt = {}
for f in files:
if ignorable(f):
continue
src = srcdir / f
tgt = tgtdir / f
if not tgt.isfile():
pr("Creating %s" % str(tgt))
tgt.write_text(src.text())
rpt[str(tgt)] = md5.new(tgt.text()).hexdigest()
else:
cont = tgt.text()
sum = rpt.get(str(tgt), None)
#print sum
if sum and md5.new(cont).hexdigest() == sum:
pr("Unedited, installing new %s" % tgt)
rpt[str(tgt)] = md5.new(tgt.text()).hexdigest()
else:
pr(' == Modified, skipping %s, diffs below == ' % tgt)
#rpt[str(tgt)] = md5.new(tgt.bytes()).hexdigest()
real = showdiff(tgt,src)
pr('') # empty line
if not real:
pr("(Ok, it wasn't that different at all, upgrading checksum)")
rpt[str(tgt)] = md5.new(tgt.text()).hexdigest()
else:
modded.append(tgt)
#print rpt
pickle.dump(rpt, rep.open('w'))
if modded:
print "\n\nDelete the following files manually if you need a full upgrade:"
for m in modded:
print m
import sys
if __name__ == "__main__":
upgrade_dir(path(sys.argv[1]), path(sys.argv[2]))