From 4c9e477db003d25ab89391234a6cb80514cafc72 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Mon, 21 Mar 2022 13:25:56 +0100 Subject: [PATCH] Remove six from other parts --- python/nav/asyncdns.py | 5 ++--- python/nav/bitvector.py | 9 +++----- python/nav/bulkimport.py | 8 +++---- python/nav/bulkparse.py | 19 +++++++--------- python/nav/colors.py | 7 ++---- python/nav/config.py | 6 ++--- python/nav/event2.py | 5 ++--- python/nav/eventengine/config.py | 5 ++--- python/nav/eventengine/export.py | 8 +++---- python/nav/ipdevpoll/utils.py | 1 - python/nav/logengine.py | 14 +++--------- python/nav/macaddress.py | 35 +++++++++++++---------------- python/nav/oidparsers.py | 7 +++--- python/nav/oids.py | 7 +++--- python/nav/pwhash.py | 6 ++--- python/nav/six.py | 38 -------------------------------- python/nav/startstop.py | 3 +-- python/nav/tableformat.py | 7 +++--- python/nav/thresholdmon.py | 8 +++---- python/nav/util.py | 11 ++++----- python/pylint.rc | 2 +- requirements/base.txt | 3 --- tools/iana-enterprise.py | 3 ++- 23 files changed, 69 insertions(+), 148 deletions(-) delete mode 100644 python/nav/six.py diff --git a/python/nav/asyncdns.py b/python/nav/asyncdns.py index ab83c9b3b4..cac80ffe00 100644 --- a/python/nav/asyncdns.py +++ b/python/nav/asyncdns.py @@ -1,5 +1,6 @@ # # Copyright (C) 2008-2011 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -44,8 +45,6 @@ from twisted.names.error import DNSServerError, DNSNameError from twisted.names.error import DNSNotImplementedError, DNSQueryRefusedError -import six - def reverse_lookup(addresses): """Runs parallel reverse DNS lookups for addresses. @@ -136,7 +135,7 @@ class ForwardResolver(Resolver): def lookup(self, name): """Returns a deferred object with all records related to hostname""" - if isinstance(name, six.text_type): + if isinstance(name, str): name = name.encode('idna') resolver = next(self._resolvers) diff --git a/python/nav/bitvector.py b/python/nav/bitvector.py index 7461b245fc..b4aa4f2b00 100644 --- a/python/nav/bitvector.py +++ b/python/nav/bitvector.py @@ -1,5 +1,6 @@ # # Copyright (C) 2007, 2009 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -18,10 +19,6 @@ import array import re -import six - -from .six import encode_array - class BitVector(object): """ @@ -38,7 +35,7 @@ def __init__(self, octetstring): self.vector = array.array("B", octetstring) def to_bytes(self): - return encode_array(self.vector) + return self.vector.tobytes() def __len__(self): return len(self.vector) * 8 @@ -85,7 +82,7 @@ def from_hex(cls, hexstring): if len(hexstring) % 2 != 0: raise ValueError("hexstring must contain an even number of digits") hex_octets = [hexstring[i : i + 2] for i in range(0, len(hexstring), 2)] - octetstring = b''.join([six.int2byte(int(octet, 16)) for octet in hex_octets]) + octetstring = b''.join([bytes((int(octet, 16),)) for octet in hex_octets]) return cls(octetstring) def to_binary(self): diff --git a/python/nav/bulkimport.py b/python/nav/bulkimport.py index 680bbdff2d..325421f1a7 100644 --- a/python/nav/bulkimport.py +++ b/python/nav/bulkimport.py @@ -1,5 +1,6 @@ # # Copyright (C) 2010, 2011, 2013-2015 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -22,7 +23,6 @@ import json from django.core.exceptions import ValidationError -import six from nav.models.fields import PointField from nav.models.manage import Netbox, Room, Organization @@ -39,7 +39,7 @@ from nav.bulkparse import BulkParseError -class BulkImporter(six.Iterator): +class BulkImporter: """Abstract bulk import iterator""" def __init__(self, parser): @@ -51,7 +51,7 @@ def __iter__(self): def __next__(self): """Parses and returns next line""" try: - row = six.next(self.parser) + row = next(self.parser) row = self._decode_as_utf8(row) objects = self._create_objects_from_row(row) except BulkParseError as error: @@ -62,7 +62,7 @@ def __next__(self): def _decode_as_utf8(row): """Decodes all unicode values in row as utf-8 strings""" for key, value in row.items(): - if isinstance(value, six.binary_type): + if isinstance(value, bytes): row[key] = value.decode('utf-8') return row diff --git a/python/nav/bulkparse.py b/python/nav/bulkparse.py index 4e5cf10399..5096cdcfeb 100644 --- a/python/nav/bulkparse.py +++ b/python/nav/bulkparse.py @@ -1,5 +1,6 @@ # # Copyright (C) 2010-2015 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -22,7 +23,6 @@ import io import json -import six from IPy import IP from nav.django.validators import is_valid_point_string @@ -37,7 +37,7 @@ ) -class BulkParser(six.Iterator): +class BulkParser: """Abstract base class for bulk parsers""" format = () @@ -49,13 +49,10 @@ def __init__(self, data, delimiter=None): if hasattr(data, 'seek'): self.data = data else: - if six.PY3: - if isinstance(data, six.binary_type): - self.data = io.StringIO(data.decode('utf-8')) - else: - self.data = io.StringIO(data) + if isinstance(data, bytes): + self.data = io.StringIO(data.decode('utf-8')) else: - self.data = io.BytesIO(data) + self.data = io.StringIO(data) if delimiter is None: try: @@ -85,7 +82,7 @@ def __iter__(self): def __next__(self): """Generate next parsed row""" - row = six.next(self.reader) + row = next(self.reader) # although the DictReader doesn't return blank lines, we want # to count them so we can pinpoint errors exactly within the # source file. @@ -139,7 +136,7 @@ def get_header(cls): # don't complain about simple iterators, mr. Pylint! # pylint: disable=R0903 -class CommentStripper(six.Iterator): +class CommentStripper: """Iterator that strips comments from the input iterator""" COMMENT_PATTERN = re.compile(r'\W*#[^\n\r]*') @@ -152,7 +149,7 @@ def __iter__(self): def __next__(self): """Returns next line""" - line = six.next(self.source_iterator) + line = next(self.source_iterator) return self.COMMENT_PATTERN.sub('', line) diff --git a/python/nav/colors.py b/python/nav/colors.py index 632302a339..cdfcfa232b 100644 --- a/python/nav/colors.py +++ b/python/nav/colors.py @@ -1,5 +1,6 @@ # # Copyright (C) 2013, 2019 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -31,7 +32,6 @@ COLOR_WHITE, COLOR_YELLOW, ) -import six __all__ = [ 'COLOR_BLACK', @@ -63,10 +63,7 @@ if not _set_color: _is_term = False -if six.PY3: - _term = sys.stdout.buffer -else: - _term = sys.stdout +_term = sys.stdout.buffer def colorize(color): diff --git a/python/nav/config.py b/python/nav/config.py index e6ba866fa2..127c83ea5c 100644 --- a/python/nav/config.py +++ b/python/nav/config.py @@ -29,8 +29,6 @@ import configparser import pkg_resources -import six - from nav.errors import GeneralException from . import buildconf @@ -80,7 +78,7 @@ def read_flat_config(config_file, delimiter='='): :returns: dictionary of the key/value pairs that were read. """ - if isinstance(config_file, six.string_types): + if isinstance(config_file, str): config_file = open_configfile(config_file) configuration = {} @@ -109,7 +107,7 @@ def getconfig(configfile, defaults=None): section as values. """ - if isinstance(configfile, six.string_types): + if isinstance(configfile, str): configfile = open_configfile(configfile) config = configparser.RawConfigParser(defaults) diff --git a/python/nav/event2.py b/python/nav/event2.py index b0d75783f0..668691a985 100644 --- a/python/nav/event2.py +++ b/python/nav/event2.py @@ -1,5 +1,6 @@ # # Copyright (C) 2015 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -19,8 +20,6 @@ """ from __future__ import absolute_import -import six - from nav.models.event import EventQueue @@ -69,7 +68,7 @@ def base(self, device=None, netbox=None, subid='', varmap=None, alert_type=None) else: event.netbox = netbox - event.subid = six.text_type(subid) + event.subid = str(subid) var = dict(varmap or {}) if alert_type: diff --git a/python/nav/eventengine/config.py b/python/nav/eventengine/config.py index eece664f52..ac9652df3f 100644 --- a/python/nav/eventengine/config.py +++ b/python/nav/eventengine/config.py @@ -1,5 +1,6 @@ # # Copyright (C) 2012 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -17,8 +18,6 @@ from __future__ import unicode_literals from configparser import NoSectionError, NoOptionError -import six - from nav.config import NAVConfigParser from nav.util import parse_interval @@ -49,7 +48,7 @@ def get_timeout_for(self, option): an int, option is returned unchanged. """ - if isinstance(option, six.integer_types): + if isinstance(option, int): return option try: return parse_interval(self.get('timeouts', option)) diff --git a/python/nav/eventengine/export.py b/python/nav/eventengine/export.py index d69734fd00..0379d67a81 100644 --- a/python/nav/eventengine/export.py +++ b/python/nav/eventengine/export.py @@ -1,5 +1,6 @@ # -# Copyright (C) 2019 UNINETT +# Copyright (C) 2019 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -23,7 +24,6 @@ import subprocess32 as subprocess except ImportError: import subprocess -import six from nav.web.api.v1.alert_serializers import AlertQueueSerializer @@ -86,8 +86,6 @@ def export(self, alert): def _send_string(self, string): if self.is_ok(): self._process.stdin.write( - string - if not isinstance(string, six.text_type) - else string.encode("utf-8") + string if not isinstance(string, str) else string.encode("utf-8") ) self._process.stdin.flush() diff --git a/python/nav/ipdevpoll/utils.py b/python/nav/ipdevpoll/utils.py index 0cbcb9e9a4..13bdd1826d 100644 --- a/python/nav/ipdevpoll/utils.py +++ b/python/nav/ipdevpoll/utils.py @@ -22,7 +22,6 @@ from IPy import IP -import six from twisted.internet import defer from twisted.internet.defer import Deferred from twisted.internet import reactor diff --git a/python/nav/logengine.py b/python/nav/logengine.py index 3f79eaec5c..c38e00f805 100644 --- a/python/nav/logengine.py +++ b/python/nav/logengine.py @@ -54,8 +54,6 @@ import datetime import optparse -import six - import nav import nav.logs from nav import db @@ -322,10 +320,7 @@ def read_log_lines(config): logfile = None # open log try: - if six.PY3: - logfile = open(filename, "r+", encoding=charset) - else: - logfile = open(filename, "r+") + logfile = open(filename, "r+", encoding=charset) except IOError as err: # If logfile can't be found, we ignore it. We won't needlessly # spam the NAV admin every minute with a file not found error! @@ -350,9 +345,6 @@ def read_log_lines(config): logfile.close() for line in fcon: - if six.PY2: - # Make sure the data is encoded as UTF-8 before we begin work on it - line = line.decode(charset).encode("UTF-8") yield line @@ -454,7 +446,7 @@ def add_category(category, categories, database): def add_origin(origin, category, origins, database): database.execute("SELECT nextval('origin_origin_seq')") originid = database.fetchone()[0] - assert isinstance(originid, six.integer_types) + assert isinstance(originid, int) database.execute( "INSERT INTO origin (origin, name, " "category) VALUES (%s, %s, %s)", (originid, origin, category), @@ -466,7 +458,7 @@ def add_origin(origin, category, origins, database): def add_type(facility, mnemonic, priorityid, types, database): database.execute("SELECT nextval('log_message_type_type_seq')") typeid = int(database.fetchone()[0]) - assert isinstance(typeid, six.integer_types) + assert isinstance(typeid, int) database.execute( "INSERT INTO log_message_type (type, facility, " diff --git a/python/nav/macaddress.py b/python/nav/macaddress.py index 1907789c23..99993d3e43 100644 --- a/python/nav/macaddress.py +++ b/python/nav/macaddress.py @@ -37,8 +37,6 @@ # pylint: disable=W0402 import string -import six - # 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))) # Legal delimiters and the number of nybbles between them. @@ -55,9 +53,6 @@ # Obviously number of bits for a nybble. NUM_BITS_IN_NYBBLE = 4 -if six.PY3: - long = int - class MacAddress(object): """A representation of a single MAC address""" @@ -75,11 +70,11 @@ def __init__(self, addr): # pylint: disable=W0212 if isinstance(addr, MacAddress): self._addr = addr._addr - elif isinstance(addr, six.integer_types): - self._addr = long(addr) + elif isinstance(addr, int): + self._addr = addr if self._addr < 0 or self._addr > self.MAX_MAC_ADDR_VALUE: raise ValueError('Illegal value for MacAddress') - elif isinstance(addr, six.string_types): + elif isinstance(addr, str): self._addr = self._parse_address_string(addr) else: raise ValueError('Illegal parameter-type') @@ -90,23 +85,23 @@ def from_octets(cls, binary_mac): hexstring = octets_to_hexstring(binary_mac) return cls(hexstring.rjust(MAC_ADDR_NYBBLES, "0")) - def tolong(self): - """Returns a long integer representation of this MacAddress""" + def toint(self): + """Returns an integer representation of this MacAddress""" return self._addr @staticmethod def _parse_address_string(addr): - """Parses the mac-address string and returns a long int + """Parses the mac-address string and returns an int representation of it """ - if not isinstance(addr, six.string_types): + if not isinstance(addr, str): raise TypeError('addr argument must be string or unicode') addr = _clean_hexstring(addr) if len(addr) != MAC_ADDR_NYBBLES: raise ValueError('Mac-address must be %s nybbles long' % MAC_ADDR_NYBBLES) - addr_bytes = [long(addr[x : x + 2], 16) for x in range(0, len(addr), 2)] + addr_bytes = [int(addr[x : x + 2], 16) for x in range(0, len(addr), 2)] addr = sum(n << shift for n, shift in zip(addr_bytes, _SHIFT_RANGE)) return addr @@ -193,7 +188,7 @@ class MacPrefix(object): MIN_PREFIX_LEN = 6 def __init__(self, prefix, min_prefix_len=MIN_PREFIX_LEN): - prefix = _clean_hexstring(six.text_type(prefix)) + prefix = _clean_hexstring(str(prefix)) self._mask_len = len(prefix) if self._mask_len < min_prefix_len: @@ -248,7 +243,7 @@ def __getitem__(self, key): >>> ma[-1] MacAddress('e4:23:1d:ff:ff:ff') """ - if not isinstance(key, six.integer_types): + if not isinstance(key, int): raise TypeError if key < 0: if abs(key) <= len(self): @@ -258,10 +253,10 @@ def __getitem__(self, key): else: if key >= len(self): raise IndexError - return MacAddress(self._base.tolong() + long(key)) + return MacAddress(self._base.toint() + int(key)) def __str__(self): - base = six.text_type(self._base) + base = str(self._base) digitpos = [pos for pos, char in enumerate(base) if char in string.hexdigits] digitpos = digitpos[self._mask_len - 1] base = base[: digitpos + 1] @@ -292,7 +287,7 @@ def _int_to_delimited_hexstring(mac_addr, delim, step): def octets_to_hexstring(octets): """Converts an octet string to a printable hexadecimal string""" - if isinstance(octets, six.binary_type): - return ''.join("%02x" % byte for byte in six.iterbytes(octets)) + if isinstance(octets, bytes): + return ''.join("%02x" % byte for byte in octets) else: - return ''.join("%02x" % ord(byte) for byte in six.iterbytes(octets)) + return ''.join("%02x" % ord(byte) for byte in octets) diff --git a/python/nav/oidparsers.py b/python/nav/oidparsers.py index 7e1abe2dea..d4470f6dd5 100644 --- a/python/nav/oidparsers.py +++ b/python/nav/oidparsers.py @@ -1,5 +1,6 @@ # # Copyright (C) 2016 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -30,8 +31,6 @@ from IPy import IP from .oids import OID -from .six import encode_array - IPV4_ID = 1 IPV6_ID = 2 @@ -70,7 +69,7 @@ def oid_to_ipv6(oid): if len(oid) != 16: raise ValueError("IPv6 address must be 16 octets, not %d" % len(oid)) try: - high, low = unpack("!QQ", encode_array(array.array("B", oid))) + high, low = unpack("!QQ", array.array("B", oid).tobytes()) except OverflowError as error: raise ValueError(error) addr = (high << 64) + low @@ -87,7 +86,7 @@ def oid_to_ipv4(oid): if len(oid) != 4: raise ValueError("IPv4 address must be 4 octets, not %d" % len(oid)) try: - (addr,) = unpack("!I", encode_array(array.array("B", oid))) + (addr,) = unpack("!I", array.array("B", oid).tobytes()) except OverflowError as error: raise ValueError(error) return IP(addr, ipversion=4) diff --git a/python/nav/oids.py b/python/nav/oids.py index afc3f6585b..33df829556 100644 --- a/python/nav/oids.py +++ b/python/nav/oids.py @@ -1,5 +1,6 @@ # # Copyright (C) 2011 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -16,8 +17,6 @@ """OID manipulation""" from __future__ import absolute_import -import six - SEPARATOR = '.' SEPARATOR_B = b'.' @@ -45,9 +44,9 @@ class OID(tuple): """ def __new__(cls, oid): - if isinstance(oid, six.string_types): + if isinstance(oid, str): oid = map(int, oid.strip(SEPARATOR).split(SEPARATOR)) - elif isinstance(oid, six.binary_type): + elif isinstance(oid, bytes): oid = map(int, oid.strip(SEPARATOR_B).split(SEPARATOR_B)) elif isinstance(oid, OID): return oid diff --git a/python/nav/pwhash.py b/python/nav/pwhash.py index cc63f57ad1..c182811d7b 100644 --- a/python/nav/pwhash.py +++ b/python/nav/pwhash.py @@ -23,8 +23,6 @@ import base64 import re -import six - from django.utils import crypto from nav import errors @@ -104,9 +102,9 @@ def update(self, password): """Update the hash with a new password.""" salt = self.salt - if isinstance(salt, six.text_type): + if isinstance(salt, str): salt = salt.encode('utf-8') - if isinstance(password, six.text_type): + if isinstance(password, str): password = password.encode('utf-8') hasher = KNOWN_METHODS[self.method] diff --git a/python/nav/six.py b/python/nav/six.py deleted file mode 100644 index b4b0368449..0000000000 --- a/python/nav/six.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (C) 2019 Uninett AS -# -# This file is part of Network Administration Visualized (NAV). -# -# NAV is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License version 3 as published by -# the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. You should have received a copy of the GNU General Public License -# along with NAV. If not, see . -# -""" -Various functions that we need to keep code in python2 and python3 looking the -same that six lacks. - -""" -from __future__ import absolute_import - -import six - -if six.PY3: - - def encode_array(array): - return array.tobytes() - -else: - - def encode_array(array): - return array.tostring() - - -__all__ = [ - 'encode_array', -] diff --git a/python/nav/startstop.py b/python/nav/startstop.py index 908460f20a..693f4845ad 100644 --- a/python/nav/startstop.py +++ b/python/nav/startstop.py @@ -27,7 +27,6 @@ import re import yaml -import six from nav.config import open_configfile, find_config_file, NAV_CONFIG from nav.errors import GeneralException @@ -428,7 +427,7 @@ def __getitem__(self, key): def __setitem__(self, key, content): block = ['##block %s##' % key, '##end##'] - if isinstance(content, six.string_types): + if isinstance(content, str): block[1:1] = content.split('\n') else: block[1:1] = content diff --git a/python/nav/tableformat.py b/python/nav/tableformat.py index 14ee517059..df6da358df 100644 --- a/python/nav/tableformat.py +++ b/python/nav/tableformat.py @@ -1,5 +1,6 @@ # # Copyright (C) 2010 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -16,8 +17,6 @@ """Formatting of table data to readable text.""" from __future__ import absolute_import -import six - class SimpleTableFormatter(object): def __init__(self, data): @@ -45,7 +44,7 @@ def _format_row(self, row, widths): new_row = [] for index, cell in enumerate(row): fmt = u"%%%ds" % widths[index] - new_row.append(fmt % six.text_type(cell)) + new_row.append(fmt % str(cell)) return ' | '.join(new_row) def _find_widest_elements(self): @@ -57,7 +56,7 @@ def _find_widest_elements(self): return max_widths def _get_max_width_of_column(self, column_number): - widths = [len(six.text_type(row[column_number])) for row in self.data] + widths = [len(str(row[column_number])) for row in self.data] return max(widths) def _get_column_count(self): diff --git a/python/nav/thresholdmon.py b/python/nav/thresholdmon.py index 49db399ebd..7ded29de10 100644 --- a/python/nav/thresholdmon.py +++ b/python/nav/thresholdmon.py @@ -1,5 +1,6 @@ # # Copyright (C) 2013 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -23,7 +24,6 @@ import django from django.db import transaction -import six from nav import buildconf from nav.logs import init_generic_logging @@ -176,11 +176,11 @@ def make_event(start, rule, metric, value): varmap = dict( metric=metric, alert=rule.alert, - ruleid=six.text_type(rule.id), - measured_value=six.text_type(value), + ruleid=str(rule.id), + measured_value=str(value), ) if rule.clear: - varmap['clear'] = six.text_type(rule.clear) + varmap['clear'] = str(rule.clear) _add_subject_details(event, metric, varmap) event.save() diff --git a/python/nav/util.py b/python/nav/util.py index f72efa657e..7e8cd6d207 100644 --- a/python/nav/util.py +++ b/python/nav/util.py @@ -27,9 +27,6 @@ from itertools import chain, tee, groupby, islice from operator import itemgetter -import six -from six.moves import range - import IPy @@ -108,7 +105,7 @@ def _is_valid_ip_ipy(ip): A cleaned up version of the IP address string is returned if it is verified, otherwise a false value is returned. """ - if isinstance(ip, six.string_types) and not ip.isdigit(): + if isinstance(ip, str) and not ip.isdigit(): try: valid_ip = IPy.IP(ip) if valid_ip.len() == 1: @@ -126,7 +123,7 @@ def is_valid_cidr(cidr): Uses the IPy library to verify addresses. """ - if isinstance(cidr, six.string_types) and not cidr.isdigit() and '/' in cidr: + if isinstance(cidr, str) and not cidr.isdigit() and '/' in cidr: try: valid_cidr = IPy.IP(cidr) is not None except (ValueError, TypeError): @@ -218,7 +215,7 @@ def first_true(iterable, default=None, pred=None): :param pred: Optional predicate function to evaluate the truthfulness of elements. """ - return next(six.moves.filter(pred, iterable), default) + return next(filter(pred, iterable), default) def chunks(iterable, size): @@ -475,7 +472,7 @@ def auth_token(): """Generates a hash that can be used as an OAuth API token""" from django.conf import settings - _hash = hashlib.sha1(six.text_type(uuid.uuid4()).encode('utf-8')) + _hash = hashlib.sha1(str(uuid.uuid4()).encode('utf-8')) _hash.update(settings.SECRET_KEY.encode('utf-8')) return _hash.hexdigest() diff --git a/python/pylint.rc b/python/pylint.rc index eb74c93840..762ea35387 100644 --- a/python/pylint.rc +++ b/python/pylint.rc @@ -162,7 +162,7 @@ ignore-mixin-members=yes # List of module names for which member attributes should not be checked # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis -ignored-modules=ldap,six,django.utils.six.moves,_MovedItems,nav.junos.nav_views,jnpr.junos.op +ignored-modules=ldap,_MovedItems,nav.junos.nav_views,jnpr.junos.op # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). diff --git a/requirements/base.txt b/requirements/base.txt index 56cd467aad..109d5952da 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -34,6 +34,3 @@ pynetsnmp-2>=0.1.8,<0.2.0 libsass==0.15.1 napalm==3.0.1 - -# Remove when rid of Django 2.2 -six diff --git a/tools/iana-enterprise.py b/tools/iana-enterprise.py index 347b863a51..6247b4b734 100755 --- a/tools/iana-enterprise.py +++ b/tools/iana-enterprise.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # # Copyright (C) 2015 Uninett AS +# Copyright (C) 2022 Sikt # # This file is part of Network Administration Visualized (NAV). # @@ -22,7 +23,7 @@ import sys import os from collections import namedtuple, Counter -from six.moves.urllib.request import urlopen +from urllib.request import urlopen import re import string from datetime import datetime