(symb, length)
return res
Construct spatial object of given length.

    return: [] of equal-length strings
Construct spatial object of given length.
Construct spatial object of given length .
def xobj(symb, length):
    """Construct spatial object of given length.

    return: [] of equal-length strings
    """

    if length <= 0:
        raise ValueError("Length should be greater than 0")

    # TODO robustify when no unicodedat available
    if _use_unicode:
        _xobj = _xobj_unicode
    else:
        _xobj = _xobj_ascii

    vinfo = _xobj[symb]

    c1 = top = bot = mid = None

    if not isinstance(vinfo, tuple):        # 1 entry
        ext = vinfo
    else:
        if isinstance(vinfo[0], tuple):     # (vlong), c1
            vlong = vinfo[0]
            c1 = vinfo[1]
        else:                               # (vlong), c1
            vlong = vinfo

        ext = vlong[0]

        try:
            top = vlong[1]
            bot = vlong[2]
            mid = vlong[3]
        except IndexError:
            pass

    if c1 is None:
        c1 = ext
    if top is None:
        top = ext
    if bot is None:
        bot = ext
    if mid is not None:
        if (length % 2) == 0:
            # even height, but we have to print it somehow anyway...
            # XXX is it ok?
            length += 1

    else:
        mid = ext

    if length == 1:
        return c1

    res = []
    next = (length - 2)//2
    nmid = (length - 2) - next*2

    res += [top]
    res += [ext]*next
    res += [mid]*nmid
    res += [ext]*next
    res += [bot]

    return res
def xobj ( symb , length ) : if length <= 0 : raise ValueError ( "Length should be greater than 0" ) # TODO robustify when no unicodedat available if _use_unicode : _xobj = _xobj_unicode else : _xobj = _xobj_ascii vinfo = _xobj [ symb ] c1 = top = bot = mid = None if not isinstance ( vinfo , tuple ) : # 1 entry ext = vinfo else : if isinstance ( vinfo [ 0 ] , tuple ) : # (vlong), c1 vlong = vinfo [ 0 ] c1 = vinfo [ 1 ] else : # (vlong), c1 vlong = vinfo ext = vlong [ 0 ] try : top = vlong [ 1 ] bot = vlong [ 2 ] mid = vlong [ 3 ] except IndexError : pass if c1 is None : c1 = ext if top is None : top = ext if bot is None : bot = ext if mid is not None : if ( length % 2 ) == 0 : # even height, but we have to print it somehow anyway... # XXX is it ok? length += 1 else : mid = ext if length == 1 : return c1 res = [ ] next = ( length - 2 ) // 2 nmid = ( length - 2 ) - next * 2 res += [ top ] res += [ ext ] * next res += [ mid ] * nmid res += [ ext ] * next res += [ bot ] return res