view sandbox/common.py @ 191:73f9779491ef
Renamed lib to allpy
Previously, every import looked like "from allpy.lib import ...", which
was ridiculous.
Consequences:
1. Uses of the package look like "from allpy import"
2. When testing the package locally, you have to add `pwd` to PYTHONPATH,
not `pwd`/.. (this is a good thing (tm))
3. It is now possible to make a proper Debian package
The change renames directory & fixes all imports referencing allpy.lib
The results are untested since there were no working tests before the
change.
author |
Daniil Alexeyevsky <me.dendik@gmail.com> |
date |
Thu, 18 Nov 2010 19:38:05 +0300 |
parents |
|
children |
|
line source
1 def autoload(filename):
3 maxlen, seqs = measure(seqs)
4 stats, seqs = stat(maxlen, seqs)
5 seqs = color(maxlen, stats, seqs)
10 for block in open(filename).read().split('\n>'):
11 lines = block.split('\n')
12 name = lines[0].lstrip('>').strip()
13 body = "".join(lines[1:])
14 seqs.append((name, body))
18 maxlen = max([len(body) for name, body in seqs])
19 for i, (name, body) in enumerate(seqs):
20 body += "-" * (maxlen - len(body))
24 def stat(maxlen, seqs):
26 for x in xrange(maxlen):
28 for name, body in seqs:
30 stat[char] = stat.get(char, 0) + 1
34 def color(maxlen, stats, seqs):
36 for i, (name, body) in enumerate(seqs):
39 for x in xrange(maxlen):
40 id = stats[x][body[x]] * 10 // full
42 color = '#%02x%02x%02x' % (norm, norm, norm)
45 seqs[i] = name, body, ids, colors