Skip to content

Commit

Permalink
Merge pull request #3125 from k-nut/3123-dict-comprehension
Browse files Browse the repository at this point in the history
Dict comprehension without pep8 problems
  • Loading branch information
amercader committed Jun 20, 2016
2 parents 817d97d + 5503851 commit d423687
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions ckan/lib/config_tool.py
Expand Up @@ -189,9 +189,9 @@ def insert_new_sections(new_sections):
# at start of new section, write the 'add'ed options
for option in changes.get(section, 'add'):
write_option(option)
options_to_edit_in_this_section = dict(
[(option.key, option)
for option in changes.get(section, 'edit')])
options_to_edit_in_this_section = {option.key: option
for option
in changes.get(section, 'edit')}
continue
existing_option = parse_option_string(section, line)
if not existing_option:
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/create_test_data.py
Expand Up @@ -187,7 +187,7 @@ def create_arbitrary(cls, package_dicts, relationships=[],
if not isinstance(v, datetime.datetime):
v = unicode(v)
non_extras[str(k)] = v
extras = dict([(str(k), unicode(v)) for k, v in res_dict.get('extras', {}).items()])
extras = {str(k): unicode(v) for k, v in res_dict.get('extras', {}).items()}
pkg.add_resource(extras=extras, **non_extras)
elif attr == 'tags':
if isinstance(val, (str, unicode)):
Expand Down
6 changes: 2 additions & 4 deletions ckan/lib/dictization/model_save.py
Expand Up @@ -157,10 +157,8 @@ def package_tag_list_save(tag_dicts, package, context):
for package_tag in
package.package_tag_all)

tag_package_tag_inactive = dict(
[ (tag,pt) for tag,pt in tag_package_tag.items() if
pt.state in ['deleted'] ]
)
tag_package_tag_inactive = {tag: pt for tag,pt in tag_package_tag.items() if
pt.state in ['deleted']}

tag_name_vocab = set()
tags = set()
Expand Down
2 changes: 1 addition & 1 deletion ckan/logic/schema.py
Expand Up @@ -618,7 +618,7 @@ def create_schema_for_required_keys(keys):
''' helper function that creates a schema definition where
each key from keys is validated against ``not_missing``.
'''
schema = dict([(x, [not_missing]) for x in keys])
schema = {x: [not_missing] for x in keys}
return schema


Expand Down
2 changes: 1 addition & 1 deletion ckan/model/package.py
Expand Up @@ -204,7 +204,7 @@ def as_dict(self, ref_package_by='name', ref_group_by='name'):
groups = [getattr(group, ref_group_by) for group in self.get_groups()]
groups.sort()
_dict['groups'] = groups
_dict['extras'] = dict([(key, value) for key, value in self.extras.items()])
_dict['extras'] = {key: value for key, value in self.extras.items()}
_dict['ratings_average'] = self.get_average_rating()
_dict['ratings_count'] = len(self.ratings)
_dict['resources'] = [res.as_dict(core_columns_only=False) \
Expand Down

0 comments on commit d423687

Please sign in to comment.