Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devel/management/commands/archweb_inotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
logger.setLevel(logging.WARNING)


class Database(object):
class Database:
'''A object representing a pacman database on the filesystem. It stores
various bits of metadata and state representing the file path, when we last
updated, how long our delay is before performing the update, whether we are
Expand Down
1 change: 0 additions & 1 deletion devel/management/commands/generate_keyring.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
generate_keyring command

Expand Down
5 changes: 2 additions & 3 deletions devel/management/commands/pgp_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
pgp_import command

Expand Down Expand Up @@ -75,7 +74,7 @@ def call_gpg(keyring, *args):
return outdata.decode("utf-8")


class KeyData(object):
class KeyData:
def __init__(self, key, created, expires):
self.key = key
self.created = get_datetime(created)
Expand Down Expand Up @@ -172,7 +171,7 @@ def import_keys(keyring):
logger.info("created %d, updated %d keys", created_ct, updated_ct)


class SignatureData(object):
class SignatureData:
def __init__(self, signer, signee, created):
self.signer = signer
self.signee = signee
Expand Down
1 change: 0 additions & 1 deletion devel/management/commands/read_rebuilderd_status.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
read_rebuilderd_status command

Expand Down
1 change: 0 additions & 1 deletion devel/management/commands/rematch_developers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
rematch_developers command

Expand Down
5 changes: 2 additions & 3 deletions devel/management/commands/reporead.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
reporead command

Expand Down Expand Up @@ -90,7 +89,7 @@ def handle(self, arch=None, filename=None, **options):
return read_repo(arch, filename, options)


class RepoPackage(object):
class RepoPackage:
"""An interim 'container' object for holding Arch package data."""
bare = ('name', 'base', 'arch', 'filename',
'md5sum', 'sha256sum', 'url', 'packager')
Expand Down Expand Up @@ -151,7 +150,7 @@ def full_version(self):
'''Very similar to the main.models.Package method.'''
if self.epoch > 0:
return '%d:%s-%s' % (self.epoch, self.ver, self.rel)
return '%s-%s' % (self.ver, self.rel)
return f'{self.ver}-{self.rel}'


DEPEND_RE = re.compile(r"^(.+?)((>=|<=|=|>|<)(.+))?$")
Expand Down
1 change: 0 additions & 1 deletion devel/management/commands/reporead_inotify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
reporead_inotify command

Expand Down
1 change: 0 additions & 1 deletion devel/management/commands/retire_user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
retire_user

Expand Down
2 changes: 0 additions & 2 deletions devel/migrations/0001_squashed_0002_staffgroup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-11-17 20:54
from __future__ import unicode_literals

import django.db.models.deletion
import django_countries.fields
Expand Down
7 changes: 3 additions & 4 deletions devel/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import zoneinfo

from django.contrib.auth.models import Group, User
Expand Down Expand Up @@ -71,7 +70,7 @@ def get_absolute_url(self):
user = self.user
group = StaffGroup.objects.filter(group=user.groups.all().first()).get()
if group:
return '%s#%s' % (group.get_absolute_url(), user.username)
return f'{group.get_absolute_url()}#{user.username}'
return None

def __str__(self):
Expand Down Expand Up @@ -116,7 +115,7 @@ class Meta:
get_latest_by = 'created'

def __str__(self):
return '%s, created %s' % (self.owner.get_full_name(), self.created)
return f'{self.owner.get_full_name()}, created {self.created}'


class DeveloperKey(models.Model):
Expand Down Expand Up @@ -147,7 +146,7 @@ class Meta:
verbose_name = 'PGP signature'

def __str__(self):
return '%s → %s' % (self.signer, self.signee)
return f'{self.signer} → {self.signee}'


def create_feed_model(sender, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion devel/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def linkify_non_reproducible_packages(statuses):
return pkgs


class DeveloperReport(object):
class DeveloperReport:
def __init__(self,
slug,
name,
Expand Down
2 changes: 1 addition & 1 deletion devel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def new_func(*args, **kwargs):
return new_func


class UserFinder(object):
class UserFinder:
def __init__(self):
self.cache = {}
self.username_cache = {}
Expand Down
6 changes: 3 additions & 3 deletions feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from releng.models import Release


class BatchWritesWrapper(object):
class BatchWritesWrapper:
def __init__(self, outfile):
self.outfile = outfile
self.buf = []
Expand Down Expand Up @@ -161,7 +161,7 @@ def item_pubdate(self, item):
return item.last_update

def item_title(self, item):
return '%s %s %s' % (item.pkgname, item.full_version, item.arch.name)
return f'{item.pkgname} {item.full_version} {item.arch.name}'

def item_description(self, item):
return item.pkgdesc
Expand Down Expand Up @@ -293,7 +293,7 @@ def item_pubdate(self, item):
return item.created

def item_title(self, item):
return '%s %s' % (item.pkgname, item.arch.name)
return f'{item.pkgname} {item.arch.name}'

def item_description(self, item):
return item.pkgname
Expand Down
4 changes: 2 additions & 2 deletions main/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_item_limits(self):
self.popitem(last=False)


class RateLimitFilter(object):
class RateLimitFilter:
def __init__(self, name='', rate=10, prefix='error_rate', max_keys=100):
# delayed import otherwise we have a circular dep when setting up
# the logging config: settings -> logging -> cache -> settings
Expand All @@ -55,7 +55,7 @@ def filter(self, record):
use_cache = False

if use_cache:
cache_key = '%s_%s' % (self.prefix, key)
cache_key = f'{self.prefix}_{key}'
duplicate = (cache.get(cache_key) == 1)
cache.set(cache_key, 1, self.rate)
else:
Expand Down
17 changes: 8 additions & 9 deletions main/management/commands/donor_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
donor_import

Expand Down Expand Up @@ -57,13 +56,13 @@ def sanitize_name(self, name):

# Some submissions contain no alphabetic characters, skip them
if all(not l.isalpha() for l in name): # noqa: E741
return u''
return ''

# Strip any numbers, they could be a bank account number
name = u''.join([l for l in name if not l.isdigit()]) # noqa: E741
name = ''.join([l for l in name if not l.isdigit()]) # noqa: E741

# Normalize all capitalized names. (JOHN DOE)
name = u' '.join(l.capitalize() for l in name.split(u' ')) # noqa: E741
name = ' '.join(l.capitalize() for l in name.split(' ')) # noqa: E741

# Trim excess spaces
name = name.rstrip().lstrip()
Expand All @@ -81,28 +80,28 @@ def handle(self, *args, **options):

msg = email.message_from_file(options['input'])
if not msg['subject']:
raise CommandError(u"Failed to read from STDIN")
raise CommandError("Failed to read from STDIN")
subject = msg.get('subject', '')
if 'utf-8' in subject:
# Decode UTF-8 encoded subjects
subject = self.decode_subject(subject)

# Subject header can contain enters, replace them with a space
subject = subject.replace(u'\n', u' ')
subject = subject.replace('\n', ' ')

name = self.parse_subject(subject)
if not name:
logger.error(u'Unable to parse: %s', subject)
logger.error('Unable to parse: %s', subject)
sys.exit(0)

name = self.sanitize_name(name)
if not name:
logger.error(u'Invalid name in subject: %s', subject)
logger.error('Invalid name in subject: %s', subject)
sys.exit(0)

try:
_, created = Donor.objects.get_or_create(name=name)
if created:
logger.info('Adding donor: %s', name)
except DBError as e:
logger.info(u'Error while adding donor: %s, %s', name, e)
logger.info('Error while adding donor: %s, %s', name, e)
3 changes: 0 additions & 3 deletions main/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
Expand Down
4 changes: 2 additions & 2 deletions main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __str__(self):
def full_version(self):
if self.epoch > 0:
return '%d:%s-%s' % (self.epoch, self.pkgver, self.pkgrel)
return '%s-%s' % (self.pkgver, self.pkgrel)
return f'{self.pkgver}-{self.pkgrel}'

def get_absolute_url(self):
return f'/packages/{self.repo.name.lower()}/{self.arch.name}/{self.pkgname}/'
Expand Down Expand Up @@ -481,7 +481,7 @@ def status_str(self):
return self.REBUILDERD_STATUSES[self.status][1]

def __str__(self):
return "pkg=%s, status=%s" % (self.pkg, self.status_str)
return f"pkg={self.pkg}, status={self.status_str}"


class Soname(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion main/templatetags/details_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def link_encode(url, query):
# doesn't barf at the data we pass it
query = {k: str(v).encode('utf-8') for k, v in query.items()}
data = urlencode(query)
return "%s?%s" % (url, data)
return f"{url}?{data}"


@register.simple_tag
Expand Down
4 changes: 1 addition & 3 deletions main/tests/test_donor_import.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

from email.header import Header
from email.message import Message
from io import StringIO
Expand Down Expand Up @@ -31,7 +29,7 @@ def test_parse_name():


def test_decode_subject():
text = u'メイル'
text = 'メイル'
subject = Header(text, 'utf-8')
assert command.decode_subject(subject) == text

Expand Down
4 changes: 2 additions & 2 deletions main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def gitlab_project_name_to_path(name: str) -> str:
return name


class PackageStandin(object):
class PackageStandin:
'''Resembles a Package object, and has a few of the same fields, but is
really a link to a pkgbase that has no package with matching pkgname.'''

Expand All @@ -180,7 +180,7 @@ def get_absolute_url(self):
return f'/packages/{self.repo.name.lower()}/{self.arch.name}/{self.pkgname}/'


class DependStandin(object):
class DependStandin:
'''Resembles a Depend object, and has a few of the same fields, but is
really a link to a base package rather than a single package.'''

Expand Down
3 changes: 1 addition & 2 deletions mirrors/management/commands/mirrorcheck.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
mirrorcheck command

Expand Down Expand Up @@ -246,7 +245,7 @@ def mirror_url_worker(work, output, location, timeout):
return 0


class MirrorCheckPool(object):
class MirrorCheckPool:
def __init__(self, urls, location, timeout=10, num_threads=10):
self.tasks = Queue()
self.logs = deque()
Expand Down
1 change: 0 additions & 1 deletion mirrors/management/commands/mirrorresolv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
mirrorresolv command

Expand Down
2 changes: 0 additions & 2 deletions mirrors/migrations/0001_squashed_0002_mirrorurl_bandwidth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-11-17 20:54
from __future__ import unicode_literals

import django.db.models.deletion
import django_countries.fields
Expand Down
6 changes: 3 additions & 3 deletions mirrors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_absolute_url(self):

def get_full_url(self, proto='https'):
domain = Site.objects.get_current().domain
return '%s://%s%s' % (proto, domain, self.get_absolute_url())
return f'{proto}://{domain}{self.get_absolute_url()}'


class MirrorProtocol(models.Model):
Expand Down Expand Up @@ -118,7 +118,7 @@ def get_absolute_url(self):

def get_full_url(self, proto='https'):
domain = Site.objects.get_current().domain
return '%s://%s%s' % (proto, domain, self.get_absolute_url())
return f'{proto}://{domain}{self.get_absolute_url()}'


class MirrorRsync(models.Model):
Expand Down Expand Up @@ -183,7 +183,7 @@ def delay(self):
return self.check_time - self.last_sync

def __str__(self):
return "Check of %s at %s" % (self.url.url, self.check_time)
return f"Check of {self.url.url} at {self.check_time}"

class Meta:
verbose_name = 'mirror check log'
Expand Down
6 changes: 3 additions & 3 deletions mirrors/templatetags/mirror_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@register.filter
def duration(value):
if not value or not isinstance(value, timedelta):
return u''
return ''
# does not take microseconds into account
total_secs = value.seconds + value.days * 24 * 3600
mins = total_secs // 60
Expand All @@ -19,7 +19,7 @@ def duration(value):
@register.filter
def hours(value):
if not value or not isinstance(value, timedelta):
return u''
return ''
# does not take microseconds into account
total_secs = value.seconds + value.days * 24 * 3600
mins = total_secs // 60
Expand All @@ -32,7 +32,7 @@ def hours(value):
@register.filter
def percentage(value, arg=1):
if not value or not isinstance(value, float):
return u''
return ''
new_val = value * 100.0
return '%.*f%%' % (arg, new_val)

Expand Down
2 changes: 0 additions & 2 deletions news/migrations/0001_squashed_0002_news_send_announce.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.15 on 2018-11-17 20:55
from __future__ import unicode_literals

import django.db.models.deletion
from django.conf import settings
Expand Down
Loading