From: g0dil Date: Mon, 15 Nov 2010 14:16:25 +0000 (+0000) Subject: Fix sample bootstrap senfutil.py (Examples/Sniffer/site_scons/senfutil.py) X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=4101c2b818ec67e7469ebb44f030eed2185c4ab0;p=senf.git Fix sample bootstrap senfutil.py (Examples/Sniffer/site_scons/senfutil.py) git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1748 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/Sniffer/site_scons/senfutil.py b/Examples/Sniffer/site_scons/senfutil.py index 212819a..ceabee8 100644 --- a/Examples/Sniffer/site_scons/senfutil.py +++ b/Examples/Sniffer/site_scons/senfutil.py @@ -1,22 +1,22 @@ -import sys, os def findsenf(sysdirs = ('/usr/local/lib/senf','/usr/lib/senf'), subdirs = ('', 'senf', 'Senf', 'SENF')): - from os.path import join, sep, exists, normpath - from itertools import starmap, product, chain + import os, itertools + + def ancestors(d): + p = d.split(os.path.sep) + return (os.path.join(p[0]+os.path.sep,*p[1:i]) for i in range(len(p),0,-1)) - def joinpaths(*p): return starmap(join, product(*p)) - def existing(l): return (e for e in l if exists(e)) - def ancestors(d): p = d.split(sep); return (join(p[0]+sep,*p[1:i]) for i in range(len(p),0,-1)) - def butfirst(l): - i = iter(l); i.next() - for e in i : yield e + for d in itertools.chain(ancestors(os.getcwd()),sysdirs): + for s in subdirs: + py = os.path.join(d,s,'site_scons/senfutil.py') + if os.path.exists(py) and not os.path.samefile(py,__file__): return py - try: return normpath(existing(butfirst(joinpaths( - chain(ancestors(os.getcwd()),sysdirs), - subdirs,('site_scons/senfutil.py',)))).next()) - except StopIteration: raise ImportError, 'senfutil not found' + raise ImportError, 'senfutil not found' -__file__ = findsenf(); del findsenf +# replace module with real senfutil +import sys, os +__file__ = findsenf() sys.path.append(os.path.dirname(__file__)) +del sys, os, findsenf execfile(__file__, locals(), globals()) diff --git a/site_scons/lib/dot-munge.pl b/site_scons/lib/dot-munge.pl index 263b44e..5c60e41 100755 --- a/site_scons/lib/dot-munge.pl +++ b/site_scons/lib/dot-munge.pl @@ -1,20 +1,20 @@ #!/usr/bin/perl -i -n # Reduce fontsize and change font -s/fontsize=10/fontsize=8/g; +s/fontsize=10/fontsize=8/g; s/fontname="FreeSans.ttf"/fontname="Verdana"/g; # Wrap long labels (templates and pathnames) -if (/label=\"([^"]{48,})\"/) { #"])){ # To make emacs happy ... - $pre=$`; +if (/label=\"([^"]{24,})\"/) { #"])){ # To make emacs happy ... + $pre=$`; $post=$'; #'; # To make emacs happy ... $label=$1; # Break at each komma or / - $label=~s{[,/]}{$&\\r\\ \\ \\ \\ \\ \\ \\ \\ }g; + $label=~s{[,/]}{$&\\r\\ \\ \\ \\ \\ \\ \\ \\ }g; # If more than one '<' is in the label, break after each '<' - if (($label=~tr/1) { + if (($label=~tr/1) { $label=~s/