Add a repr method to *cls*.
977058
def _add_repr(cls, ns=None, attrs=None):
    
    if attrs is None:
        attrs = cls.__attrs_attrs__

    cls.__repr__ = _make_repr(attrs, ns)
    return cls
625688
def raw_repr(obj):
    ''''''
    if isproxy(obj):
        return '<%s with prime_id=%d>' % (obj.__class__.__name__, obj.prime_id)
    else:
        return repr(obj)
1348530
def add_class(self, cls, callback):
        
        if cls.TAG in self._tag_map:
            raise ValueError(
                "duplicate tag: {!r} is already handled by {}".format(
                    cls.TAG,
                    self._tag_map[cls.TAG]))
        self._class_map[cls] = callback
        self._tag_map[cls.TAG] = (cls, callback)
33407
def bind_model_cls(self, model_cls):
        """"""
        if self.model_cls:
            raise errors.Error('"{0}" has been already bound to "{1}" and '
                               'could not be rebound to "{2}"'.format(
                                   self, self.model_cls, model_cls))
        self.model_cls = model_cls
        return self
177241
def _add_new_methods(cls):
        """"""
        for name, method in cls.context.new_methods.items():
            if hasattr(cls.context.new_class, name):
                raise ValueError(
                    "Name collision in state machine class - '{name}'."
                    .format(name)
                )

            setattr(cls.context.new_class, name, method)
419148
def immutable_attribs(cls):
    """"""
    cls = attr.s(cls, frozen=True)
    defaults = OrderedDict([(a.name, a.default) for a in cls.__attrs_attrs__])

    def repr_(self):
        from qnet.printing import srepr
        real_cls = self.__class__
        class_name = real_cls.__name__
        args = []
        for name in defaults.keys():
            val = getattr(self, name)
            positional = defaults[name] == attr.NOTHING
            if val != defaults[name]:
                args.append(
                    srepr(val) if positional else "%s=%s" % (name, srepr(val)))
        return "{0}({1})".format(class_name, ", ".join(args))

    cls.__repr__ = repr_
    return cls
1178157
def _apply_replace_backrefs(m, repl=None, flags=0):
    """"""

    if m is None:
        raise ValueError("Match is None!")
    else:
        if isinstance(repl, ReplaceTemplate):
            return repl.expand(m)
        elif isinstance(repl, (str, bytes)):
            return _bregex_parse._ReplaceParser().parse(m.re, repl, bool(flags & FORMAT)).expand(m)
933231
def add(cls, name, value):
        """"""
        attr = cls(value)
        attr._name = name
        setattr(cls, name, attr)
543310
def to_cls(self):
        """"""
        # Checks if ``to_cls`` is a string
        #   If it is, checks if the entity is imported and available
        #   If it is, register the class
        try:
            if isinstance(self._to_cls, str):
                self._to_cls = fetch_entity_cls_from_registry(self._to_cls)
        except AssertionError:
            # Preserve ``to_cls`` as a string and we will hook up the entity later
            pass

        return self._to_cls
13696
def _repr_values(self):
        """"""
        def getattr_better(obj, field):
            try:
                return getattr(obj, field)
            except AttributeError as e:
                try:
                    return getattr(obj, '_' + field)
                except AttributeError:
                    raise e

        return (getattr_better(self, attr) for attr in self._repr_attributes)
1016404
def _add_dunder_class(func, member):
    """"""
    python_cls = member.__class__
    cls_name = getattr(python_cls, "__name__", None)
    if not cls_name:
        return
    cls_bases = [ancestor.__name__ for ancestor in python_cls.__bases__]
    ast_klass = build_class(cls_name, cls_bases, python_cls.__doc__)
    func.instance_attrs["__class__"] = [ast_klass]
385969
def contribute_to_class(self, cls, name):
        

        self.update_rel_to(cls)

        # Called to get a name
        self.set_attributes_from_name(name)
        self.model = cls

        # Set the through field
        if not self.remote_field.through and not cls._meta.abstract:
            self.remote_field.through = create_many_to_many_intermediary_model(
                self, cls)

        # Do the rest
        super(M2MFromVersion, self).contribute_to_class(cls, name)
98657
def repr_assist(obj, remap=None):
    
    if not remap:
        remap = {}
    data = []
    for arg in inspect.getargspec(getattr(obj.__class__, '__init__'))[0]:
        if arg == 'self':
            continue
        elif arg in remap:
            value = remap[arg]
        else:
            try:
                value = getattr(obj, arg)
            except AttributeError:
                value = getattr(obj, '_%s' % arg)
        if isinstance(value, (type(None), list, basestring, datetime.date,
                              datetime.time)):
            data.append(repr(value))
        else:
            data.append(str(value))
    return "%s(%s)" % (obj.__class__.__name__, ', '.join(data))
391666
def class_register(cls):
    """"""
    cls.handler_registry = {}
    cls.sender_registry = {}
    for method_name in dir(cls):
        method = getattr(cls, method_name)
        if hasattr(method, '_handle'):
            cls.handler_registry.update({method._handle: method_name})
        if hasattr(method, '_sends'):
            cls.sender_registry.update({method._sends: method_name})
    return cls
1347237
def assignrepr(self, prefix='') -> str:
        """"""
        with objecttools.repr_.preserve_strings(True):
            with hydpy.pub.options.ellipsis(2, optional=True):
                prefix += '%s(' % objecttools.classname(self)
                repr_ = objecttools.assignrepr_values(
                    sorted(self.names), prefix, 70)
                return repr_ + ')'
252782
def transform(self, attrs):
        """"""
        self.collect(attrs)
        self.add_missing_implementations()
        self.fill_attrs(attrs)
1011580
public void repr(StringBuilder buf, String sep) {
    if (style != null) {
      buf.append("style=").append(style);
    }
    super.repr(buf, sep);
  }