@@ -37,8 +37,7 @@ def __init__(self,
37
37
- ``art_type`` -- type of the character art (i.e. a subclass of
38
38
:class:`~sage.typeset.character_art.CharacterArt`)
39
39
40
- - ``string_type`` -- type of strings (the lines in the
41
- character art, e.g. ``str`` or ``unicode``)
40
+ - ``string_type`` -- ignored (always ``str``)
42
41
43
42
- ``magic_method_name`` -- name of the Sage magic method (e.g.
44
43
``'_ascii_art_'`` or ``'_unicode_art_'``)
@@ -60,8 +59,6 @@ def __init__(self,
60
59
<class 'sage.typeset.character_art_factory.CharacterArtFactory'>
61
60
"""
62
61
self .art_type = art_type
63
- assert isinstance (string_type ('a' ), str )
64
- self .string_type = string_type
65
62
assert magic_method_name in ['_ascii_art_' , '_unicode_art_' ]
66
63
self .magic_method_name = magic_method_name
67
64
self .left_parenthesis , self .right_parenthesis = parenthesis
@@ -204,13 +201,11 @@ def build_from_string(self, obj, baseline=0):
204
201
bb
205
202
ccc
206
203
"""
207
- if self . string_type is str and not isinstance (obj , str ):
204
+ if not isinstance (obj , str ):
208
205
if isinstance (obj , bytes ):
209
206
obj = obj .decode ('utf-8' )
210
207
else :
211
208
obj = str (obj )
212
- if self .string_type is bytes and not isinstance (obj , bytes ):
213
- obj = str (obj ).encode ('utf-8' )
214
209
return self .art_type (obj .splitlines (), baseline = baseline )
215
210
216
211
def build_container (self , content , left_border , right_border , baseline = 0 ):
@@ -263,7 +258,7 @@ def build_container(self, content, left_border, right_border, baseline=0):
263
258
left_border = left_border .character_art (h )
264
259
right_border = right_border .character_art (h )
265
260
lines = []
266
- pad = self . string_type ( ' ' )
261
+ pad = ' '
267
262
for left , line , right in zip (left_border , matrix , right_border ):
268
263
lines .append (left + pad + line .ljust (w ) + pad + right )
269
264
shift = len (left_border ) + len (pad )
@@ -295,7 +290,7 @@ def build_set(self, s, baseline=0):
295
290
{ /\ /\ /\/\ / \ }
296
291
{ /\/\/\, /\/ \, / \/\, / \, / \ }
297
292
"""
298
- comma = self .art_type ([self . string_type ( ', ' ) ], baseline = 0 )
293
+ comma = self .art_type ([', ' ], baseline = 0 )
299
294
repr_elems = self .concatenate (s , comma , nested = True )
300
295
return self .build_container (
301
296
repr_elems , self .left_curly_brace , self .right_curly_brace ,
@@ -323,10 +318,10 @@ def build_dict(self, d, baseline=0):
323
318
sage: ascii_art({'a': '', '': ''})
324
319
{ a:, : }
325
320
"""
326
- comma = self .art_type ([self . string_type ( ', ' ) ],
321
+ comma = self .art_type ([', ' ],
327
322
baseline = 0 ,
328
323
breakpoints = [1 ])
329
- colon = self .art_type ([self . string_type ( ':' ) ], baseline = 0 )
324
+ colon = self .art_type ([':' ], baseline = 0 )
330
325
331
326
def concat_no_breakpoint (k , v ):
332
327
k = self .build (k )
@@ -378,7 +373,7 @@ def build_list(self, l, baseline=0):
378
373
22, 23, 24, 25 ], [ 1, 2, 3, 4, 5 ],\n\n
379
374
[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ] ]'
380
375
"""
381
- comma = self .art_type ([self . string_type ( ', ' ) ],
376
+ comma = self .art_type ([', ' ],
382
377
baseline = 0 ,
383
378
breakpoints = [1 ])
384
379
repr_elems = self .concatenate (l , comma , nested = True )
@@ -397,7 +392,7 @@ def build_tuple(self, t, baseline=0):
397
392
( /\ /\ /\/\ / \ )
398
393
( /\/\/\, /\/ \, / \/\, / \, / \ )
399
394
"""
400
- comma = self .art_type ([self . string_type ( ', ' ) ],
395
+ comma = self .art_type ([', ' ],
401
396
baseline = 0 ,
402
397
breakpoints = [1 ])
403
398
repr_elems = self .concatenate (t , comma , nested = True )
0 commit comments