예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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))
예제 #6
0
 def write(self, data):
     '''
     Writes the given data to the stream.
     '''
     if data:
         self._stream.write(utils.encode(data, self._encoding))
예제 #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))