Skip to content

Commit 5a97c34

Browse files
authored
Reformatting for latest Black (GeoNode#11915)
1 parent bf9b500 commit 5a97c34

37 files changed

+48
-86
lines changed

create-envfile.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ def _get_vals_to_replace(args):
9292
_vals_to_replace["letsencrypt_mode"] = (
9393
"disabled"
9494
if not _vals_to_replace.get("https_host")
95-
else "staging"
96-
if _jsfile.get("env_type", args.env_type) in ["test"]
97-
else "production"
95+
else "staging" if _jsfile.get("env_type", args.env_type) in ["test"] else "production"
9896
)
9997
_vals_to_replace["debug"] = False if _jsfile.get("env_type", args.env_type) in ["prod", "test"] else True
10098
_vals_to_replace["email"] = _jsfile.get("email", args.email)
@@ -124,7 +122,7 @@ def _get_vals_to_replace(args):
124122
prog="ENV file builder",
125123
description="Tool for generate environment file automatically. The information can be passed or via CLI or via JSON file ( --file /path/env.json)",
126124
usage="python create-envfile.py localhost -f /path/to/json/file.json",
127-
allow_abbrev=False
125+
allow_abbrev=False,
128126
)
129127
parser.add_argument(
130128
"--noinput",

geonode/api/resourcebase_api.py

-6
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ def hydrate_title(self, bundle):
593593

594594

595595
class ResourceBaseResource(CommonModelApi):
596-
597596
"""ResourceBase api"""
598597

599598
class Meta(CommonMetaApi):
@@ -607,7 +606,6 @@ class Meta(CommonMetaApi):
607606

608607

609608
class FeaturedResourceBaseResource(CommonModelApi):
610-
611609
"""Only the featured resourcebases"""
612610

613611
class Meta(CommonMetaApi):
@@ -620,7 +618,6 @@ class Meta(CommonMetaApi):
620618

621619

622620
class LayerResource(CommonModelApi):
623-
624621
"""Dataset API"""
625622

626623
links = fields.ListField(attribute="links", null=True, use_in="all", default=[])
@@ -756,7 +753,6 @@ class Meta(CommonMetaApi):
756753

757754

758755
class MapResource(CommonModelApi):
759-
760756
"""Maps API"""
761757

762758
def build_filters(self, filters=None, ignore_bad_filters=False, **kwargs):
@@ -822,7 +818,6 @@ class Meta(CommonMetaApi):
822818

823819

824820
class GeoAppResource(CommonModelApi):
825-
826821
"""GeoApps API"""
827822

828823
def format_objects(self, objects):
@@ -874,7 +869,6 @@ class Meta(CommonMetaApi):
874869

875870

876871
class DocumentResource(CommonModelApi):
877-
878872
"""Documents API"""
879873

880874
def build_filters(self, filters=None, ignore_bad_filters=False, **kwargs):

geonode/api/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ def test_tags_lockdown(self):
386386

387387

388388
class SearchApiTests(ResourceTestCaseMixin, GeoNodeBaseTestSupport):
389-
390389
"""Test the search"""
391390

392391
# loading test thesausuri and initial data

geonode/base/api/permissions.py

-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242

4343
class IsSelf(permissions.BasePermission):
44-
4544
"""Grant permission only if the current instance is the request user.
4645
Used to allow users to edit their own account, nothing to others (even
4746
superusers).
@@ -62,7 +61,6 @@ def has_object_permission(self, request, view, obj):
6261

6362

6463
class IsSelfOrReadOnly(IsSelf):
65-
6664
"""Grant permissions if instance *IS* the request user, or read-only.
6765
Used to allow users to edit their own account, and others to read.
6866
"""
@@ -75,7 +73,6 @@ def has_object_permission(self, request, view, obj):
7573

7674

7775
class IsSelfOrAdmin(IsSelf):
78-
7976
"""Grant R/W to self and superusers/staff members. Deny others."""
8077

8178
def has_permission(self, request, view):
@@ -94,7 +91,6 @@ def has_object_permission(self, request, view, obj):
9491

9592

9693
class IsSelfOrAdminOrReadOnly(IsSelfOrAdmin):
97-
9894
"""Grant R/W to self and superusers/staff members, R/O to others."""
9995

10096
def has_permission(self, request, view):
@@ -111,7 +107,6 @@ def has_object_permission(self, request, view, obj):
111107

112108

113109
class IsSelfOrAdminOrAuthenticatedReadOnly(IsSelfOrAdmin):
114-
115110
"""Grant R/W to self and superusers/staff members, R/O to auth."""
116111

117112
def has_object_permission(self, request, view, obj):

geonode/base/api/serializers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class Meta:
655655
"is_copyable",
656656
"blob",
657657
"metadata",
658-
"executions"
658+
"executions",
659659
# TODO
660660
# csw_typename, csw_schema, csw_mdsource, csw_insert_date, csw_type, csw_anytext, csw_wkt_geometry,
661661
# metadata_uploaded, metadata_uploaded_preserve, metadata_xml,

geonode/base/api/tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1951,10 +1951,10 @@ def test_set_resource_thumbnail(self):
19511951
self.assertEqual(response.json(), "The url must be of an image with format (png, jpeg or jpg)")
19521952

19531953
# using Base64 data as an ASCII byte string
1954-
data[
1955-
"file"
1956-
] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABHNCSVQICAgI\
1954+
data["file"] = (
1955+
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABHNCSVQICAgI\
19571956
fAhkiAAAABl0RVh0U29mdHdhcmUAZ25vbWUtc2NyZWVuc2hvdO8Dvz4AAAANSURBVAiZYzAxMfkPAALYAZzx61+bAAAAAElFTkSuQmCC"
1957+
)
19581958
with patch("geonode.base.models.is_monochromatic_image") as _mck:
19591959
_mck.return_value = False
19601960
response = self.client.put(url, data=data, format="json")

geonode/base/forms.py

-1
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ def build_attrs(self, base_attrs=None, extra_attrs=None, **kwargs):
412412

413413

414414
class ResourceBaseForm(TranslationModelForm, LinkedResourceForm):
415-
416415
"""Base form for metadata, should be inherited by childres classes of ResourceBase"""
417416

418417
abstract = forms.CharField(label=_("Abstract"), required=False, widget=TinyMCE())

geonode/base/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ def test_add_missing_metadata_author_or_poc(self):
166166

167167

168168
class TestCreationOfContactRolesByDifferentInputTypes(ThumbnailTests):
169-
170169
"""
171170
Test that contact roles can be set as people profile
172171
"""

geonode/catalogue/metadataxsl/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626

2727
class MetadataXSLTest(GeoNodeBaseTestSupport):
28-
2928
"""
3029
Tests geonode.catalogue.metadataxsl app/module
3130
"""

geonode/context_processors.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ def resource_urls(request):
8686
EXIF_ENABLED=getattr(settings, "EXIF_ENABLED", False),
8787
FAVORITE_ENABLED=getattr(settings, "FAVORITE_ENABLED", False),
8888
SEARCH_FILTERS=getattr(settings, "SEARCH_FILTERS", False),
89-
THESAURI_FILTERS=[
90-
t["name"]
91-
for t in [
92-
settings.THESAURUS,
89+
THESAURI_FILTERS=(
90+
[
91+
t["name"]
92+
for t in [
93+
settings.THESAURUS,
94+
]
95+
if t.get("filter")
9396
]
94-
if t.get("filter")
95-
]
96-
if hasattr(settings, "THESAURUS")
97-
else [t.identifier for t in thesaurus],
97+
if hasattr(settings, "THESAURUS")
98+
else [t.identifier for t in thesaurus]
99+
),
98100
MAP_CLIENT_USE_CROSS_ORIGIN_CREDENTIALS=getattr(settings, "MAP_CLIENT_USE_CROSS_ORIGIN_CREDENTIALS", False),
99101
SHOW_PROFILE_EMAIL=getattr(settings, "SHOW_PROFILE_EMAIL", False),
100102
OGC_SERVER=getattr(settings, "OGC_SERVER", None),

geonode/documents/forms.py

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class DocumentDescriptionForm(forms.Form):
117117

118118

119119
class DocumentCreateForm(TranslationModelForm):
120-
121120
"""
122121
The document upload form.
123122
"""

geonode/documents/models.py

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838

3939
class Document(ResourceBase):
40-
4140
"""
4241
A document is any kind of information that can be attached to a map such as pdf, images, videos, xls...
4342
"""

geonode/documents/views.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,11 @@ def document_metadata(
322322
category_form = CategoryForm(
323323
request.POST,
324324
prefix="category_choice_field",
325-
initial=int(request.POST["category_choice_field"])
326-
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
327-
else None,
325+
initial=(
326+
int(request.POST["category_choice_field"])
327+
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
328+
else None
329+
),
328330
)
329331

330332
if hasattr(settings, "THESAURUS"):

geonode/geoapps/models.py

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232

3333
class GeoApp(ResourceBase):
34-
3534
"""
3635
A GeoApp it is a generic container for every client applications the
3736
user might want to create or define.

geonode/geoapps/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232

3333
class GeoAppTests(GeoNodeBaseTestSupport):
34-
3534
"""Tests geonode.geoapps module"""
3635

3736
fixtures = ["initial_data.json", "group_test_data.json", "default_oauth_apps.json"]

geonode/geoapps/views.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,11 @@ def geoapp_metadata(
216216
category_form = CategoryForm(
217217
request.POST,
218218
prefix="category_choice_field",
219-
initial=int(request.POST["category_choice_field"])
220-
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
221-
else None,
219+
initial=(
220+
int(request.POST["category_choice_field"])
221+
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
222+
else None
223+
),
222224
)
223225

224226
if hasattr(settings, "THESAURUS"):

geonode/geoserver/createlayer/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434

3535
class CreateLayerCoreTest(GeoNodeBaseTestSupport):
36-
3736
"""
3837
Test createlayer application.
3938
"""

geonode/geoserver/tests/integration.py

-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def _log(msg, *args):
5656

5757
@override_settings(SITEURL="http://localhost:8001/")
5858
class GeoNodeGeoServerSync(GeoNodeLiveTestSupport):
59-
6059
"""
6160
Tests GeoNode/GeoServer syncronization
6261
"""
@@ -104,7 +103,6 @@ def test_set_attributes_from_geoserver(self):
104103

105104
@override_settings(SITEURL="http://localhost:8002/")
106105
class GeoNodeGeoServerCapabilities(GeoNodeLiveTestSupport):
107-
108106
"""
109107
Tests GeoNode/GeoServer GetCapabilities per layer, user, category and map
110108
"""

geonode/harvesting/harvesters/geonodeharvester.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,14 @@ def _get_resource_list_params(self, offset: typing.Optional[int] = 0) -> typing.
433433
result["filter{title.icontains}"] = self.resource_title_filter
434434
if self.start_date_filter is not None:
435435
start_date = dateutil.parser.parse(self.start_date_filter)
436-
result[
437-
"filter{date.gte}"
438-
] = f"{start_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
436+
result["filter{date.gte}"] = (
437+
f"{start_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
438+
)
439439
if self.end_date_filter is not None:
440440
end_date = dateutil.parser.parse(self.end_date_filter)
441-
result[
442-
"filter{date.lte}"
443-
] = f"{end_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
441+
result["filter{date.lte}"] = (
442+
f"{end_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
443+
)
444444
if self.keywords_filter is not None:
445445
result["filter{keywords.slug.in}"] = self.keywords_filter
446446
if self.categories_filter is not None:
@@ -738,14 +738,14 @@ def _get_resource_list_params(self, offset: typing.Optional[int] = 0) -> typing.
738738
result["title__icontains"] = self.resource_title_filter
739739
if self.start_date_filter is not None:
740740
start_date = dateutil.parser.parse(self.start_date_filter)
741-
result[
742-
"date__gte"
743-
] = f"{start_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
741+
result["date__gte"] = (
742+
f"{start_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
743+
)
744744
if self.end_date_filter is not None:
745745
end_date = dateutil.parser.parse(self.end_date_filter)
746-
result[
747-
"date__lte"
748-
] = f"{end_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
746+
result["date__lte"] = (
747+
f"{end_date.astimezone(dt.timezone.utc).replace(microsecond=0).isoformat().split('+')[0]}Z"
748+
)
749749
if self.keywords_filter is not None:
750750
result["keywords__slug__in"] = ",".join(self.keywords_filter)
751751
if self.categories_filter is not None:

geonode/layers/models.py

-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161

6262

6363
class Style(models.Model, PermissionLevelMixin):
64-
6564
"""Model for storing styles."""
6665

6766
name = models.CharField(_("style name"), max_length=255, unique=True)
@@ -103,7 +102,6 @@ def __init__(self):
103102

104103

105104
class Dataset(ResourceBase):
106-
107105
"""
108106
Dataset (inherits ResourceBase fields)
109107
"""
@@ -376,15 +374,13 @@ def view_count_up(self, user, do_local=False):
376374

377375

378376
class AttributeManager(models.Manager):
379-
380377
"""Helper class to access filtered attributes"""
381378

382379
def visible(self):
383380
return self.get_queryset().filter(visible=True).order_by("display_order")
384381

385382

386383
class Attribute(models.Model):
387-
388384
"""
389385
Auxiliary model for storing layer attributes.
390386

geonode/layers/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090

9191

9292
class DatasetsTest(GeoNodeBaseTestSupport):
93-
9493
"""Tests geonode.layers app/module"""
9594

9695
type = "dataset"

geonode/layers/views.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,11 @@ def dataset_metadata(
414414
category_form = CategoryForm(
415415
request.POST,
416416
prefix="category_choice_field",
417-
initial=int(request.POST["category_choice_field"])
418-
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
419-
else None,
417+
initial=(
418+
int(request.POST["category_choice_field"])
419+
if "category_choice_field" in request.POST and request.POST["category_choice_field"]
420+
else None
421+
),
420422
)
421423
if not category_form.is_valid():
422424
logger.error(f"Dataset Category form is not valid: {category_form.errors}")

geonode/maps/models.py

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838

3939
class Map(ResourceBase):
40-
4140
"""
4241
A Map aggregates several layers together and annotates them with a viewport
4342
configuration.
@@ -231,7 +230,6 @@ class Meta(ResourceBase.Meta):
231230

232231

233232
class MapLayer(models.Model):
234-
235233
"""
236234
The MapLayer model represents a layer included in a map. This doesn't just
237235
identify the dataset, but also extra options such as which style to load

geonode/maps/tests.py

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979

8080

8181
class MapsTest(NotificationsTestsHelper):
82-
8382
"""Tests geonode.maps app/module"""
8483

8584
fixtures = ["initial_data.json", "group_test_data.json", "default_oauth_apps.json"]

0 commit comments

Comments
 (0)