diff options
author | Jelle van der Waa <jelle@vdwaa.nl> | 2018-02-16 22:08:35 +0100 |
---|---|---|
committer | Jelle van der Waa <jelle@vdwaa.nl> | 2019-01-21 21:19:58 +0100 |
commit | c612b1931415ca5e6a7265b4e06cd045e851e07e (patch) | |
tree | 89527c2290c58721042a063d26b59cd135a1b12f /main | |
parent | 7742430a261f36a834b93d2b8242cf847d25caa3 (diff) | |
download | archweb-c612b1931415ca5e6a7265b4e06cd045e851e07e.tar.gz archweb-c612b1931415ca5e6a7265b4e06cd045e851e07e.zip |
main: run 2to3
Diffstat (limited to 'main')
-rw-r--r-- | main/migrations/0001_initial.py | 2 | ||||
-rw-r--r-- | main/models.py | 12 | ||||
-rw-r--r-- | main/templatetags/attributes.py | 2 | ||||
-rw-r--r-- | main/templatetags/details_link.py | 6 | ||||
-rw-r--r-- | main/templatetags/flags.py | 2 | ||||
-rw-r--r-- | main/templatetags/pgp.py | 10 | ||||
-rw-r--r-- | main/tests/test_templatetags_pgp.py | 4 | ||||
-rw-r--r-- | main/utils.py | 2 |
8 files changed, 20 insertions, 20 deletions
diff --git a/main/migrations/0001_initial.py b/main/migrations/0001_initial.py index 8349d4b9..6c87bf7e 100644 --- a/main/migrations/0001_initial.py +++ b/main/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals + from django.db import models, migrations import main.fields diff --git a/main/models.py b/main/models.py index 476ee017..446c33ea 100644 --- a/main/models.py +++ b/main/models.py @@ -124,8 +124,8 @@ class Package(models.Model): @property def full_version(self): if self.epoch > 0: - return u'%d:%s-%s' % (self.epoch, self.pkgver, self.pkgrel) - return u'%s-%s' % (self.pkgver, self.pkgrel) + return '%d:%s-%s' % (self.epoch, self.pkgver, self.pkgrel) + return '%s-%s' % (self.pkgver, self.pkgrel) def get_absolute_url(self): return '/packages/%s/%s/%s/' % (self.repo.name.lower(), @@ -417,13 +417,13 @@ class Package(models.Model): '''attempt to locate this package anywhere else, regardless of architecture or repository. Excludes this package from the list.''' names = [self.pkgname] - if self.pkgname.startswith(u'lib32-'): + if self.pkgname.startswith('lib32-'): names.append(self.pkgname[6:]) - elif self.pkgname.endswith(u'-multilib'): + elif self.pkgname.endswith('-multilib'): names.append(self.pkgname[:-9]) else: - names.append(u'lib32-' + self.pkgname) - names.append(self.pkgname + u'-multilib') + names.append('lib32-' + self.pkgname) + names.append(self.pkgname + '-multilib') return Package.objects.normal().filter( pkgname__in=names).exclude(id=self.id).order_by( 'arch__name', 'repo__name') diff --git a/main/templatetags/attributes.py b/main/templatetags/attributes.py index bd4ccf3d..ab09b63e 100644 --- a/main/templatetags/attributes.py +++ b/main/templatetags/attributes.py @@ -9,7 +9,7 @@ def attribute(value, arg): """Gets an attribute of an object dynamically from a string name""" if hasattr(value, str(arg)): return getattr(value, arg) - elif hasattr(value, 'has_key') and value.has_key(arg): + elif hasattr(value, 'has_key') and arg in value: return value[arg] elif numeric_test.match(str(arg)) and len(value) > int(arg): return value[int(arg)] diff --git a/main/templatetags/details_link.py b/main/templatetags/details_link.py index c9c0521a..582ffa1b 100644 --- a/main/templatetags/details_link.py +++ b/main/templatetags/details_link.py @@ -1,4 +1,4 @@ -from urllib import urlencode, quote as urlquote, unquote +from urllib.parse import urlencode, quote as urlquote, unquote from django import template from main.templatetags import pgp @@ -8,7 +8,7 @@ register = template.Library() def link_encode(url, query): # massage the data into all utf-8 encoded strings first, so urlencode # doesn't barf at the data we pass it - query = {k: unicode(v).encode('utf-8') for k, v in query.items()} + query = {k: str(v).encode('utf-8') for k, v in list(query.items())} data = urlencode(query) return "%s?%s" % (url, data) @@ -70,7 +70,7 @@ def pgp_key_link(key_id, link_text=None): def url_unquote(original_url): try: url = original_url - if isinstance(url, unicode): + if isinstance(url, str): url = url.encode('ascii') url = unquote(url).decode('utf-8') return url diff --git a/main/templatetags/flags.py b/main/templatetags/flags.py index fafcb5aa..d47ee707 100644 --- a/main/templatetags/flags.py +++ b/main/templatetags/flags.py @@ -9,7 +9,7 @@ def country_flag(country): if not country: return '' return format_html('<span class="fam-flag fam-flag-%s" title="%s"></span> ' % ( - unicode(country.code).lower(), unicode(country.name))) + str(country.code).lower(), str(country.name))) # vim: set ts=4 sw=4 et: diff --git a/main/templatetags/pgp.py b/main/templatetags/pgp.py index f8c99574..4597e10b 100644 --- a/main/templatetags/pgp.py +++ b/main/templatetags/pgp.py @@ -9,19 +9,19 @@ register = template.Library() def format_key(key_id): if len(key_id) in (8, 20): - return u'0x%s' % key_id + return '0x%s' % key_id elif len(key_id) == 40: # normal display format is 5 groups of 4 hex chars seperated by spaces, # double space, then 5 more groups of 4 hex chars split = tuple(key_id[i:i+4] for i in range(0, 40, 4)) - return u'%s\u00a0 %s' % (' '.join(split[0:5]), ' '.join(split[5:10])) - return u'0x%s' % key_id + return '%s\u00a0 %s' % (' '.join(split[0:5]), ' '.join(split[5:10])) + return '0x%s' % key_id @register.simple_tag def pgp_key_link(key_id, link_text=None): if not key_id: return "Unknown" - if isinstance(key_id, (int, long)): + if isinstance(key_id, int): key_id = '%X' % key_id # zero-fill to nearest 8, 16, or 40 chars if necessary if len(key_id) <= 8: @@ -57,7 +57,7 @@ def user_pgp_key_link(dev_keys, key_id): @register.filter def pgp_fingerprint(key_id): if not key_id: - return u'' + return '' return mark_safe(format_key(conditional_escape(key_id))) diff --git a/main/tests/test_templatetags_pgp.py b/main/tests/test_templatetags_pgp.py index 240de3cb..39ace88b 100644 --- a/main/tests/test_templatetags_pgp.py +++ b/main/tests/test_templatetags_pgp.py @@ -13,7 +13,7 @@ class PGPTemplateTest(TestCase): pgp_key_len = len(pgp_key) output = format_key(pgp_key) - spaces = output.count(' ') + output.count(u'\xa0') # nbsp + spaces = output.count(' ') + output.count('\xa0') # nbsp self.assertEqual(pgp_key_len + spaces, len(output)) # 21 - 39 len case @@ -68,7 +68,7 @@ class PGPTemplateTest(TestCase): self.assertNotIn("https", pgp_key_link(pgp_key)) def test_pgp_fingerprint(self): - self.assertEqual(pgp_fingerprint(None), u"") + self.assertEqual(pgp_fingerprint(None), "") keyid = '423423fD9004FB063E2C81117BFB1108D234DAFZ' fingerprint = pgp_fingerprint(keyid) self.assertTrue(len(fingerprint) > len(keyid)) diff --git a/main/utils.py b/main/utils.py index ff976f51..f0b10ef5 100644 --- a/main/utils.py +++ b/main/utils.py @@ -1,5 +1,5 @@ try: - import cPickle as pickle + import pickle as pickle except ImportError: import pickle |