Skip to content

Commit e63ad67

Browse files
author
Taher Chegini
committed
ENH: Address issues raised by refurb. [skip ci]
1 parent 010b361 commit e63ad67

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

pygeoogc/cache_keys.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def create_request_key(
5656
norm_url = _normalize_url_params(url, params)
5757

5858
# Create a hash based on the normalized and filtered request
59-
key = hashlib.sha256(
59+
return hashlib.sha256(
6060
method.upper().encode() + str(norm_url).encode() + _encode_dict(data) + _encode_dict(json)
61-
)
62-
return key.hexdigest()
61+
).hexdigest()

pygeoogc/core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __init__(
123123
def _set_service_properties(self) -> None:
124124
rjson = self.get_response(self.base_url, [{"f": "json"}])[0]
125125
try:
126-
self.valid_layers = {f"{lyr['id']}": lyr["name"] for lyr in rjson["layers"]}
126+
self.valid_layers = {str(lyr["id"]): lyr["name"] for lyr in rjson["layers"]}
127127
self.query_formats = rjson["supportedQueryFormats"].replace(" ", "").lower().split(",")
128128

129129
extent = rjson["extent"] if "extent" in rjson else rjson["fullExtent"]
@@ -183,7 +183,7 @@ def _set_layer_properties(self) -> None:
183183
def initialize_service(self) -> None:
184184
"""Initialize the RESTFul service."""
185185
self._set_service_properties()
186-
if f"{self.layer}" not in self.valid_layers:
186+
if str(self.layer) not in self.valid_layers:
187187
valids = [f'"{i}" for {n}' for i, n in self.valid_layers.items()]
188188
raise InputValueError("layer", valids)
189189

@@ -280,10 +280,10 @@ def get_features(
280280
payloads = [
281281
{
282282
"objectIds": ",".join(ids),
283-
"returnGeometry": f"{return_geom}".lower(),
284-
"outSR": f"{self.out_sr}",
283+
"returnGeometry": str(return_geom).lower(),
284+
"outSR": str(self.out_sr),
285285
"outfields": ",".join(self.outfields),
286-
"ReturnM": f"{return_m}".lower(),
286+
"ReturnM": str(return_m).lower(),
287287
"f": self.outformat,
288288
}
289289
for ids in featureids
@@ -330,7 +330,7 @@ def retry_failed_requests(self) -> list[dict[str, Any]]:
330330
features = list(tlz.concat(features))
331331
self.n_missing -= len(features)
332332
self.disable_retry = retry
333-
os.environ["HYRIVER_CACHE_DISABLE"] = f"{caching}".lower()
333+
os.environ["HYRIVER_CACHE_DISABLE"] = str(caching).lower()
334334
return features
335335

336336
def get_response(

pygeoogc/pygeoogc.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def oids_bygeom(
171171
"f": self.client.outformat,
172172
}
173173
if distance:
174-
payload.update({"distance": f"{distance}", "units": "esriSRUnit_Meter"})
174+
payload.update({"distance": str(int(distance)), "units": "esriSRUnit_Meter"})
175175

176176
if sql_clause:
177177
payload.update({"where": sql_clause})
@@ -185,7 +185,9 @@ def oids_bygeom(
185185
msg = resp["error"]["message"] if "error" in resp else "No matched records"
186186
raise ZeroMatchedError(msg) from ex
187187

188-
def oids_byfield(self, field: str, ids: str | list[str]) -> Iterator[tuple[str, ...]]:
188+
def oids_byfield(
189+
self, field: str, ids: str | int | list[str] | list[int]
190+
) -> Iterator[tuple[str, ...]]:
189191
"""Get Object IDs based on a list of field IDs.
190192
191193
Parameters
@@ -208,7 +210,7 @@ def oids_byfield(self, field: str, ids: str | list[str]) -> Iterator[tuple[str,
208210
if "string" in self.client.field_types.get(field, ""):
209211
fids = ", ".join(f"'{i}'" for i in ids_ls)
210212
else:
211-
fids = ", ".join(f"{i}" for i in ids_ls)
213+
fids = ", ".join(str(i) for i in ids_ls)
212214

213215
return self.oids_bysql(f"{field} IN ({fids})")
214216

@@ -451,7 +453,7 @@ def _get_payloads(
451453
if self.version != "1.1.1" and self.is_geographic and not always_xy:
452454
_bbox = (_bbox[1], _bbox[0], _bbox[3], _bbox[2])
453455
_payload = payload.copy()
454-
_payload["bbox"] = f'{",".join(str(round(c, 6)) for c in _bbox)}'
456+
_payload["bbox"] = ",".join(str(round(c, 6)) for c in _bbox)
455457
_payload["width"] = str(_width)
456458
_payload["height"] = str(_height)
457459
_payload["layers"] = lyr
@@ -725,7 +727,7 @@ def getfeature_byid(
725727
if "str" in valid_features[featurename]:
726728
feat_vals = ", ".join(f"'{fid}'" for fid in set(featureids))
727729
else:
728-
feat_vals = ", ".join(f"{fid}" for fid in set(featureids))
730+
feat_vals = ", ".join(str(fid) for fid in set(featureids))
729731

730732
return self.getfeature_byfilter(
731733
f"{featurename} IN ({feat_vals})", method="POST", sort_attr=featurename

0 commit comments

Comments
 (0)