Skip to content

Commit

Permalink
Song: handle Unicode better when setting info properties
Browse files Browse the repository at this point in the history
  • Loading branch information
stump committed Dec 31, 2012
1 parent 8b62bf2 commit a4134e6
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/Song.py
Expand Up @@ -39,6 +39,7 @@
import cPickle #stump: Cerealizer and sqlite3 don't seem to like each other that much...
from Language import _
import VFS
from Unicode import asUTF8Bytes

DEFAULT_BPM = 120.0
DEFAULT_LIBRARY = "songs"
Expand Down Expand Up @@ -350,11 +351,7 @@ def getScores(self, part):
def _set(self, attr, value):
if not self.info.has_section("song"):
self.info.add_section("song")
if type(value) == unicode:
value = value.encode(Config.encoding)
else:
value = str(value)
self.info.set("song", attr, value)
self.info.set("song", attr, asUTF8Bytes(value))

def getObfuscatedScores(self, part = parts[GUITAR_PART]):
s = {}
Expand Down Expand Up @@ -736,11 +733,7 @@ def __init__(self, libraryName, infoFileName):
def _set(self, attr, value):
if not self.info.has_section("library"):
self.info.add_section("library")
if type(value) == unicode:
value = value.encode(Config.encoding)
else:
value = str(value)
self.info.set("library", attr, value)
self.info.set("library", attr, asUTF8Bytes(value))

def save(self):
if os.access(os.path.dirname(self.fileName), os.W_OK) == True:
Expand Down Expand Up @@ -828,11 +821,7 @@ def __init__(self, config, section):
self.artist = None #MFH - prevents search errors

def _set(self, attr, value):
if type(value) == unicode:
value = value.encode(Config.encoding)
else:
value = str(value)
self.info.set(self.section, attr, value)
self.info.set(self.section, attr, asUTF8Bytes(value))

def _get(self, attr, type = None, default = ""):
try:
Expand Down

0 comments on commit a4134e6

Please sign in to comment.