Skip to content

Commit

Permalink
Newer versions of flake8 are stricter and have more findings. Use aut…
Browse files Browse the repository at this point in the history
…opep8 to resolve some of these.
  • Loading branch information
Coop56 committed Mar 20, 2019
1 parent 56fbc7e commit f9d6e40
Show file tree
Hide file tree
Showing 68 changed files with 387 additions and 367 deletions.
4 changes: 2 additions & 2 deletions geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def build_haystack_filters(self, parameters):
else:
words = [
w for w in re.split(
'\W',
r'\W',
query,
flags=re.UNICODE) if w]
for i, search_word in enumerate(words):
Expand Down Expand Up @@ -964,7 +964,7 @@ def format_objects(self, objects):
]
for layer in map_layers:
formatted_map_layer = model_to_dict(
layer, fields=map_layer_fields)
layer, fields=map_layer_fields)
formatted_layers.append(formatted_map_layer)
formatted_obj['layers'] = formatted_layers
formatted_objects.append(formatted_obj)
Expand Down
58 changes: 29 additions & 29 deletions geonode/base/populate_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,31 @@ def create_fixtures():
world_extent = [-180, 180, -90, 90]

map_data = [
('GeoNode Default Map', 'GeoNode default map abstract', ('populartag',), world_extent, biota),
('ipsum lorem', 'common ipsum lorem', ('populartag', 'maptagunique'), world_extent, biota),
('lorem1 ipsum1', 'common abstract1', ('populartag',), world_extent, biota),
('ipsum foo', 'common bar lorem', ('populartag',), world_extent, location),
('map one', 'common this is a unique thing', ('populartag',), [0, 1, 0, 1], location),
('quux', 'common double thing', ('populartag',), [0, 5, 0, 5], location),
('morx', 'common thing double', ('populartag',), [0, 10, 0, 10], elevation),
('titledupe something else ', 'whatever common', ('populartag',), [0, 10, 0, 10], elevation),
('something titledupe else ', 'bar common', ('populartag',), [0, 50, 0, 50], elevation),
]
('GeoNode Default Map', 'GeoNode default map abstract', ('populartag',), world_extent, biota),
('ipsum lorem', 'common ipsum lorem', ('populartag', 'maptagunique'), world_extent, biota),
('lorem1 ipsum1', 'common abstract1', ('populartag',), world_extent, biota),
('ipsum foo', 'common bar lorem', ('populartag',), world_extent, location),
('map one', 'common this is a unique thing', ('populartag',), [0, 1, 0, 1], location),
('quux', 'common double thing', ('populartag',), [0, 5, 0, 5], location),
('morx', 'common thing double', ('populartag',), [0, 10, 0, 10], elevation),
('titledupe something else ', 'whatever common', ('populartag',), [0, 10, 0, 10], elevation),
('something titledupe else ', 'bar common', ('populartag',), [0, 50, 0, 50], elevation),
]

user_data = [
('bobby', 'bob', 'bobby', ''),
('norman', 'norman', 'norman', ''),
('user1', 'pass', 'uniquefirst', 'foo'),
('user2', 'pass', 'foo', 'uniquelast'),
('unique_username', 'pass', 'foo', 'uniquelast'),
('jblaze', 'pass', 'johnny', 'blaze'),
('foo', 'pass', 'bar', 'baz'),
]
('bobby', 'bob', 'bobby', ''),
('norman', 'norman', 'norman', ''),
('user1', 'pass', 'uniquefirst', 'foo'),
('user2', 'pass', 'foo', 'uniquelast'),
('unique_username', 'pass', 'foo', 'uniquelast'),
('jblaze', 'pass', 'johnny', 'blaze'),
('foo', 'pass', 'bar', 'baz'),
]

people_data = [
('this contains all my interesting profile information',),
('some other information goes here',),
]
('this contains all my interesting profile information',),
('some other information goes here',),
]
now = datetime.now(timezone.get_current_timezone())
step = timedelta(days=60)

Expand All @@ -146,14 +146,14 @@ def callable():
('common blar', 'lorem ipsum', 'foo', 'geonode:foo', world_extent,
next_date(), ('populartag', 'layertagunique'), location), # flake8: noqa
('common double it', 'whatever', 'whatever', 'geonode:whatever', [
0, 1, 0, 1], next_date(), ('populartag',), location), # flake8: noqa
('common double time', 'else', 'fooey', 'geonode:fooey', [
0, 5, 0, 5], next_date(), ('populartag',), location), # flake8: noqa
('common bar', 'uniqueabstract', 'quux', 'geonode:quux', [
0, 10, 0, 10], next_date(), ('populartag',), biota), # flake8: noqa
('common morx', 'lorem ipsum', 'fleem', 'geonode:fleem', [
0, 50, 0, 50], next_date(), ('populartag',), biota), # flake8: noqa
]
0, 1, 0, 1], next_date(), ('populartag',), location), # flake8: noqa
('common double time', 'else', 'fooey', 'geonode:fooey', [
0, 5, 0, 5], next_date(), ('populartag',), location), # flake8: noqa
('common bar', 'uniqueabstract', 'quux', 'geonode:quux', [
0, 10, 0, 10], next_date(), ('populartag',), biota), # flake8: noqa
('common morx', 'lorem ipsum', 'fleem', 'geonode:fleem', [
0, 50, 0, 50], next_date(), ('populartag',), biota), # flake8: noqa
]

document_data = [('lorem ipsum', 'common lorem ipsum', ('populartag',), world_extent, biota),
('ipsum lorem', 'common ipsum lorem', ('populartag', 'doctagunique'), world_extent, biota),
Expand Down
4 changes: 2 additions & 2 deletions geonode/base/templatetags/base_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def get_menu(placeholder_name):
m: MenuItem.objects.filter(menu=m)
for m in Menu.objects.filter(placeholder__name=placeholder_name)
}
return OrderedDict(sorted(menus.items(), key=lambda(k, v): (v, k)))
return OrderedDict(sorted(menus.items(), key=lambda k_v1: (k_v1[1], k_v1[0])))


@register.inclusion_tag(filename='base/menu.html')
Expand All @@ -343,4 +343,4 @@ def render_nav_menu(placeholder_name):
except BaseException:
pass

return {'menus': OrderedDict(sorted(menus.items(), key=lambda(k, v): (v, k)))}
return {'menus': OrderedDict(sorted(menus.items(), key=lambda k_v: (k_v[1], k_v[0])))}
2 changes: 1 addition & 1 deletion geonode/catalogue/backends/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def extract_links(self, rec):

links = []
# extract subset of description value for user-friendly display
format_re = re.compile(".*\((.*)(\s*Format*\s*)\).*?")
format_re = re.compile(r".*\((.*)(\s*Format*\s*)\).*?")

if not hasattr(rec, 'distribution'):
return None
Expand Down
2 changes: 1 addition & 1 deletion geonode/catalogue/backends/pycsw_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def get_record(self, uuid):

def search_records(self, keywords, start, limit, bbox):
with self.catalogue:
lresults = self._csw_local_dispatch(keywords, keywords, start+1, limit, bbox)
lresults = self._csw_local_dispatch(keywords, keywords, start + 1, limit, bbox)
# serialize XML
e = etree.fromstring(lresults)

Expand Down
4 changes: 2 additions & 2 deletions geonode/catalogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def catalogue_post_save(instance, sender, **kwargs):
catalogue = get_catalogue()
catalogue.create_record(instance)
record = catalogue.get_record(instance.uuid)
except EnvironmentError, err:
except EnvironmentError as err:
msg = 'Could not connect to catalogue to save information for layer "%s"' % instance.name
if err.reason.errno == errno.ECONNREFUSED:
LOGGER.warn(msg, err)
Expand Down Expand Up @@ -116,7 +116,7 @@ def catalogue_pre_save(instance, sender, **kwargs):
try:
catalogue = get_catalogue()
record = catalogue.get_record(instance.uuid)
except EnvironmentError, err:
except EnvironmentError as err:
msg = 'Could not connect to catalogue to save information for layer "%s"' % instance.name
LOGGER.warn(msg, err)
raise err
Expand Down
16 changes: 8 additions & 8 deletions geonode/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ def resource_urls(request):
defaults['GOOGLE_MAPS_API_KEY'] = settings.GOOGLE_MAPS_API_KEY

defaults['WM_COPYRIGHT_URL'] = getattr(
settings,
'WM_COPYRIGHT_URL',
'http://gis.harvard.edu/'
)
settings,
'WM_COPYRIGHT_URL',
'http://gis.harvard.edu/'
)

defaults['WM_COPYRIGHT_TEXT'] = getattr(
settings,
'WM_COPYRIGHT_TEXT',
'Center for Geographic Analysis'
)
settings,
'WM_COPYRIGHT_TEXT',
'Center for Geographic Analysis'
)

defaults['HYPERMAP_REGISTRY_URL'] = settings.HYPERMAP_REGISTRY_URL

Expand Down
8 changes: 4 additions & 4 deletions geonode/contrib/createlayer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ def create_gs_layer(name, title, geometry_type, attributes=None):
"<crs>EPSG:4326</crs></latLonBoundingBox>"
"{attributes}"
"</featureType>").format(
name=name.encode('UTF-8', 'strict'), native_name=native_name.encode('UTF-8', 'strict'),
title=title.encode('UTF-8', 'strict'),
minx=BBOX[0], maxx=BBOX[1], miny=BBOX[2], maxy=BBOX[3],
attributes=attributes_block)
name=name.encode('UTF-8', 'strict'), native_name=native_name.encode('UTF-8', 'strict'),
title=title.encode('UTF-8', 'strict'),
minx=BBOX[0], maxx=BBOX[1], miny=BBOX[2], maxy=BBOX[3],
attributes=attributes_block)

url = ('%s/workspaces/%s/datastores/%s/featuretypes'
% (ogc_server_settings.internal_rest, workspace.name, datastore.name))
Expand Down
1 change: 1 addition & 0 deletions geonode/contrib/favorite/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FavoriteTest(GeoNodeBaseTestSupport):
"""
Tests geonode.contrib.favorite app/module
"""

def setUp(self):
super(FavoriteTest, self).setUp()
self.adm_un = "admin"
Expand Down
4 changes: 2 additions & 2 deletions geonode/contrib/geosites/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
from guardian.shortcuts import get_objects_for_user

from geonode.api.resourcebase_api import CommonModelApi, LayerResource, MapResource, DocumentResource, \
ResourceBaseResource
ResourceBaseResource
from geonode.base.models import ResourceBase
from geonode.api.urls import api
from geonode.api.api import TagResource, TopicCategoryResource, RegionResource, CountJSONSerializer, \
ProfileResource
ProfileResource

from .utils import resources_for_site, users_for_site

Expand Down
11 changes: 6 additions & 5 deletions geonode/contrib/geosites/post_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
#########################################################################

##### Settings to be included last
# Settings to be included last

###############################################
# Master Geosite settings
Expand All @@ -31,23 +31,23 @@
try:
# load in local_settings from system installed geonode
execfile(os.path.join(GEONODE_ROOT, 'local_settings.py'))
except:
except BaseException:
# there are no system geonode local_settings to import
pass

# master local_settings
try:
# load in local_settings (usually for setting SITEURL and DATABASES for production)
execfile(os.path.join(SITE_ROOT, '../', 'local_settings.py'))
except:
except BaseException:
# there are no master local_settings to import
pass

# site local_settings
try:
# load in local_settings (usually for setting SITEURL and DATABASES for production)
execfile(os.path.join(SITE_ROOT, 'local_settings.py'))
except:
except BaseException:
# there are no site local_settings to import
pass

Expand Down Expand Up @@ -78,7 +78,7 @@

# Update apps if site has own apps
if SITE_APPS:
INSTALLED_APPS += SITE_APPS
INSTALLED_APPS += SITE_APPS

# Put static files in root
STATIC_ROOT = os.path.join(SERVE_PATH, 'static')
Expand Down Expand Up @@ -111,6 +111,7 @@
# DEBUG_TOOLBAR can interfere with Django - keep it off until needed
if DEBUG_TOOLBAR:
DEBUG_TOOLBAR_PATCH_SETTINGS = False

def show_if_superuser(request):
return True if request.user.is_superuser else False
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
Expand Down
7 changes: 3 additions & 4 deletions geonode/contrib/geosites/pre_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
#########################################################################

##### Settings to be included first
# Settings to be included first

# Default Django settings for GeoNode.
import os
Expand Down Expand Up @@ -56,7 +56,7 @@
# internal url to GeoServer
GEOSERVER_URL = 'http://localhost:8080/geoserver/'

##### Global Overrides
# Global Overrides
# Below are some common GeoNode settings that might be overridden to provide
# global setting acrosss all sites. Can be overridden in a sites settings.

Expand All @@ -74,7 +74,7 @@
#PROXY_ALLOWED_HOSTS = ('.domain',)


##### Production settings
# Production settings

# DEBUG Settings
DEBUG = True
Expand All @@ -87,4 +87,3 @@
from local_settings import *
except ImportError:
pass

4 changes: 2 additions & 2 deletions geonode/contrib/geosites/site_template/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
try:
# read in project pre_settings
execfile(os.path.join(SITE_ROOT, '../', 'pre_settings.py'))
except:
except BaseException:
# if not available, read in GeoSites pre_settings
execfile(os.path.join(GEOSITES_ROOT, 'pre_settings.py'))

Expand Down Expand Up @@ -67,6 +67,6 @@
try:
# read in project pre_settings
execfile(os.path.join(SITE_ROOT, '../', 'post_settings.py'))
except:
except BaseException:
# if not available, read in GeoSites pre_settings
execfile(os.path.join(GEOSITES_ROOT, 'post_settings.py'))
4 changes: 2 additions & 2 deletions geonode/contrib/geosites/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def setUp(self):
'pk': self.slave_site.pk})
self.api_layer_url = reverse('api_dispatch_list',
kwargs={
'api_name': 'api',
'resource_name': 'layers'})
'api_name': 'api',
'resource_name': 'layers'})

self.anonymous_user = get_anonymous_user()
self.slave2_data = {'name': 'Slave2',
Expand Down
2 changes: 1 addition & 1 deletion geonode/contrib/geosites/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from geonode.urls import urlpatterns
from .api import api
from .views import site_layer_detail, site_document_detail, site_map_detail, layer_acls, \
ajax_login, ajax_lookup, SiteLoginView
ajax_login, ajax_lookup, SiteLoginView

from geonode.geoserver import views
from geonode.layers import views as layers_views
Expand Down
12 changes: 6 additions & 6 deletions geonode/contrib/metadataxsl/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ def add_xsl_link(resourcebase):
url = urljoin(site_url, urlpath)

link, created = Link.objects.get_or_create(
resource=resourcebase,
url=url,
defaults=dict(name=ISO_XSL_NAME,
extension='xml',
mime='text/xml',
link_type='metadata'))
resource=resourcebase,
url=url,
defaults=dict(name=ISO_XSL_NAME,
extension='xml',
mime='text/xml',
link_type='metadata'))
return created


Expand Down
4 changes: 2 additions & 2 deletions geonode/contrib/monitoring/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class MonitoringAppConfig(NotificationsAppConfigBase):
NOTIFICATIONS = ((NOTIFICATION_NAME,
_("Monitoring alert"),
_("Alert situation reported by monitoring"),
),
)
),
)

def ready(self):
super(MonitoringAppConfig, self).ready()
Expand Down
2 changes: 1 addition & 1 deletion geonode/contrib/monitoring/probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def m(val):
'used': m(vm.used),
'free': m(vm.available),
'usage': vm.used,
'usage.percent': ((vm.used * 100.0)/vm.total),
'usage.percent': ((vm.used * 100.0) / vm.total),
}

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions geonode/contrib/monitoring/service_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ def handle_collected(self, data, *args, **kwargs):
services = dict(
(c.get_name(), c,)
for c in (
GeoNodeService,
GeoServerService,
HostGeoNodeService,
HostGeoServerService,))
GeoNodeService,
GeoServerService,
HostGeoNodeService,
HostGeoServerService,))


def get_for_service(sname):
Expand Down

0 comments on commit f9d6e40

Please sign in to comment.