Mercurial > hg > documentViewer
comparison SrvTxtUtils.py @ 614:d16da6e739ef
fix problem with utf8ify trying to encode ints.
author | casties |
---|---|
date | Mon, 21 Oct 2013 10:36:54 +0200 |
parents | c57d80a649ea |
children | a71ae589d342 |
comparison
equal
deleted
inserted
replaced
613:c57d80a649ea | 614:d16da6e739ef |
---|---|
20 import urllib2 | 20 import urllib2 |
21 httplib = 'urllib2' | 21 httplib = 'urllib2' |
22 | 22 |
23 import xml.etree.ElementTree as ET | 23 import xml.etree.ElementTree as ET |
24 | 24 |
25 srvTxtUtilsVersion = "1.12.1" | 25 srvTxtUtilsVersion = "1.12.2" |
26 | 26 |
27 map_months = {'en': [u"", | 27 map_months = {'en': [u"", |
28 u"January", | 28 u"January", |
29 u"February", | 29 u"February", |
30 u"March", | 30 u"March", |
82 assumes string objects to be utf-8""" | 82 assumes string objects to be utf-8""" |
83 if not s: | 83 if not s: |
84 return "" | 84 return "" |
85 if isinstance(s, str): | 85 if isinstance(s, str): |
86 return s | 86 return s |
87 else: | 87 elif isinstance(s, unicode): |
88 return s.encode('utf-8') | 88 return s.encode('utf-8') |
89 else: | |
90 return str(s) | |
89 | 91 |
90 def getText(node, recursive=0): | 92 def getText(node, recursive=0): |
91 """returns all text content of a (etree) node and its subnodes""" | 93 """returns all text content of a (etree) node and its subnodes""" |
92 if node is None: | 94 if node is None: |
93 return '' | 95 return '' |