Skip to content

Commit

Permalink
Remove six from metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Mar 23, 2022
1 parent 441f4a3 commit 78e03b2
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
6 changes: 3 additions & 3 deletions python/nav/metrics/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from datetime import datetime
import json
import logging
from six.moves.urllib.parse import urlencode, urljoin
from six.moves.urllib.request import Request, urlopen
from six.moves.urllib.error import HTTPError, URLError
from urllib.parse import urlencode, urljoin
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError

from nav.metrics import CONFIG, errors
from nav.metrics.templates import (
Expand Down
7 changes: 3 additions & 4 deletions python/nav/metrics/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
import re

from django.urls import reverse
import six
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode


TIMETICKS_IN_DAY = 100 * 3600 * 24
Expand Down Expand Up @@ -233,7 +232,7 @@ def get_simple_graph_url(
:return: The URL that will generate the requested graph.
"""
if isinstance(metric_paths, six.string_types):
if isinstance(metric_paths, str):
metric_paths = [metric_paths]

target_spec = (
Expand All @@ -245,7 +244,7 @@ def get_simple_graph_url(
if kwargs:
graph.args.update(kwargs)

return six.text_type(graph)
return str(graph)


def get_metric_meta(metric_path):
Expand Down
4 changes: 1 addition & 3 deletions python/nav/metrics/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import re

from nav.compatibility import lru_cache
from six import iteritems

from nav.models.manage import Netbox, Interface, Prefix, Sensor


Expand Down Expand Up @@ -113,7 +111,7 @@ def _reverse_prefix(netaddr):
def _single_like_match(model, related=None, **kwargs):
args = [
("{field}::TEXT LIKE %s".format(field=key), value)
for key, value in iteritems(kwargs)
for key, value in kwargs.items()
]
where, params = zip(*args)
qset = model.objects.extra(where=where, params=params)
Expand Down
6 changes: 3 additions & 3 deletions python/nav/metrics/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from collections import OrderedDict
import itertools
import json
from six.moves.urllib.parse import urlencode, urljoin
from six.moves.urllib.request import Request, urlopen
from six.moves.urllib.error import URLError
from urllib.parse import urlencode, urljoin
from urllib.request import Request, urlopen
from urllib.error import URLError
from nav.metrics import CONFIG, errors
import string

Expand Down
5 changes: 2 additions & 3 deletions python/nav/metrics/templates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (C) 2013 Uninett AS
# Copyright (C) 2022 Sikt
#
# This file is part of Network Administration Visualized (NAV).
#
Expand All @@ -17,8 +18,6 @@
Metric naming templates for various things that NAV sends/retrieves from
Graphite.
"""
import six

from nav.metrics.names import escape_metric_name

# pylint: disable=C0111
Expand Down Expand Up @@ -174,7 +173,7 @@ def metric_prefix_for_system(sysname):

def metric_prefix_for_multicast_group(group):
tmpl = "nav.multicast.groups.{group}"
return tmpl.format(group=escape_metric_name(six.text_type(group)))
return tmpl.format(group=escape_metric_name(str(group)))


def metric_path_for_multicast_usage(group, sysname):
Expand Down
7 changes: 3 additions & 4 deletions python/nav/metrics/thresholds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Copyright (C) 2013 Uninett AS
# Copyright (C) 2022 Sikt
#
# This file is part of Network Administration Visualized (NAV).
#
Expand Down Expand Up @@ -64,8 +65,6 @@
import logging
import re

from six import iteritems, iterkeys

from nav.metrics.data import get_metric_average
from nav.metrics.graphs import get_metric_meta, extract_series_name

Expand Down Expand Up @@ -149,7 +148,7 @@ def get_values(self):
)
self.result = dict(
(extract_series_name(key), dict(value=value))
for key, value in iteritems(averages)
for key, value in averages.items()
)
return self.result

Expand All @@ -169,7 +168,7 @@ def evaluate(self, expression, invert=False):
matcher = self._get_matcher(expression)
result = [
(metric, self.result[metric]['value'])
for metric in iterkeys(self.result)
for metric in self.result.keys()
if bool(matcher(metric)) ^ bool(invert)
]
return result
Expand Down

0 comments on commit 78e03b2

Please sign in to comment.