f18c274b2eddbe163ba40a35cad031458feebe17
[sfa.git] / sfa / util / printable.py
1 # yet another way to display records...
2 def beginning (foo,size=15):
3     full="%s"%foo
4     if len(full)<=size: return full
5     return full[:size-3]+'...'
6
7 def printable (record_s):
8     # a list of records :
9     if isinstance (record_s,list):
10         return "[" + "\n".join( [ printable(r) for r in record_s ]) + "]"
11     if isinstance (record_s, dict):
12         return "{" + " , ".join( [ "%s:%s"%(k,beginning(v)) for k,v in record_s.iteritems() ] ) + "}"
13     if isinstance (record_s, str):
14         return record_s
15     return "unprintable [[%s]]"%record_s