gui/component.py
def represent(obj, prefix, parent="", indent=0, context=False, max_cols=80):
    "Construct a string representing the object"
    try:
        name = getattr(obj, "name", "")
        class_name = "%s.%s" % (prefix, obj.__class__.__name__)
        padding = len(class_name) + 1 + indent * 4 + (5 if context else 0)
        params = []
        for (k, spec) in sorted(obj._meta.specs.items(), key=get_sort_key):
            if k == "index":        # index is really defined by creation order
                continue            # also, avoid infinite recursion
            if k == "parent" and parent != "":
                v = parent
            else:
                v = getattr(obj, k, "")
                if (not isinstance(spec, InternalSpec) 
                    and v != spec.default
                    and (k != 'id' or v > 0) 
                    and isinstance(v, 
                         (basestring, int, long, float, bool, dict, list, 
                          decimal.Decimal, 
                          datetime.datetime, datetime.date, datetime.time,
                          Font, Color))                
                    and repr(v) != 'None'
                    ):
                    v = repr(v)
                else:
                    v = None
            if v is not None:
                params.append("%s=%s" % (k, v)) 
        param_lines = []
        line = ""
        for param in params:
            if len(line + param) + 3 > max_cols - padding:
                param_lines.append(line)
                line = ""
            line += param + ", "
        param_lines.append(line)
        param_str = ("\n%s" % (" " * padding)).join(param_lines)
        return "%s(%s)" % (class_name, param_str)
    except:
        raise
        # uninitialized, use standard representation to not break debuggers
        return object.__repr__(obj)
def represent(obj, prefix, parent="", indent=0, context=False, max_cols=80):
    "Construct a string representing the object"
    try:
        name = getattr(obj, "name", "")
        class_name = "%s.%s" % (prefix, obj.__class__.__name__)
        padding = len(class_name) + 1 + indent * 4 + (5 if context else 0)
        params = []
        for (k, spec) in sorted(obj._meta.specs.items(), key=get_sort_key):
            if k == "index":        # index is really defined by creation order
                continue            # also, avoid infinite recursion
            if k == "parent" and parent != "":
                v = parent
            else:
                v = getattr(obj, k, "")
                if (not isinstance(spec, InternalSpec) 
                    and v != spec.default
                    and (k != 'id' or v > 0) 
                    and isinstance(v, 
                         (basestring, int, long, float, bool, dict, list, 
                          decimal.Decimal, 
                          datetime.datetime, datetime.date, datetime.time,
                          Font, Color))                
                    and repr(v) != 'None'
                    ):
                    v = repr(v)
                else:
                    v = None
            if v is not None:
                params.append("%s=%s" % (k, v)) 
        param_lines = []
        line = ""
        for param in params:
            if len(line + param) + 3 > max_cols - padding:
                param_lines.append(line)
                line = ""
            line += param + ", "
        param_lines.append(line)
        param_str = ("\n%s" % (" " * padding)).join(param_lines)
        return "%s(%s)" % (class_name, param_str)
    except:
        raise
        # uninitialized, use standard representation to not break debuggers
        return object.__repr__(obj)
def represent ( obj , prefix , parent = "" , indent = 0 , context = False , max_cols = 80 ) : try : name = getattr ( obj , "name" , "" ) class_name = "%s.%s" % ( prefix , obj . __class__ . __name__ ) padding = len ( class_name ) + 1 + indent * 4 + ( 5 if context else 0 ) params = [ ] for ( k , spec ) in sorted ( obj . _meta . specs . items ( ) , key = get_sort_key ) : if k == "index" : # index is really defined by creation order
 continue # also, avoid infinite recursion
 if k == "parent" and parent != "" : v = parent else : v = getattr ( obj , k , "" ) if ( not isinstance ( spec , InternalSpec ) and v != spec . default and ( k != 'id' or v > 0 ) and isinstance ( v , ( basestring , int , long , float , bool , dict , list , decimal . Decimal , datetime . datetime , datetime . date , datetime . time , Font , Color ) ) and repr ( v ) != 'None' ) : v = repr ( v ) else : v = None if v is not None : params . append ( "%s=%s" % ( k , v ) ) param_lines = [ ] line = "" for param in params : if len ( line + param ) + 3 > max_cols - padding : param_lines . append ( line ) line = "" line += param + ", " param_lines . append ( line ) param_str = ( "\n%s" % ( " " * padding ) ) . join ( param_lines ) return "%s(%s)" % ( class_name , param_str ) except : raise # uninitialized, use standard representation to not break debuggers
 return object . __repr__ ( obj )
Construct a string representing the object
Construct a string representing the object