Commit ecb4c7b4 authored by Antoine Millet's avatar Antoine Millet
Browse files

Added __repr__ to CallbackTag and StaticTag

parent c6052463
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ class StaticTag(BaseTag):
        super(StaticTag, self).__init__(name, **kwargs)
        self._value = value

    def __repr__(self):
        return '<%s %s (value=%r)>' % (self.__class__.__name__, self.name, self.value)

    #
    # Implentation of StaticTagInterface:
    #
@@ -101,6 +104,19 @@ class CallbackTag(BaseTag, StaticTagInterface):
        self._cache_value = ''
        self._cache_last_update = None

    def __repr__(self):
        if self._cache_last_update is not None and self._ttl is not None:
            dt = self.ttl - (datetime.now() - self._cache_last_update)
            expire = (dt.microseconds + (dt.seconds + dt.days * 24 * 3600) * 10**6) / 10.0**6
        else:
            expire = None
        return '<%s %s (ttl=%r expire=%r cached=%r cb=%r)>' % (self.__class__.__name__,
                                                               self.name,
                                                               self._ttl,
                                                               expire,
                                                               self._cache_value,
                                                               self._callback.__name__)

    #
    # Implentation of StaticTagInterface:
    #