Skip to content

Commit 47a8df2

Browse files
committed
Ran black
1 parent c309fcb commit 47a8df2

24 files changed

Lines changed: 2903 additions & 1358 deletions

clients/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.2.0'
1+
__version__ = "2.2.0"

clients/arcgis.py

Lines changed: 371 additions & 139 deletions
Large diffs are not rendered by default.

clients/exceptions.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def __init__(self, message, url=None, **kwargs):
2222

2323

2424
class ClientRequestError(ClientError):
25-
2625
def __init__(self, message, params=None, status_code=None, **kwargs):
2726
super(ClientRequestError, self).__init__(message, **kwargs)
2827

@@ -51,7 +50,6 @@ class ServiceTimeout(ServiceError, requests.exceptions.Timeout):
5150

5251

5352
class ImageError(ClientError):
54-
5553
def __init__(self, message, params=None, tile_info=None, **kwargs):
5654
super(ImageError, self).__init__(message, **kwargs)
5755

@@ -60,27 +58,25 @@ def __init__(self, message, params=None, tile_info=None, **kwargs):
6058

6159

6260
class ValidationError(ClientError, AttributeError):
63-
6461
def __init__(self, message, **kwargs):
6562
super(ValidationError, self).__init__(message, **kwargs)
6663

6764

6865
class BadExtent(ValidationError, ValueError):
69-
7066
def __init__(self, message, extent=None, **kwargs):
7167
super(BadExtent, self).__init__(message, **kwargs)
7268
self.error_context["extent"] = self.extent = extent
7369

7470

7571
class BadSpatialReference(BadExtent):
76-
7772
def __init__(self, message, spatial_reference=None, **kwargs):
7873
super(BadSpatialReference, self).__init__(message, **kwargs)
79-
self.error_context["spatial_reference"] = self.spatial_reference = spatial_reference
74+
self.error_context[
75+
"spatial_reference"
76+
] = self.spatial_reference = spatial_reference
8077

8178

8279
class BadTileScheme(ValidationError, ValueError):
83-
8480
def __init__(self, message, tile_info=None, **kwargs):
8581
super(BadTileScheme, self).__init__(message, **kwargs)
8682
self.error_context["tile_info"] = self.tile_info = tile_info
@@ -91,17 +87,17 @@ class NoLayers(ValidationError):
9187

9288

9389
class MissingFields(ValidationError, MissingFieldException):
94-
9590
def __init__(self, message, missing=None, **kwargs):
9691
super(MissingFields, self).__init__(message, **kwargs)
9792
self.error_context["missing"] = self.missing = wrap_value(missing)
9893

9994

10095
class UnsupportedVersion(ValidationError):
101-
10296
def __init__(self, message, invalid=None, supported=None, **kwargs):
10397
super(UnsupportedVersion, self).__init__(message, **kwargs)
10498

10599
self.invalid = invalid
106100
self.supported = wrap_value(supported)
107-
self.error_context.update({"invalid": self.invalid, "supported": self.supported})
101+
self.error_context.update(
102+
{"invalid": self.invalid, "supported": self.supported}
103+
)

clients/query/arcgis.py

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,36 @@
55

66

77
FEATURE_LAYER_PARAMS = (
8-
"f", "where", "object_ids", "geometry", "geometry_type", "in_sr", "spatial_rel", "relation_param", "time",
9-
"distance", "units", "out_fields", "return_geometry", "max_allowable_offset", "geometry_precision",
10-
"out_sr", "gdb_version", "return_distinct_values", "return_ids_only", "return_count_only",
11-
"return_extent_only", "order_by_fields", "group_by_fields_for_statistics", "out_statistics", "return_z",
12-
"return_m", "multipatch_option", "result_offset", "result_record_count", "token"
8+
"f",
9+
"where",
10+
"object_ids",
11+
"geometry",
12+
"geometry_type",
13+
"in_sr",
14+
"spatial_rel",
15+
"relation_param",
16+
"time",
17+
"distance",
18+
"units",
19+
"out_fields",
20+
"return_geometry",
21+
"max_allowable_offset",
22+
"geometry_precision",
23+
"out_sr",
24+
"gdb_version",
25+
"return_distinct_values",
26+
"return_ids_only",
27+
"return_count_only",
28+
"return_extent_only",
29+
"order_by_fields",
30+
"group_by_fields_for_statistics",
31+
"out_statistics",
32+
"return_z",
33+
"return_m",
34+
"multipatch_option",
35+
"result_offset",
36+
"result_record_count",
37+
"token",
1338
)
1439
FEATURE_LAYER_QUERY = QueryAction(
1540
"query",
@@ -39,12 +64,12 @@
3964
"return_m": "returnM",
4065
"multipatch_option": "multipatchOption",
4166
"result_offset": "resultOffset",
42-
"result_record_count": "resultRecordCount"
67+
"result_record_count": "resultRecordCount",
4368
},
4469
params_via_post=True,
4570
serializer=URLSerializer,
4671
deserializer=JSONSerializer,
47-
response_type=Action.DICT_RESPONSE
72+
response_type=Action.DICT_RESPONSE,
4873
)
4974

5075
FEATURE_LAYER_TIME_PARAMS = ("f", "token")
@@ -57,14 +82,27 @@
5782
params_via_post=True,
5883
serializer=URLSerializer,
5984
deserializer=JSONSerializer,
60-
response_type=Action.DICT_RESPONSE
85+
response_type=Action.DICT_RESPONSE,
6186
)
6287

6388

6489
FEATURE_SERVER_PARAMS = (
65-
"f", "layer_defs", "geometry", "geometry_type", "in_sr", "spatial_rel", "time", "out_sr", "gdb_version",
66-
"return_geometry", "max_allowable_offset", "return_ids_only", "return_count_only", "return_z", "return_m",
67-
"geometry_precision"
90+
"f",
91+
"layer_defs",
92+
"geometry",
93+
"geometry_type",
94+
"in_sr",
95+
"spatial_rel",
96+
"time",
97+
"out_sr",
98+
"gdb_version",
99+
"return_geometry",
100+
"max_allowable_offset",
101+
"return_ids_only",
102+
"return_count_only",
103+
"return_z",
104+
"return_m",
105+
"geometry_precision",
68106
)
69107
FEATURE_SERVER_QUERY = QueryAction(
70108
"query",
@@ -83,9 +121,9 @@
83121
"return_count_only": "returnCountOnly",
84122
"return_z": "returnZ",
85123
"return_m": "returnM",
86-
"geometry_precision": "geometryPrecision"
124+
"geometry_precision": "geometryPrecision",
87125
},
88126
params_via_post=True,
89127
serializer=URLSerializer,
90-
response_type=Action.DICT_RESPONSE
128+
response_type=Action.DICT_RESPONSE,
91129
)

clients/query/fields.py

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class DictField(fields.DictField):
1414
handle defaults and support aliases for dict keys
1515
"""
1616

17-
def __init__(self, aliases=None, convert_camel=True, defaults=None, *args, **kwargs):
17+
def __init__(
18+
self, aliases=None, convert_camel=True, defaults=None, *args, **kwargs
19+
):
1820
self.convert_camel = convert_camel
1921
self.aliases = aliases or {}
2022
self.defaults = defaults or []
@@ -41,7 +43,11 @@ def convert(val):
4143

4244
if isinstance(value, dict):
4345
d = {self.aliases.get(k, k): convert(v) for k, v in value.items()}
44-
return {camel_to_snake(k): v for k, v in d.items()} if self.convert_camel else d
46+
return (
47+
{camel_to_snake(k): v for k, v in d.items()}
48+
if self.convert_camel
49+
else d
50+
)
4551

4652
elif isinstance(value, list):
4753
return [convert(v) for v in value]
@@ -68,10 +74,19 @@ def to_python(self, value, resource):
6874
class ObjectField(fields.ObjectField):
6975
""" Overridden to convert camel properties to snake by default, and to add get_data method to custom types """
7076

71-
def __init__(self, class_name="AnonymousObject", aliases=None, convert_camel=True, *args, **kwargs):
77+
def __init__(
78+
self,
79+
class_name="AnonymousObject",
80+
aliases=None,
81+
convert_camel=True,
82+
*args,
83+
**kwargs,
84+
):
7285
self.convert_camel = convert_camel
7386

74-
super(ObjectField, self).__init__(class_name=class_name, aliases=aliases or {}, *args, **kwargs)
87+
super(ObjectField, self).__init__(
88+
class_name=class_name, aliases=aliases or {}, *args, **kwargs
89+
)
7590

7691
def to_data(self, value):
7792
if isinstance(value, list):
@@ -83,7 +98,9 @@ def to_python(self, value, resource):
8398

8499
if isinstance(value, dict):
85100
d = {
86-
self.aliases.get(k, k): self.to_python(v, resource) if isinstance(v, (dict, list)) else v
101+
self.aliases.get(k, k): self.to_python(v, resource)
102+
if isinstance(v, (dict, list))
103+
else v
87104
for k, v in value.items()
88105
}
89106
if self.convert_camel:
@@ -100,7 +117,10 @@ def to_python(self, value, resource):
100117
return obj
101118

102119
elif isinstance(value, list):
103-
return [self.to_python(x, resource) if isinstance(x, (dict, list)) else x for x in value]
120+
return [
121+
self.to_python(x, resource) if isinstance(x, (dict, list)) else x
122+
for x in value
123+
]
104124
else:
105125
return value
106126

@@ -110,7 +130,9 @@ class CommaSeparatedField(fields.TextField):
110130

111131
def to_python(self, value, resource):
112132
if not isinstance(value, list):
113-
value = super(CommaSeparatedField, self).to_python(value, resource).split(",")
133+
value = (
134+
super(CommaSeparatedField, self).to_python(value, resource).split(",")
135+
)
114136

115137
return [str(val).strip() for val in value if val] if value else []
116138

@@ -119,12 +141,13 @@ def to_value(self, obj, resource):
119141

120142

121143
class DrawingInfoField(ObjectField):
122-
123144
def __init__(self, *args, **kwargs):
124145
self.renderer_defaults = RENDERER_DEFAULTS
125146

126147
aliases = dict(DRAWING_INFO_ALIASES)
127-
super(DrawingInfoField, self).__init__(class_name="DrawingInfo", aliases=aliases, *args, **kwargs)
148+
super(DrawingInfoField, self).__init__(
149+
class_name="DrawingInfo", aliases=aliases, *args, **kwargs
150+
)
128151

129152
def to_python(self, value, resource):
130153
""" Overridden to ensure the presence of field properties in renderer """
@@ -136,7 +159,6 @@ def to_python(self, value, resource):
136159

137160

138161
class BaseExtentField(DictField):
139-
140162
def __init__(self, esri_format=True, *args, **kwargs):
141163
self.esri_format = esri_format
142164

@@ -171,7 +193,6 @@ def _py_to_val(self, obj, resource):
171193

172194

173195
class ExtentField(BaseExtentField):
174-
175196
def _val_to_py(self, value, resource):
176197
try:
177198
return Extent(value)
@@ -180,17 +201,17 @@ def _val_to_py(self, value, resource):
180201

181202

182203
class SpatialReferenceField(BaseExtentField):
183-
184204
def _val_to_py(self, value, resource):
185205
return SpatialReference(value)
186206

187207

188208
class TimeInfoField(ObjectField):
189-
190209
def __init__(self, *args, **kwargs):
191210
aliases = dict(TIME_INFO_ALIASES)
192211

193-
super(TimeInfoField, self).__init__(class_name="TimeInfo", aliases=aliases, *args, **kwargs)
212+
super(TimeInfoField, self).__init__(
213+
class_name="TimeInfo", aliases=aliases, *args, **kwargs
214+
)
194215

195216

196217
DRAWING_INFO_ALIASES = {
@@ -202,7 +223,6 @@ def __init__(self, *args, **kwargs):
202223
"minScale": "min_scale",
203224
"maxScale": "max_scale",
204225
"whereClause": "where",
205-
206226
# Renderer
207227
"defaultSymbol": "default_symbol",
208228
"defaultLabel": "default_label",
@@ -214,12 +234,10 @@ def __init__(self, *args, **kwargs):
214234
"normalizationTotal": "normalization_total",
215235
"backgroundFillSymbol": "background_fill_symbol",
216236
"minValue": "min",
217-
218237
# Class Break Info
219238
"classBreakInfos": "class_breaks",
220239
"classMinValue": "min",
221240
"classMaxValue": "max",
222-
223241
# Symbol
224242
"xoffset": "offset_x",
225243
"yoffset": "offset_y",
@@ -232,7 +250,7 @@ def __init__(self, *args, **kwargs):
232250
"haloColor": "halo_color",
233251
"horizontalAlignment": "horizontal_alignment",
234252
"verticalAlignment": "vertical_alignment",
235-
"rightToLeft": "is_rtl"
253+
"rightToLeft": "is_rtl",
236254
}
237255

238256
RENDERER_ALIASES = {
@@ -250,20 +268,18 @@ def __init__(self, *args, **kwargs):
250268
"minValue": "min_val",
251269
"imageData": "image",
252270
"xoffset": "offset_x",
253-
"yoffset": "offset_y"
271+
"yoffset": "offset_y",
254272
}
255273
RENDERER_DEFAULTS = ("default_symbol", "field", "field1", "field2", "field3", "label")
256274

257275
TIME_INFO_ALIASES = {
258276
"startTimeField": "start_field",
259277
"endTimeField": "end_field",
260278
"trackIdField": "track_field",
261-
262279
# Used at the map service layer level (time data is layer specific)
263280
"timeInterval": "interval",
264281
"timeIntervalUnits": "units",
265-
266282
# Used at the map service level (defaults if not defined in layer)
267283
"defaultTimeInterval": "default_interval",
268-
"defaultTimeIntervalUnits": "default_units"
284+
"defaultTimeIntervalUnits": "default_units",
269285
}

0 commit comments

Comments
 (0)