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