Skip to content

Commit

Permalink
Remove six from django
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Mar 23, 2022
1 parent c890973 commit f7c0396
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/nav/django/forms.py
@@ -1,5 +1,6 @@
#
# Copyright (C) 2011, 2018 Uninett AS
# Copyright (C) 2022 Sikt
#
# This file is part of Network Administration Visualized (NAV).
#
Expand All @@ -21,7 +22,6 @@

from django import forms
from django.forms import Field, Textarea
import six

from nav.util import is_valid_cidr
from nav.django import validators, widgets
Expand Down Expand Up @@ -52,7 +52,7 @@ def _render_value(self, value):
Falsey values are converted to an empty string. Bytestrings are
considered to be encoded as utf-8 and converted to text."""
if value and not isinstance(value, six.string_types):
if value and not isinstance(value, str):
value = json.dumps(
value, sort_keys=True, indent=4, cls=validators.JSONBytesEncoder
)
Expand Down
2 changes: 1 addition & 1 deletion python/nav/django/templatetags/report.py
Expand Up @@ -2,7 +2,7 @@
from django import template
from django.template.defaultfilters import stringfilter
from django.urls import reverse
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode


register = template.Library()
Expand Down
7 changes: 3 additions & 4 deletions python/nav/django/validators.py
Expand Up @@ -20,7 +20,6 @@
import json
from decimal import Decimal, InvalidOperation

import six
from django.utils.translation import gettext
from django.core.exceptions import ValidationError

Expand All @@ -42,7 +41,7 @@ def is_valid_point_string(point_string):

class JSONBytesEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, six.binary_type):
if isinstance(obj, bytes):
return obj.decode('utf-8')
return super(JSONBytesEncoder, self).default(self, obj)

Expand All @@ -56,11 +55,11 @@ def validate_hstore(value):
# ensure valid JSON
try:
# work on unicode strings only
if isinstance(value, six.binary_type):
if isinstance(value, bytes):
value = value.decode('utf-8')

# convert strings to dictionaries
if isinstance(value, six.text_type):
if isinstance(value, str):
dictionary = json.loads(value)

# if not a string we'll check at the next control if it's a dict
Expand Down

0 comments on commit f7c0396

Please sign in to comment.