Skip to content

Commit 2c3d056

Browse files
Reformat codebase using ruff v0.11.9
1 parent 24d74de commit 2c3d056

File tree

360 files changed

+800
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

360 files changed

+800
-756
lines changed

python/nav/Snmp/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
multiple implementations
2121
2222
"""
23+
2324
import os
2425
import sys
2526

python/nav/Snmp/defines.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
1515
#
1616
"""Defines types and enumerations for SNMP communication parameters"""
17+
1718
from enum import Enum
1819

1920

python/nav/Snmp/profile.py

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
1515
#
1616
"""Helper functions to build SNMP sessions from NAV ManagementProfile instances"""
17+
1718
from functools import partial
1819
from typing import Callable
1920

python/nav/Snmp/pynetsnmp.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#
1717
"""High level synchronouse NAV API for NetSNMP"""
1818

19-
2019
from collections import namedtuple
2120
from ctypes import (
2221
c_int,

python/nav/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""
1717
Provides a common root package for the NAV python library.
1818
"""
19+
1920
import time
2021
import warnings
2122

python/nav/activeipcollector/manager.py

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
1717
#
1818
"""Manage collection and storing of active ip-addresses statistics"""
19+
1920
import datetime
2021
import logging
2122
import time

python/nav/alertengine/base.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#
1919
"""Alertengine base functionality"""
2020

21-
2221
import gc
2322
import logging
2423
from datetime import datetime, timedelta
@@ -420,7 +419,7 @@ def process_single_queued_notification(queued_alert, now):
420419

421420
if subscription is None:
422421
_logger.info(
423-
'Sending alert %d right away as the users profile has ' 'been disabled',
422+
'Sending alert %d right away as the users profile has been disabled',
424423
queued_alert.alert_id,
425424
)
426425
send = True
@@ -444,7 +443,7 @@ def process_single_queued_notification(queued_alert, now):
444443

445444
else:
446445
_logger.error(
447-
'Account %s has an invalid subscription type in ' 'subscription %d',
446+
'Account %s has an invalid subscription type in subscription %d',
448447
subscription.account,
449448
subscription.id,
450449
)
@@ -484,7 +483,7 @@ def _verify_daily_dispatch(queued_alert, now, _logger=_logger):
484483
now.date(), daily_time
485484
)
486485
_logger.debug(
487-
'Tests: last sent %s, daily time %s, insertion time ' '%s',
486+
'Tests: last sent %s, daily time %s, insertion time %s',
488487
last_sent_test,
489488
daily_time_test,
490489
insertion_time_test,
@@ -512,7 +511,7 @@ def _verify_weekly_dispatch(queued_alert, now, _logger=_logger):
512511
)
513512

514513
_logger.debug(
515-
'Tests: weekday %s, last sent %s, weekly time %s, ' 'insertion time %s',
514+
'Tests: weekday %s, last sent %s, weekly time %s, insertion time %s',
516515
weekday_test,
517516
last_sent_test,
518517
weekly_time_test,

python/nav/alertengine/dispatchers/email_dispatcher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def send(self, address, alert, language='en'):
6161
email.send(fail_silently=False)
6262
else:
6363
_logger.debug(
64-
'alert %d: In testing mode, would have sent ' 'email to %s',
64+
'alert %d: In testing mode, would have sent email to %s',
6565
alert.id,
6666
address.address,
6767
)

python/nav/arnold.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
Provides helpfunctions for Arnold web and script
2020
"""
2121

22-
2322
import re
2423
import os
2524
import configparser

python/nav/asyncdns.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
2525
"""
2626

27-
2827
import socket
2928
from itertools import cycle
3029
from collections import defaultdict

python/nav/auditlog/models.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def add_log_entry(
8282
self = cls()
8383
dict = {'actor': actor, 'object': object, 'target': target}
8484
for k, v in dict.items():
85-
dict[k] = getattr(v, 'audit_logname', u'%s' % v)
85+
dict[k] = getattr(v, 'audit_logname', '%s' % v)
8686
try:
8787
self.summary = template.format(**dict)
8888
except KeyError as error:
@@ -111,8 +111,8 @@ def add_create_entry(actor, obj):
111111
model = obj.__class__.__name__.lower()
112112
LogEntry.add_log_entry(
113113
actor,
114-
u'create-{}'.format(model),
115-
u'{actor} created {object}',
114+
'create-{}'.format(model),
115+
'{actor} created {object}',
116116
after=obj,
117117
object=obj,
118118
)
@@ -121,9 +121,9 @@ def add_create_entry(actor, obj):
121121
def add_delete_entry(actor, obj, template=None):
122122
"""Add log entry for deleted objects"""
123123
model = obj.__class__.__name__.lower()
124-
template = template or u'{actor} deleted {object}'
124+
template = template or '{actor} deleted {object}'
125125
LogEntry.add_log_entry(
126-
actor, u'delete-{}'.format(model), template, before=obj, object=obj
126+
actor, 'delete-{}'.format(model), template, before=obj, object=obj
127127
)
128128

129129
@staticmethod
@@ -137,10 +137,10 @@ def dict_to_string(d):
137137
"""
138138
{"a": "b", "c": "d"} => "a=b, c=d"
139139
"""
140-
return u", ".join(u"{}={}".format(x, y) for x, y in d.items())
140+
return ", ".join("{}={}".format(x, y) for x, y in d.items())
141141

142142
model = new.__class__.__name__.lower()
143-
prefix = u'{actor} edited {object}'
143+
prefix = '{actor} edited {object}'
144144
old_value = getattr(old, attribute)
145145
new_value = getattr(new, attribute)
146146
if include_values:
@@ -149,16 +149,16 @@ def dict_to_string(d):
149149
old_value = dict_to_string(old_value)
150150
if isinstance(new_value, dict):
151151
new_value = dict_to_string(new_value)
152-
summary = u"{} changed from '{}' to '{}'".format(
152+
summary = "{} changed from '{}' to '{}'".format(
153153
attribute, old_value, new_value
154154
)
155155
else:
156-
summary = u"{} changed".format(attribute)
156+
summary = "{} changed".format(attribute)
157157

158158
LogEntry.add_log_entry(
159159
actor,
160-
u'edit-{}-{}'.format(model, attribute),
161-
u'{}: {}'.format(prefix, summary),
160+
'edit-{}-{}'.format(model, attribute),
161+
'{}: {}'.format(prefix, summary),
162162
before=old,
163163
after=new,
164164
object=new,

python/nav/auditlog/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def get_auditlog_entries(
3636
Limit results to <pks>, <queryset> and/or <subsystem>
3737
"""
3838
assert modelname or queryset, (
39-
"At least one of <modelname> or " "<queryset> must be given"
39+
"At least one of <modelname> or <queryset> must be given"
4040
)
4141
if pks is None:
4242
pks = []

python/nav/bin/alertengine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def main():
154154

155155
except DatabaseError as err:
156156
_logger.error(
157-
'Database error, closing the DB connection just in ' 'case:\n%s', err
157+
'Database error, closing the DB connection just in case:\n%s', err
158158
)
159159
_logger.debug('', exc_info=True)
160160
if connection.queries:
@@ -233,7 +233,7 @@ def loginitsmtp(loglevel, mailaddr, fromaddr, mailserver):
233233
mailserver, fromaddr, mailaddr, 'NAV alertengine warning from ' + hostname
234234
)
235235
mailformat = (
236-
'[%(asctime)s] [%(levelname)s] [pid=%(process)d %(name)s] ' '%(message)s'
236+
'[%(asctime)s] [%(levelname)s] [pid=%(process)d %(name)s] %(message)s'
237237
)
238238
mailformatter = logging.Formatter(mailformat)
239239
mailhandler.setFormatter(mailformatter)

python/nav/bin/collect_active_ip.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#
1818
"""A wrapper for prefix_ip_collector"""
1919

20-
2120
import argparse
2221
import logging
2322
import time

python/nav/bin/macwatch.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# Occurences of the mac-address nearest to the edges has highest
4343
# priority
44-
LOCATION_PRIORITY = {u'GSW': 1, u'GW': 1, u'SW': 2, u'EDGE': 3}
44+
LOCATION_PRIORITY = {'GSW': 1, 'GW': 1, 'SW': 2, 'EDGE': 3}
4545

4646

4747
def prioritize_location(cam_objects):
@@ -175,7 +175,7 @@ def main():
175175
# continue with next mac if not.
176176
if len(macwatch_matches) == 1:
177177
_logger.info(
178-
"Mac-address is active, but have not moved " "since last check"
178+
"Mac-address is active, but have not moved since last check"
179179
)
180180
continue
181181

@@ -205,7 +205,7 @@ def main():
205205
)
206206
new_macwatch_match.save()
207207
else:
208-
_logger.warning("Failed to post event, no alert will be " "given.")
208+
_logger.warning("Failed to post event, no alert will be given.")
209209

210210
_logger.info(
211211
"--> Done checking for macs in %.3f seconds <--", time.time() - start_time

python/nav/bin/mailin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def add_mailin_subsystem():
131131

132132
cursor.execute("select * from subsystem where name='mailin'")
133133
if cursor.rowcount == 0:
134-
cursor.execute("INSERT INTO subsystem (name, descr) " "VALUES ('mailin', '')")
134+
cursor.execute("INSERT INTO subsystem (name, descr) VALUES ('mailin', '')")
135135
conn.commit()
136136

137137

python/nav/bin/maintengine.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
schedule in NAVdb.
2121
"""
2222

23-
2423
import time
2524
import logging
2625

python/nav/bin/navcheckservice.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
2323
"""
2424

25-
2625
import argparse
2726
import sys
2827

python/nav/bin/navclean.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# along with NAV. If not, see <http://www.gnu.org/licenses/>.
2020
#
2121
"""Cleans old data from the NAV database"""
22+
2223
import argparse
2324
import sys
2425

python/nav/bin/navdf.py

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
A command line interface to list and filter IP devices monitored by NAV
1919
"""
2020

21-
2221
import argparse
2322

2423
from nav.bootstrap import bootstrap_django

python/nav/bin/navdump.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def parse_args():
112112
args = parser.parse_args()
113113
if not (args.table or args.all):
114114
parser.error(
115-
"Please specify which tables to dump, using either " "--table or --all"
115+
"Please specify which tables to dump, using either --table or --all"
116116
)
117117
return args
118118

@@ -128,13 +128,13 @@ def fail(resultcode, msg):
128128

129129
def header(definition):
130130
"""Output the header definition, possibly with replaced separators"""
131-
definition = definition.replace(u":", SEPARATOR) + u'\n'
131+
definition = definition.replace(":", SEPARATOR) + '\n'
132132
sys.stdout.write(definition)
133133

134134

135135
def lineout(line):
136136
"""Output line, remove any : in strings"""
137-
newline = (u'"%s"' % column if SEPARATOR in column else column for column in line)
137+
newline = ('"%s"' % column if SEPARATOR in column else column for column in line)
138138
line = SEPARATOR.join(newline) + '\n'
139139
sys.stdout.write(line)
140140

@@ -151,8 +151,8 @@ def netbox():
151151
"devicegroup1:devicegroup2..]"
152152
)
153153
for box in manage.Netbox.objects.all():
154-
profiles = u'|'.join(box.profiles.values_list('name', flat=True))
155-
data = u'|'.join(u"%s=%s" % (k, v) for k, v in box.data.items())
154+
profiles = '|'.join(box.profiles.values_list('name', flat=True))
155+
data = '|'.join("%s=%s" % (k, v) for k, v in box.data.items())
156156
line = [
157157
box.room_id,
158158
box.ip,

python/nav/bin/naventity.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
ENTITY-MIB::entPhysicalTable.
2121
"""
2222

23-
2423
import sys
2524
import argparse
2625

python/nav/bin/navmain.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# License along with NAV. If not, see <http://www.gnu.org/licenses/>.
1717
#
1818
"""Command line program to control NAV processes"""
19+
1920
import sys
2021
import os
2122
import os.path
@@ -102,7 +103,7 @@ def _add_bespoke_subparsers(subparsers):
102103
config_sub = config.add_subparsers()
103104
where = config_sub.add_parser(
104105
"where",
105-
help="find and report the location of the " "main NAV configuration file",
106+
help="find and report the location of the main NAV configuration file",
106107
)
107108
where.set_defaults(func=command_config_where)
108109

@@ -121,12 +122,12 @@ def _add_bespoke_subparsers(subparsers):
121122
"directory",
122123
)
123124
install.add_argument(
124-
'target_directory', help="the directory in which to install the config " "files"
125+
'target_directory', help="the directory in which to install the config files"
125126
)
126127
install.add_argument(
127128
'--overwrite',
128129
action="store_true",
129-
help="overwrite existing config files in target " "directory",
130+
help="overwrite existing config files in target directory",
130131
)
131132
install.add_argument(
132133
'--verbose',
@@ -300,8 +301,9 @@ def command_config_where(_args):
300301
print(path)
301302
else:
302303
sys.exit(
303-
"Could not find nav.conf in any of these locations:\n"
304-
"{}".format('\n'.join(CONFIG_LOCATIONS))
304+
"Could not find nav.conf in any of these locations:\n{}".format(
305+
'\n'.join(CONFIG_LOCATIONS)
306+
)
305307
)
306308

307309

python/nav/bin/navoidverify.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
NAV-monitored devices.
2222
"""
2323

24-
2524
import platform
2625
import sys
2726
from itertools import cycle

python/nav/bin/navsnmp.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
line arguments.
1919
2020
"""
21+
2122
import argparse
2223
import sys
2324

python/nav/bin/navsynctypes.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
to synchronize the IP Device type registry of one NAV installation based on the
1919
information contained in another.
2020
"""
21+
2122
import argparse
2223

2324
import nav.db

0 commit comments

Comments
 (0)