Skip to content

Commit

Permalink
Format with new black version 24.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Jul 3, 2024
1 parent b8ca8ba commit 41a21ac
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion python/nav/bin/pping.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def generate_events(self):

down_now = []
# Find out which netboxes to consider down
for (netboxid, replies) in self.replies.items():
for netboxid, replies in self.replies.items():
if replies[: self._nrping] == [-1] * self._nrping:
down_now.append(netboxid)

Expand Down
1 change: 1 addition & 0 deletions python/nav/buildconf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NAV build configuration variables."""

# pylint: disable=invalid-name
import os
import sysconfig
Expand Down
2 changes: 1 addition & 1 deletion python/nav/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def switchuser(username):

# Set non-primary groups
gids = []
for (_name, _passwd, gid, members) in grp.getgrall():
for _name, _passwd, gid, members in grp.getgrall():
if username in members:
gids.append(gid)
if gids:
Expand Down
2 changes: 1 addition & 1 deletion python/nav/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def log_stacktrace(logger, stacktrace):
return

dump = []
for (frame, filename, line_no, func, source, _) in stacktrace:
for frame, filename, line_no, func, source, _ in stacktrace:
dump.append(" File %r, line %s, in %s" % (filename, line_no, func))
for line in source:
dump.append(" %s" % line.rstrip())
Expand Down
1 change: 1 addition & 0 deletions python/nav/django/templatetags/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Template tags used in report subsystem"""

from django import template
from django.template.defaultfilters import stringfilter
from django.urls import reverse
Expand Down
1 change: 1 addition & 0 deletions python/nav/django/templatetags/string_manipulation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Template filters for string manipulation"""

import re

from django import template
Expand Down
1 change: 1 addition & 0 deletions python/nav/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class GeneralException(Exception):
"General exception"

# Just subclass this with a new doc-string
def __str__(self):
# Returns a nice version of the docstring
Expand Down
4 changes: 1 addition & 3 deletions python/nav/eventengine/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ def _get_target_dgram_addr(target):
a SOCK_DGRAM socket type.
"""
for (family, socktype, _proto, _canonname, sockaddr) in socket.getaddrinfo(
target, 1
):
for family, socktype, _proto, _canonname, sockaddr in socket.getaddrinfo(target, 1):
if socktype == socket.SOCK_DGRAM:
return family, sockaddr
1 change: 0 additions & 1 deletion python/nav/ipdevpoll/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


class Plugin(object):

"""Abstract class providing common functionality for all polling plugins.
Do *NOT* create instances of the base class.
Expand Down
3 changes: 1 addition & 2 deletions python/nav/ipdevpoll/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def __init__(self, msg=None, cause=None, delay=60):


class JobHandler(object):

"""Handles a single polling job against a single netbox.
An instance of this class performs a polling job, as described by
Expand Down Expand Up @@ -191,7 +190,7 @@ def _get_willing_plugins(self, plugin_classes):
else:
unwilling_plugins.append(cls)

for (willingness, plugins) in [
for willingness, plugins in [
('unwilling', unwilling_plugins),
('willing', willing_plugins),
]:
Expand Down
2 changes: 1 addition & 1 deletion python/nav/ipdevpoll/plugins/arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _make_new_mappings(self, mappings):
timestamp = datetime.now()
infinity = datetime.max

for (ip, mac) in mappings:
for ip, mac in mappings:
if not ip or not mac:
continue # Some devices seem to return empty results!
arp = self.containers.factory((ip, mac), shadows.Arp)
Expand Down
16 changes: 10 additions & 6 deletions python/nav/mibs/cpqpower_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
'precision': 2,
'name': 'Group {pdu3GroupName} Current',
'minimum': 0,
'maximum': lambda x: x.get('pdu3groupCurrentRating') / 100
if x.get('pdu3groupCurrentRating') > 0
else None,
'maximum': lambda x: (
x.get('pdu3groupCurrentRating') / 100
if x.get('pdu3groupCurrentRating') > 0
else None
),
},
'pdu3GroupPowerVA': {
'unit_of_measurement': Sensor.UNIT_VOLTAMPERES,
Expand Down Expand Up @@ -88,9 +90,11 @@
'precision': 2,
'name': 'Input {pdu3InputPhaseCurrentMeasType} Current',
'minimum': 0,
'maximum': lambda x: x.get('pdu3InputPhaseCurrentRating') / 100
if x.get('pdu3InputPhaseCurrentRating') > 0
else None,
'maximum': lambda x: (
x.get('pdu3InputPhaseCurrentRating') / 100
if x.get('pdu3InputPhaseCurrentRating') > 0
else None
),
},
'pdu3InputPhasePowerVA': {
'unit_of_measurement': Sensor.UNIT_VOLTAMPERES,
Expand Down
6 changes: 3 additions & 3 deletions python/nav/mibs/juniper_mib.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def _fru_row_to_powersupply_or_fan(fru_row):
model = fru_row.get("jnxContentsModel")
psu_or_fan = PowerSupplyOrFan(
name=fru_row.get("jnxFruName"),
physical_class="powerSupply"
if fru_row.get("jnxFruType") == "powerEntryModule"
else "fan",
physical_class=(
"powerSupply" if fru_row.get("jnxFruType") == "powerEntryModule" else "fan"
),
descr=model,
internal_id=fru_row.get(0),
)
Expand Down
1 change: 1 addition & 0 deletions python/nav/models/images.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Models for uploaded image information"""

import os
from os.path import exists, join

Expand Down
2 changes: 1 addition & 1 deletion python/nav/portadmin/snmp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _get_if_stats(self, stats):
"""Make a list with tuples. Each tuple contain
interface-index and corresponding status-value"""
available_stats = []
for (if_index, stat) in stats:
for if_index, stat in stats:
if_index = OID(if_index)[-1]
if isinstance(if_index, int):
available_stats.append((if_index, stat))
Expand Down
2 changes: 1 addition & 1 deletion python/nav/smsd/navdbqueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def getmsgs(self, sent='N'):
db.execute(sql, data)

result = []
for (smsqid, name, msg, time) in db.fetchall():
for smsqid, name, msg, time in db.fetchall():
result.append(
dict(
id=smsqid, name=name, msg=msg, time=time.strftime("%Y-%m-%d %H:%M")
Expand Down
2 changes: 1 addition & 1 deletion python/nav/statemon/checker/PostgresqlChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def execute(self):
kwargs = {}

# Build keywords from arguments
for (name, value) in self.args.items():
for name, value in self.args.items():
if name in ('user', 'password', 'database'):
# Must convert to str here because psycopg2 complains
# if keywords are unicode. ("Keywords must be strings")
Expand Down
6 changes: 3 additions & 3 deletions python/nav/web/networkexplorer/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def get_context_data(self, **kwargs):
'type': 'swport',
'interface': model_to_dict(interface),
'netbox_sysname': interface.netbox.sysname,
'module_netbox_sysname': interface.module.netbox.sysname
if interface.module
else '',
'module_netbox_sysname': (
interface.module.netbox.sysname if interface.module else ''
),
'subheader_vlan': str(vlan.vlan.vlan),
'subheader_netbox': str(interface.netbox),
}
Expand Down
12 changes: 6 additions & 6 deletions python/nav/web/radius/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def _format(self, row):
try:
message = row[LOG_DETAILFIELDS.index('message')]
return map(
lambda x: x
if x != message
else x.replace('[', '[<b>').replace(']', '</b>]'),
lambda x: (
x if x != message else x.replace('[', '[<b>').replace(']', '</b>]')
),
row,
)
except ValueError:
Expand Down Expand Up @@ -218,9 +218,9 @@ def _format(self, row):
try:
message = row[LOG_SEARCHRESULTFIELDS.index('message')]
return map(
lambda x: x
if x != message
else x.replace('[', '[<b>').replace(']', '</b>]'),
lambda x: (
x if x != message else x.replace('[', '[<b>').replace(']', '</b>]')
),
row,
)
except ValueError:
Expand Down
3 changes: 2 additions & 1 deletion python/nav/web/seeddb/page/service/edit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Forms and view functions for editing services in SeedDB"""

#
# Copyright (C) 2011, 2013-2015 Uninett AS
#
Expand Down Expand Up @@ -212,7 +213,7 @@ def service_save(request, service_form, property_form):
service = Service.objects.create(
netbox=netbox, handler=service_form.cleaned_data['handler']
)
for (prop, value) in property_form.cleaned_data.items():
for prop, value in property_form.cleaned_data.items():
if value:
ServiceProperty.objects.create(service=service, property=prop, value=value)
new_message(
Expand Down
1 change: 1 addition & 0 deletions python/nav/web/webfront/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""NAV web common package."""

import os

from django.db.models import Count
Expand Down
1 change: 1 addition & 0 deletions python/nav/web/webfront/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utility functions for various parts of the frontpage, navbar etc."""

#
# Copyright (C) 2009, 2012 Uninett AS
#
Expand Down

0 comments on commit 41a21ac

Please sign in to comment.