Python3: Use __str__ instead of __unicode

...also no unicode strings.
This commit is contained in:
Sebastian Lohff 2020-05-31 01:49:03 +02:00
parent 525d8a724d
commit b9956c0246
1 changed files with 16 additions and 16 deletions

View File

@ -19,8 +19,8 @@ class ConfigHost(models.Model):
ip = models.GenericIPAddressField()
checkMethod = models.CharField(max_length=4, choices=CHECK_CHOICES)
def __unicode__(self):
return u"%s (%s / %s)" % (self.name, self.number, self.ip)
def __str__(self):
return "%s (%s / %s)" % (self.name, self.number, self.ip)
class CrawlRun(models.Model):
# time start, time end,
@ -34,8 +34,8 @@ class CrawlRun(models.Model):
asOfflineCount = models.IntegerField(default=0)
peeringCount = models.IntegerField(default=0)
def __unicode__(self):
return u"Run %d - %s to %s" % (self.pk, self.startTime, self.endTime if self.endTime else "?")
def __str__(self):
return "Run %d - %s to %s" % (self.pk, self.startTime, self.endTime if self.endTime else "?")
def countAS(self):
return self.asCount
@ -78,9 +78,9 @@ class CrawlLog(models.Model):
log.host = host
log.save()
def __unicode__(self):
def __str__(self):
host = "host %s - " % self.host.name if self.host else ""
return u"Log %s %s: %s%s" % (self.get_severity_display(), self.logtime, host, self.message)
return "Log %s %s: %s%s" % (self.get_severity_display(), self.logtime, host, self.message)
class AS(models.Model):
# asno
@ -97,8 +97,8 @@ class AS(models.Model):
('crawl', 'number'),
)
def __unicode__(self):
return u"AS %s (crawl %d)" % (self.number, self.crawl.pk)
def __str__(self):
return "AS %s (crawl %d)" % (self.number, self.crawl.pk)
def setOnline(self):
if not self.online:
@ -125,10 +125,10 @@ class BorderRouter(models.Model):
pingable = models.BooleanField(default=False)
reachable = models.BooleanField(default=False)
def __unicode__(self):
def __str__(self):
p = "p" if self.pingable else "!p"
r = "r" if self.reachable else "!r"
return u"Router %s (AS %s, %s%s)" % (self.routerID, self.AS.number, p, r)
return "Router %s (AS %s, %s%s)" % (self.routerID, self.AS.number, p, r)
class Announcement(models.Model):
router = models.ForeignKey(BorderRouter)
@ -142,8 +142,8 @@ class Announcement(models.Model):
originAS = models.ForeignKey(AS, null=True)
crawlAS = models.ForeignKey(AS, related_name='crawl_as', null=True)
def __unicode__(self):
return u"%s/%s via %s (crawl %s)" % (self.ip, self.prefix, self.ASPath, self.router.AS.crawl.pk)
def __str__(self):
return "%s/%s via %s (crawl %s)" % (self.ip, self.prefix, self.ASPath, self.router.AS.crawl.pk)
class Peering(models.Model):
DIRECT = 'direct'
@ -162,8 +162,8 @@ class Peering(models.Model):
as2 = models.ForeignKey(AS, related_name='peering2')
origin = models.CharField(max_length=10, choices=ORIGIN)
def __unicode__(self):
return u"AS %s <--> AS %s (%s, crawl %s)" % (self.as1.number, self.as2.number, self.get_origin_display(), self.as1.crawl.pk)
def __str__(self):
return "AS %s <--> AS %s (%s, crawl %s)" % (self.as1.number, self.as2.number, self.get_origin_display(), self.as1.crawl.pk)
def containsAS(self, AS):
return AS in (self.as1, self.as2)
@ -181,8 +181,8 @@ class BorderRouterPair(models.Model):
router1 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair1')
router2 = models.ForeignKey(BorderRouter, default=None, blank=True, null=True, related_name='routerpair2')
def __unicode__(self):
return u"%s <--> %s (crawl %d)" % (self.router1, self.router2, self.router1.AS.crawl.pk)
def __str__(self):
return "%s <--> %s (crawl %d)" % (self.router1, self.router2, self.router1.AS.crawl.pk)
@staticmethod
def getPairing(peering, router1, router2):