Skip to content

Commit

Permalink
Get rid of python_2_unicode_compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Oct 20, 2021
1 parent 9a36b38 commit 09312e0
Show file tree
Hide file tree
Showing 19 changed files with 3 additions and 124 deletions.
2 changes: 0 additions & 2 deletions python/nav/auditlog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import logging

from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.encoding import force_text
from django.utils.timezone import now as utcnow

Expand All @@ -30,7 +29,6 @@
_logger = logging.getLogger(__name__)


@python_2_unicode_compatible
class LogEntry(models.Model):
"""
Logs mostly user actions in NAV
Expand Down
2 changes: 0 additions & 2 deletions python/nav/macaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import string

import six
from django.utils.encoding import python_2_unicode_compatible

# A range of left shift values for the 6 bytes in a MAC address
_SHIFT_RANGE = tuple(x * 8 for x in reversed(range(6)))
Expand Down Expand Up @@ -177,7 +176,6 @@ def to_string(self, delim=None):
return _int_to_delimited_hexstring(self._addr, delim, DELIMS_AND_STEPS[delim])


@python_2_unicode_compatible
class MacPrefix(object):
"""Represents the prefix of a range of MacAddress objects.
Expand Down
2 changes: 0 additions & 2 deletions python/nav/models/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

from django.db import models
from django.urls import reverse
from django.utils.encoding import python_2_unicode_compatible

from nav.adapters import HStoreField
from nav.models.fields import VarcharField
from nav.models.profiles import Account


@python_2_unicode_compatible
class APIToken(models.Model):
"""APItokens are used for authenticating to the api
Expand Down
6 changes: 0 additions & 6 deletions python/nav/models/arnold.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# pylint: disable=R0903

from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from nav.models.fields import VarcharField
from nav.models.manage import Interface
Expand All @@ -35,7 +34,6 @@
KEEP_CLOSED_CHOICES = [('n', 'Open on move'), ('y', 'All closed')]


@python_2_unicode_compatible
class Identity(models.Model):
"""
The table contains a listing for each computer,interface combo Arnold
Expand Down Expand Up @@ -97,7 +95,6 @@ class Meta(object):
unique_together = ('mac', 'interface')


@python_2_unicode_compatible
class Event(models.Model):
"""A class representing an action taken"""

Expand All @@ -122,7 +119,6 @@ class Meta(object):
ordering = ('event_time',)


@python_2_unicode_compatible
class Justification(models.Model):
"""Represents the justification for an event"""

Expand All @@ -138,7 +134,6 @@ class Meta(object):
ordering = ('name',)


@python_2_unicode_compatible
class QuarantineVlan(models.Model):
"""A quarantine vlan is a vlan where offenders are placed"""

Expand All @@ -154,7 +149,6 @@ class Meta(object):
ordering = ('vlan',)


@python_2_unicode_compatible
class DetentionProfile(models.Model):
"""A detention profile is a configuration used by an automatic detention"""

Expand Down
3 changes: 0 additions & 3 deletions python/nav/models/cabling.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
"""Django ORM wrapper for the NAV manage database"""

from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from nav.models.manage import Room, Interface
from nav.models.fields import VarcharField


@python_2_unicode_compatible
class Cabling(models.Model):
"""From NAV Wiki: The cabling table documents the cabling from the wiring
closet's jack number to the end user's room number."""
Expand Down Expand Up @@ -61,7 +59,6 @@ def verbose(self):
)


@python_2_unicode_compatible
class Patch(models.Model):
"""From NAV Wiki: The patch table documents the cross connect from switch
port to jack."""
Expand Down
15 changes: 0 additions & 15 deletions python/nav/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from django.db import models
from django.db.models import Q
from django.utils.encoding import python_2_unicode_compatible
from django.core.validators import MaxValueValidator, MinValueValidator

from nav.models.fields import VarcharField, DateTimeInfinityField, UNRESOLVED
Expand All @@ -42,7 +41,6 @@
)


@python_2_unicode_compatible
class Subsystem(models.Model):
"""From NAV Wiki: Defines the subsystems that post or receives an event."""

Expand Down Expand Up @@ -175,7 +173,6 @@ def _update_variables(self, obj, vardict):
)


@python_2_unicode_compatible
class UnknownEventSubject(object):
"""Representation of unknown alert/event subjects"""

Expand Down Expand Up @@ -284,7 +281,6 @@ def _fetch_subject(self):
return self.netbox or self.device or UnknownEventSubject(self)


@python_2_unicode_compatible
class ThresholdEvent(object):
"""
Magic class to act as a threshold event subject that produces useful
Expand Down Expand Up @@ -337,7 +333,6 @@ def get_absolute_url(self):
return self.subject.netbox.get_absolute_url()


@python_2_unicode_compatible
class EventQueue(models.Model, EventMixIn):
"""From NAV Wiki: The event queue. Additional data in eventqvar. Different
subsystem (specified in source) post events on the event queue. Normally
Expand Down Expand Up @@ -418,7 +413,6 @@ def save(self, *args, **kwargs):
self.varmap = self.varmap


@python_2_unicode_compatible
class EventType(models.Model):
"""From NAV Wiki: Defines event types."""

Expand All @@ -440,7 +434,6 @@ def __str__(self):
return self.id


@python_2_unicode_compatible
class EventQueueVar(models.Model):
"""From NAV Wiki: Defines additional (key,value) tuples that follow
events."""
Expand All @@ -466,7 +459,6 @@ def __str__(self):
### Alert system


@python_2_unicode_compatible
class AlertQueue(models.Model, EventMixIn):
"""From NAV Wiki: The alert queue. Additional data in alertqvar and
alertmsg. Event engine posts alerts on the alert queue (and in addition on
Expand Down Expand Up @@ -535,7 +527,6 @@ def save(self, *args, **kwargs):
self.varmap = self.varmap


@python_2_unicode_compatible
class AlertType(models.Model):
"""From NAV Wiki: Defines the alert types. An event type may have many alert
types."""
Expand All @@ -555,7 +546,6 @@ def __str__(self):
return u'%s, of event type %s' % (self.name, self.event_type)


@python_2_unicode_compatible
class AlertQueueMessage(models.Model):
"""From NAV Wiki: Event engine will, based on alertmsg.conf, preformat the
alarm messages, one message for each configured alert channel (email, sms),
Expand All @@ -581,7 +571,6 @@ def __str__(self):
return u'%s message in language %s' % (self.type, self.language)


@python_2_unicode_compatible
class AlertQueueVariable(models.Model):
"""From NAV Wiki: Defines additional (key,value) tuples that follow alert.
Note: the eventqvar tuples are passed along to the alertqvar table so that
Expand Down Expand Up @@ -622,7 +611,6 @@ def unresolved(self, event_type_id=None):
return self.filter(filtr)


@python_2_unicode_compatible
class AlertHistory(models.Model, EventMixIn):
"""From NAV Wiki: The alert history. Simular to the alert queue with one
important distinction; alert history stores stateful events as one row,
Expand Down Expand Up @@ -724,7 +712,6 @@ def save(self, *args, **kwargs):
self.varmap = self.varmap


@python_2_unicode_compatible
class AlertHistoryMessage(models.Model):
"""From NAV Wiki: To have a history of the formatted messages too, they are
stored in alerthistmsg."""
Expand Down Expand Up @@ -756,7 +743,6 @@ def __str__(self):
return u'%s message in language %s' % (self.type, self.language)


@python_2_unicode_compatible
class AlertHistoryVariable(models.Model):
"""From NAV Wiki: Defines additional (key,value) tuples that follow the
alerthist record."""
Expand Down Expand Up @@ -787,7 +773,6 @@ def __str__(self):
return u'%s=%s' % (self.variable, self.value)


@python_2_unicode_compatible
class Acknowledgement(models.Model):
"""Alert acknowledgements"""

Expand Down
6 changes: 2 additions & 4 deletions python/nav/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@

import pickle
import json

from datetime import datetime
from decimal import Decimal

import six

import django
from django import forms
from django.db import models
from django.db.models import signals
from django.core import exceptions
from django.db.models import Q
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.apps import apps

from nav.util import is_valid_cidr, is_valid_ip
Expand Down Expand Up @@ -170,7 +169,6 @@ def formfield(self, **kwargs):
# this interfaces with Django model protocols, which generates unnecessary
# pylint violations:
# pylint: disable=W0201,W0212
@python_2_unicode_compatible
class LegacyGenericForeignKey(object):
"""Generic foreign key for legacy NAV database.
Expand Down
5 changes: 0 additions & 5 deletions python/nav/models/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@


from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from nav.models.fields import VarcharField


@python_2_unicode_compatible
class LoggerCategory(models.Model):
"""
Model for the logger.category-table
Expand All @@ -39,7 +37,6 @@ class Meta(object):
db_table = '"logger"."category"'


@python_2_unicode_compatible
class Origin(models.Model):
"""
Model for the logger.origin-table
Expand All @@ -58,7 +55,6 @@ class Meta(object):
db_table = '"logger"."origin"'


@python_2_unicode_compatible
class Priority(models.Model):
"""
Model for the logger.priority-table
Expand All @@ -75,7 +71,6 @@ class Meta(object):
db_table = '"logger"."priority"'


@python_2_unicode_compatible
class LogMessageType(models.Model):
"""
Model for the logger.log_message_type-table
Expand Down
Loading

0 comments on commit 09312e0

Please sign in to comment.