@@ -124,14 +124,15 @@ class DateType(types.Float):
124
124
query = dbcore .query .DateQuery
125
125
126
126
def format (self , value ):
127
- return time .strftime (beets .config ['time_format' ].get (unicode ),
127
+ return time .strftime (beets .config ['time_format' ].get (six . text_type ),
128
128
time .localtime (value or 0 ))
129
129
130
130
def parse (self , string ):
131
131
try :
132
132
# Try a formatted date string.
133
133
return time .mktime (
134
- time .strptime (string , beets .config ['time_format' ].get (unicode ))
134
+ time .strptime (string ,
135
+ beets .config ['time_format' ].get (six .text_type ))
135
136
)
136
137
except ValueError :
137
138
# Fall back to a plain timestamp number.
@@ -153,7 +154,7 @@ def parse(self, string):
153
154
return normpath (bytestring_path (string ))
154
155
155
156
def normalize (self , value ):
156
- if isinstance (value , unicode ):
157
+ if isinstance (value , six . text_type ):
157
158
# Paths stored internally as encoded bytes.
158
159
return bytestring_path (value )
159
160
@@ -281,11 +282,11 @@ def __unicode__(self):
281
282
"""
282
283
return u'{0}: {1}' .format (
283
284
util .displayable_path (self .path ),
284
- unicode (self .reason )
285
+ six . text_type (self .reason )
285
286
)
286
287
287
288
def __str__ (self ):
288
- return unicode (self ).encode ('utf8' )
289
+ return six . text_type (self ).encode ('utf8' )
289
290
290
291
291
292
class ReadError (FileOperationError ):
@@ -331,7 +332,7 @@ def add(self, lib=None):
331
332
332
333
def __format__ (self , spec ):
333
334
if not spec :
334
- spec = beets .config [self ._format_config_key ].get (unicode )
335
+ spec = beets .config [self ._format_config_key ].get (six . text_type )
335
336
result = self .evaluate_template (spec )
336
337
if isinstance (spec , bytes ):
337
338
# if spec is a byte string then we must return a one as well
@@ -517,7 +518,7 @@ def __setitem__(self, key, value):
517
518
"""
518
519
# Encode unicode paths and read buffers.
519
520
if key == 'path' :
520
- if isinstance (value , unicode ):
521
+ if isinstance (value , six . text_type ):
521
522
value = bytestring_path (value )
522
523
elif isinstance (value , buffer ):
523
524
value = bytes (value )
@@ -1061,7 +1062,8 @@ def art_destination(self, image, item_dir=None):
1061
1062
image = bytestring_path (image )
1062
1063
item_dir = item_dir or self .item_dir ()
1063
1064
1064
- filename_tmpl = Template (beets .config ['art_filename' ].get (unicode ))
1065
+ filename_tmpl = Template (
1066
+ beets .config ['art_filename' ].get (six .text_type ))
1065
1067
subpath = self .evaluate_template (filename_tmpl , True )
1066
1068
if beets .config ['asciify_paths' ]:
1067
1069
subpath = unidecode (subpath )
@@ -1179,7 +1181,8 @@ def parse_query_string(s, model_cls):
1179
1181
1180
1182
The string is split into components using shell-like syntax.
1181
1183
"""
1182
- assert isinstance (s , unicode ), u"Query is not unicode: {0!r}" .format (s )
1184
+ message = u"Query is not unicode: {0!r}" .format (s )
1185
+ assert isinstance (s , six .text_type ), message
1183
1186
try :
1184
1187
parts = util .shlex_split (s )
1185
1188
except ValueError as exc :
@@ -1405,7 +1408,7 @@ def tmpl_asciify(s):
1405
1408
def tmpl_time (s , fmt ):
1406
1409
"""Format a time value using `strftime`.
1407
1410
"""
1408
- cur_fmt = beets .config ['time_format' ].get (unicode )
1411
+ cur_fmt = beets .config ['time_format' ].get (six . text_type )
1409
1412
return time .strftime (fmt , time .strptime (s , cur_fmt ))
1410
1413
1411
1414
def tmpl_aunique (self , keys = None , disam = None ):
0 commit comments