Skip to content

Commit

Permalink
[Issue #6843] Remove redundant enumerate calls (#6836)
Browse files Browse the repository at this point in the history
* Removed redundant enumerate uses.

* flake8 fixes

Co-authored-by: Alessio Fabiani <[email protected]>
Co-authored-by: Matthew Northcott <[email protected]>
Co-authored-by: Toni <[email protected]>
  • Loading branch information
4 people authored Jan 27, 2021
1 parent 2a8786c commit e25c1ce
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,12 +1588,10 @@ def set_missing_info(self):
self.metadata_author = user

def maintenance_frequency_title(self):
return [v for i, v in enumerate(
UPDATE_FREQUENCIES) if v[0] == self.maintenance_frequency][0][1].title()
return [v for v in UPDATE_FREQUENCIES if v[0] == self.maintenance_frequency][0][1].title()

def language_title(self):
return [v for i, v in enumerate(
ALL_LANGUAGES) if v[0] == self.language][0][1].title()
return [v for v in ALL_LANGUAGES if v[0] == self.language][0][1].title()

def _set_poc(self, poc):
# reset any poc assignation to this resource
Expand Down
5 changes: 2 additions & 3 deletions geonode/layers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,9 @@ def sld_definition(style):
links = layer.link_set.download().filter(
Q(name__in=settings.DOWNLOAD_FORMATS_RASTER) |
Q(link_type='original'))
links_view = [item for idx, item in enumerate(links) if
links_view = [item for item in links if
item.link_type == 'image']
links_download = [item for idx, item in enumerate(
links) if item.link_type in ('data', 'original')]
links_download = [item for item in links if item.link_type in ('data', 'original')]
for item in links_view:
if item.url and access_token and 'access_token' not in item.url:
params = {'access_token': access_token}
Expand Down
2 changes: 1 addition & 1 deletion geonode/proxy/templatetags/proxy_lib_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def original_link_available(context, resourceid, url):
upload_session = instance.get_upload_session()
if upload_session:
layer_files = [
item for idx, item in enumerate(LayerFile.objects.filter(upload_session=upload_session))]
item for item in LayerFile.objects.filter(upload_session=upload_session)]
if layer_files:
for lyr in layer_files:
if not storage.exists(str(lyr.file)):
Expand Down
4 changes: 2 additions & 2 deletions geonode/security/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def purge_geofence_all():
if rules_count > 0:
# Delete GeoFence Rules associated to the Layer
# curl -X DELETE -u admin:geoserver http://<host>:<port>/geoserver/rest/geofence/rules/id/{r_id}
for i, rule in enumerate(rules):
for rule in rules:
r = requests.delete(url + 'rest/geofence/rules/id/' + str(rule['id']),
headers=headers,
auth=HTTPBasicAuth(user, passwd))
Expand Down Expand Up @@ -291,7 +291,7 @@ def purge_geofence_layer_rules(resource):

# Delete GeoFence Rules associated to the Layer
# curl -X DELETE -u admin:geoserver http://<host>:<port>/geoserver/rest/geofence/rules/id/{r_id}
for i, r_id in enumerate(r_ids):
for r_id in r_ids:
r = requests.delete(
url + 'rest/geofence/rules/id/' + str(r_id),
headers=headers,
Expand Down
2 changes: 1 addition & 1 deletion geonode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def _base_source(source):
del base_source[key]
return base_source

for idx, lyr in enumerate(settings.MAP_BASELAYERS):
for lyr in settings.MAP_BASELAYERS:
if "source" in lyr and _base_source(
lyr["source"]) not in map(
_base_source,
Expand Down

0 comments on commit e25c1ce

Please sign in to comment.