Unverified Commit 6bb41c6f authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by GitHub
Browse files

Merge pull request #132 from akstrfn/python3

Some py3 fixes and some refactoring
parents e8442cb7 203506c9
...@@ -11,6 +11,8 @@ collected_static/ ...@@ -11,6 +11,8 @@ collected_static/
testing/ testing/
env/ env/
.mypy_cache/
# rope # rope
.ropeproject/ .ropeproject/
......
...@@ -53,15 +53,11 @@ class Meta: ...@@ -53,15 +53,11 @@ class Meta:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(NewUserForm, self).__init__(*args, **kwargs) super(NewUserForm, self).__init__(*args, **kwargs)
# Hack ourself so certain fields appear first # Hack ourself so certain fields appear first
old = self.fields
self.fields = OrderedDict()
keys = ('username', 'private_email', 'first_name', 'last_name', keys = ('username', 'private_email', 'first_name', 'last_name',
'alias', 'public_email') 'alias', 'public_email')
for key in keys: # add all remaining keys afterwards
self.fields[key] = old[key] keys += tuple(k for k in self.fields.keys() if k not in keys)
for key, _ in list(old.items()): self.fields = OrderedDict((key, old[key]) for key in keys)
if key not in keys:
self.fields[key] = old[key]
def clean_username(self): def clean_username(self):
username = self.cleaned_data['username'] username = self.cleaned_data['username']
......
...@@ -141,7 +141,7 @@ def import_keys(keyring): ...@@ -141,7 +141,7 @@ def import_keys(keyring):
finder = UserFinder() finder = UserFinder()
# we are dependent on parents coming before children; parse_keydata # we are dependent on parents coming before children; parse_keydata
# uses an OrderedDict to ensure this is the case. # uses an OrderedDict to ensure this is the case.
for data in list(keydata.values()): for data in keydata.values():
parent_id = None parent_id = None
if data.parent: if data.parent:
parent_data = keydata.get(data.parent, None) parent_data = keydata.get(data.parent, None)
...@@ -161,7 +161,7 @@ def import_keys(keyring): ...@@ -161,7 +161,7 @@ def import_keys(keyring):
if created: if created:
created_ct += 1 created_ct += 1
else: else:
for k, v in list(other.items()): for k, v in other.items():
if getattr(dkey, k) != v: if getattr(dkey, k) != v:
setattr(dkey, k, v) setattr(dkey, k, v)
needs_save = True needs_save = True
......
...@@ -62,7 +62,7 @@ def match_packager(finder): ...@@ -62,7 +62,7 @@ def match_packager(finder):
logger.debug(" found user %s", user.username) logger.debug(" found user %s", user.username)
matched_count += 1 matched_count += 1
for packager_str, user in list(mapping.items()): for packager_str, user in mapping.items():
package_count += Package.objects.filter(packager__isnull=True, package_count += Package.objects.filter(packager__isnull=True,
packager_str=packager_str).update(packager=user) packager_str=packager_str).update(packager=user)
...@@ -88,7 +88,7 @@ def match_flagrequest(finder): ...@@ -88,7 +88,7 @@ def match_flagrequest(finder):
logger.debug(" found user %s", user.username) logger.debug(" found user %s", user.username)
matched_count += 1 matched_count += 1
for user_email, user in list(mapping.items()): for user_email, user in mapping.items():
req_count += FlagRequest.objects.filter(user__isnull=True, req_count += FlagRequest.objects.filter(user__isnull=True,
user_email=user_email).update(user=user) user_email=user_email).update(user=user)
......
...@@ -187,7 +187,7 @@ def my_init(self, **kwargs): ...@@ -187,7 +187,7 @@ def my_init(self, **kwargs):
# we really want a single path to arch mapping, so massage the data # we really want a single path to arch mapping, so massage the data
arch_paths = kwargs['arch_paths'] arch_paths = kwargs['arch_paths']
for arch, paths in list(arch_paths.items()): for arch, paths in arch_paths.items():
self.arch_lookup.update((path.rstrip('/'), arch) for path in paths) self.arch_lookup.update((path.rstrip('/'), arch) for path in paths)
def process_default(self, event): def process_default(self, event):
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
def link_encode(url, query): def link_encode(url, query):
# massage the data into all utf-8 encoded strings first, so urlencode # massage the data into all utf-8 encoded strings first, so urlencode
# doesn't barf at the data we pass it # doesn't barf at the data we pass it
query = {k: str(v).encode('utf-8') for k, v in list(query.items())} query = {k: str(v).encode('utf-8') for k, v in query.items()}
data = urlencode(query) data = urlencode(query)
return "%s?%s" % (url, data) return "%s?%s" % (url, data)
......
...@@ -48,7 +48,7 @@ def package_links(self): ...@@ -48,7 +48,7 @@ def package_links(self):
by_arch = defaultdict(list) by_arch = defaultdict(list)
for package in self.others: for package in self.others:
by_arch[package.arch].append(package) by_arch[package.arch].append(package)
for _, packages in list(by_arch.items()): for _, packages in by_arch.items():
if len(packages) == 1: if len(packages) == 1:
yield packages[0] yield packages[0]
else: else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment