Fixed #27546 -- Removed hardcoded class names in __repr__() methods.

This commit is contained in:
Keda87 2016-12-01 08:08:51 -05:00 committed by Tim Graham
parent 794b7d8033
commit 48826aa541
6 changed files with 14 additions and 8 deletions

View File

@ -46,7 +46,10 @@ class TranslatableFile(object):
self.locale_dir = locale_dir
def __repr__(self):
return "<TranslatableFile: %s>" % os.sep.join([self.dirpath, self.file])
return "<%s: %s>" % (
self.__class__.__name__,
os.sep.join([self.dirpath, self.file]),
)
def __eq__(self, other):
return self.path == other.path

View File

@ -198,8 +198,11 @@ class DeserializedObject(object):
self.m2m_data = m2m_data
def __repr__(self):
return "<DeserializedObject: %s(pk=%s)>" % (
self.object._meta.label, self.object.pk)
return "<%s: %s(pk=%s)>" % (
self.__class__.__name__,
self.object._meta.label,
self.object.pk,
)
def save(self, save_m2m=True, using=None, **kwargs):
# Call save on the Model baseclass directly. This bypasses any

View File

@ -588,7 +588,7 @@ class ModelState(object):
raise ValueError("No index named %s on model %s" % (name, self.name))
def __repr__(self):
return "<ModelState: '%s.%s'>" % (self.app_label, self.name)
return "<%s: '%s.%s'>" % (self.__class__.__name__, self.app_label, self.name)
def __eq__(self, other):
return (

View File

@ -225,7 +225,7 @@ class QuerySet(object):
data = list(self[:REPR_OUTPUT_SIZE + 1])
if len(data) > REPR_OUTPUT_SIZE:
data[-1] = "...(remaining elements truncated)..."
return '<QuerySet %r>' % data
return '<%s %r>' % (self.__class__.__name__, data)
def __len__(self):
self._fetch_all()
@ -1220,7 +1220,7 @@ class RawQuerySet(object):
self.query.cursor.close()
def __repr__(self):
return "<RawQuerySet: %s>" % self.query
return "<%s: %s>" % (self.__class__.__name__, self.query)
def __getitem__(self, k):
return list(self)[k]

View File

@ -86,7 +86,7 @@ class RawQuery(object):
return iter(result)
def __repr__(self):
return "<RawQuery: %s>" % self
return "<%s: %s>" % (self.__class__.__name__, self)
@property
def params_type(self):

View File

@ -55,7 +55,7 @@ class BaseConverter(object):
raise ValueError('Sign character found in converter base digits.')
def __repr__(self):
return "<BaseConverter: base%s (%s)>" % (len(self.digits), self.digits)
return "<%s: base%s (%s)>" % (self.__class__.__name__, len(self.digits), self.digits)
def encode(self, i):
neg, value = self.convert(i, self.decimal_digits, self.digits, '-')