Пример #1
0
 def run(self, args):
     if len(args) > 2 and '/' == args[1][0]:
         fmt = args[1]
         del args[1]
     else:
         fmt = None
         pass
     arg = ' '.join(args[1:])
     try:
         val = self.proc.eval(arg)
         if fmt:
             val = Mprint.printf(val, fmt)
             pass
         self.msg(self.proc._saferepr(val))
     except:
         pass
Пример #2
0
def print_obj(arg, val, format=None, short=False):
    """Return a string representation of an object """
    what = arg
    if format:
        what = format + ' ' + arg
        val = Mprint.printf(val, format)
        pass
    s = '%s = %s' % (what, val)
    if not short:
        s += '\n  type = %s' % type(val)
        # Try to list the members of a class.
        # Not sure if this is correct or the
        # best way to do.
        s = print_dict(s, val, "object variables")
        if hasattr(val, "__class__"):
            s = print_dict(s, val.__class__, "class variables")
            pass
        pass
    return s
Пример #3
0
def print_obj(arg, val, format=None, short=False):
    """Return a string representation of an object """
    what = arg
    if format:
        what = format + ' ' + arg
        val = Mprint.printf(val, format)
        pass
    s = '%s = %s' % (what, val)
    if not short:
        s += '\n  type = %s' % type(val)
        # Try to list the members of a class.
        # Not sure if this is correct or the
        # best way to do.
        s = print_dict(s, val, "object variables")
        if hasattr(val, "__class__"):
            s = print_dict(s, val.__class__, "class variables")
            pass
        pass
    return s
Пример #4
0
 def test_lib_printf(self):
     self.assertEqual('037', Mprint.printf(31, "/o"))
     self.assertEqual('00011111', Mprint.printf(31, "/t"))
     self.assertEqual('!', Mprint.printf(33, "/c"))
     self.assertEqual('0x21', Mprint.printf(33, "/x"))
     return
 def test_lib_printf(self):
     self.assertEqual('037', Mprint.printf(31, "/o"))
     self.assertEqual('00011111', Mprint.printf(31, "/t"))
     self.assertEqual('!', Mprint.printf(33, "/c"))
     self.assertEqual('0x21', Mprint.printf(33, "/x"))
     return