aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Shoulson <mark@kli.org>2011-12-15 09:58:15 -0500
committerMark Shoulson <mark@kli.org>2011-12-15 09:58:15 -0500
commit82cf2a5e94c9b7c0139a8444a82db34fa6e096e3 (patch)
tree57b5b624c32f31534c641ff493847a9c1d6a97e7
parentAdded some emoji, clockfaces; fixed typo in /.. expansion. (diff)
downloaddotXCompose-82cf2a5e94c9b7c0139a8444a82db34fa6e096e3.tar.gz
dotXCompose-82cf2a5e94c9b7c0139a8444a82db34fa6e096e3.tar.bz2
dotXCompose-82cf2a5e94c9b7c0139a8444a82db34fa6e096e3.zip
treeprint.py could just use yaml, you know.
-rw-r--r--treeprint.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/treeprint.py b/treeprint.py
index 0168912..adaaf1e 100644
--- a/treeprint.py
+++ b/treeprint.py
@@ -50,10 +50,10 @@ def showdict(data, indent):
else:
showdict(value, -abs(indent+4)),
else:
- print " "+value,
+ print " "+value.encode('utf-8'),
if "-n" in sys.argv:
try:
- print unicodedata.name(value.decode('utf-8')),
+ print unicodedata.name(value),
except:
pass
print ")",
@@ -62,7 +62,7 @@ listing={}
try:
while True:
- line=sys.stdin.next()
+ line=sys.stdin.next().decode('utf-8')
# print "((%s))"%line
startpos=0
name=[]
@@ -72,7 +72,7 @@ try:
if not m:
break
word=m.group(1)
- name.append(word)
+ name.append(str(word)) # The keys are ordinary strings, not unicode
startpos+=m.end()
if startpos<=0:
continue
@@ -98,8 +98,15 @@ try:
# fail. Prefix conflict. Let's ignore it.
pass
except StopIteration:
- print "hit end"
+ # print "hit end"
+ pass
+# Actually, you could get almost as nice a listing just by using yaml,
+# but now that we have special no-newlines-for-singletons handling,
+# showdict looks nicer.
showdict(listing,0)
-
+# #print "\n\n-=- YAML -=-"
+# import yaml
+# print yaml.dump(listing, default_style=r'"', allow_unicode=True)
+# # Huh. Yaml "allow_unicode=True" still escapes non-BMP chars.