diff options
author | Dan McGee <dan@archlinux.org> | 2012-11-16 23:20:11 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-11-16 23:37:52 +0100 |
commit | 6dd4d54bb0adbbb0f8c2b1beaa92b7a58971cf88 (patch) | |
tree | ce20ff9bf1118c8d383eed352bcdcbf064cb5269 /packages | |
parent | b3979dd2315ce1aef779abdb646562d7bba7a44f (diff) | |
download | archweb-6dd4d54bb0adbbb0f8c2b1beaa92b7a58971cf88.tar.gz archweb-6dd4d54bb0adbbb0f8c2b1beaa92b7a58971cf88.tar.xz |
Use Python 2.7 dictionary comprehension syntax
Rather than the old idiom of dict((k, v) for <> in <>).
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages')
-rw-r--r-- | packages/templatetags/package_extras.py | 2 | ||||
-rw-r--r-- | packages/utils.py | 5 | ||||
-rw-r--r-- | packages/views/signoff.py | 8 |
3 files changed, 6 insertions, 9 deletions
diff --git a/packages/templatetags/package_extras.py b/packages/templatetags/package_extras.py index 994265d..f3613e6 100644 --- a/packages/templatetags/package_extras.py +++ b/packages/templatetags/package_extras.py @@ -13,7 +13,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 = dict((k, unicode(v).encode('utf-8')) for k, v in query.items()) + query = {k: unicode(v).encode('utf-8') for k, v in query.items()} data = urlencode(query).replace('&', '&') return "%s?%s" % (url, data) diff --git a/packages/utils.py b/packages/utils.py index 051fed8..199e141 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -385,7 +385,7 @@ SELECT DISTINCT s.id repo_sql = ','.join(['%s' for r in repos]) sql = sql % (model._meta.db_table, repo_sql, repo_sql) repo_ids = [r.pk for r in repos] - # repo_ids are needed twice, so double the array + # repo_ids are needed twice, so double the array cursor.execute(sql, repo_ids * 2) results = cursor.fetchall() @@ -474,8 +474,7 @@ class PackageJSONEncoder(DjangoJSONEncoder): # mainly for queryset serialization return list(obj) if isinstance(obj, Package): - data = dict((attr, getattr(obj, attr)) - for attr in self.pkg_attributes) + data = {attr: getattr(obj, attr) for attr in self.pkg_attributes} for attr in self.pkg_list_attributes: data[attr] = getattr(obj, attr).all() return data diff --git a/packages/views/signoff.py b/packages/views/signoff.py index 56eb060..824a992 100644 --- a/packages/views/signoff.py +++ b/packages/views/signoff.py @@ -155,8 +155,8 @@ class SignoffJSONEncoder(DjangoJSONEncoder): def default(self, obj): if isinstance(obj, PackageSignoffGroup): - data = dict((attr, getattr(obj, attr)) - for attr in self.signoff_group_attrs) + data = {attr: getattr(obj, attr) + for attr in self.signoff_group_attrs} data['pkgnames'] = [p.pkgname for p in obj.packages] data['package_count'] = len(obj.packages) data['approved'] = obj.approved() @@ -164,9 +164,7 @@ class SignoffJSONEncoder(DjangoJSONEncoder): for attr in self.signoff_spec_attrs) return data elif isinstance(obj, Signoff): - data = dict((attr, getattr(obj, attr)) - for attr in self.signoff_attrs) - return data + return {attr: getattr(obj, attr) for attr in self.signoff_attrs} elif isinstance(obj, Arch) or isinstance(obj, Repo): return unicode(obj) elif isinstance(obj, User): |