Browse Source

Utilisation de basestring à la place de str et unicode

pull/45/head
Luthaf 11 years ago
parent
commit
377e3c2939
  1. 5
      songbook_core/build.py
  2. 4
      songbook_core/plastex_songs.py

5
songbook_core/build.py

@ -112,7 +112,7 @@ class Songbook(object):
content = self.config["content"]
self.config["content"] = []
for elem in content:
if isinstance(elem, str) or isinstance(elem, unicode):
if isinstance(elem, basestring):
self.config["content"].append(("song", elem))
elif isinstance(elem, list):
self.config["content"].append((elem[0], elem[1]))
@ -130,8 +130,7 @@ class Songbook(object):
def _set_datadir(self):
"""Set the default values for datadir"""
try:
if isinstance(self.config['datadir'], str) or \
isinstance(self.config['datadir'], unicode):
if isinstance(self.config['datadir'], basestring):
self.config['datadir'] = [self.config['datadir']]
except KeyError: # No datadir in the raw_songbook
self.config['datadir'] = [os.path.abspath('.')]

4
songbook_core/plastex_songs.py

@ -56,9 +56,7 @@ class beginsong(plasTeX.Command): # pylint: disable=invalid-name,too-many-public
for (key, val) in self.attributes['args'].iteritems():
if isinstance(val, plasTeX.DOM.Element):
args[key] = process_unbr_spaces(val).textContent.encode('utf-8')
elif isinstance(val, unicode):
args[key] = val.encode('utf-8')
elif isinstance(val, str):
elif isinstance(val, basestring):
args[key] = val.encode('utf-8')
else:
args[key] = unicode(val)

Loading…
Cancel
Save