Esempio n. 1
0
 def getEncoded(*args):
     arg = args[-1]
     args = list(args[:-1])
     if arg is not None:
         arg = encode(arg, encoding)
     args.append(arg)
     return func(*args)
Esempio n. 2
0
 def getEncoded(*args):
     arg = args[-1]
     args = list(args[:-1])
     if arg is not None:
         arg = encode(arg, encoding)
     args.append(arg)
     return func(*args)
Esempio n. 3
0
def _printAccessibleAligned(accessible, lens):
    '''
    Aligns and prints the given accessible recursively.
    '''
    row = []
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if item is None:
            item = ''
        if not isinstance(item, basestring):
            item = str(item)
        row.append(utils.encode(item).ljust(lens[i]))
    print _COLUMN_SEPARATOR.join(row)
    for child in accessible.children(force=False):
        _printAccessibleAligned(child, lens)
Esempio n. 4
0
def _printAccessibleAligned(accessible, lens):
    '''
    Aligns and prints the given accessible recursively.
    '''
    row = []
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if item is None:
            item = ''
        if not isinstance(item, basestring):
            item = str(item)
        row.append(utils.encode(item).ljust(lens[i]))
    print _COLUMN_SEPARATOR.join(row)
    for child in accessible.children(force=False):
        _printAccessibleAligned(child, lens)
Esempio n. 5
0
 def _assert(self, expr, msg, etype):
     '''
     Asserts the expression using the given exception type and message.
     '''
     if not expr:
         raise etype(encode(msg))
 def write(self, data):
     '''
     Writes the given data to the stream.
     '''
     if data:
         self._stream.write(utils.encode(data, self._encoding))
Esempio n. 7
0
 def _assert(self, expr, msg, etype):
     '''
     Asserts the expression using the given exception type and message.
     '''
     if not expr:
         raise etype(encode(msg))