Skip to content

Commit

Permalink
Rename vars
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarans committed Mar 5, 2025
1 parent 1f91d62 commit ec53f46
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
18 changes: 9 additions & 9 deletions src/hdx/resource/changedetection/head_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def process(self) -> None:
what_changed = []
why_get = []
resource = self._resources[resource_id]
http_size, http_last_modified, etag, status = result
size, last_modified, etag, status = result
if status != HTTPStatus.OK:
status_str = status_lookup[status]
if status in (
Expand Down Expand Up @@ -60,8 +60,8 @@ def process(self) -> None:
if resource[5]:
what_changed.append(status)

if http_size:
if http_size != resource[3]:
if size:
if size != resource[3]:
status = "size"
what_changed.append(status)
if etag_unchanged:
Expand All @@ -71,16 +71,16 @@ def process(self) -> None:
if resource[3]:
what_changed.append("no size")

if http_last_modified:
http_last_modified = parse_date(http_last_modified)
if last_modified:
last_modified = parse_date(last_modified)
resource_date = resource[4]
if not resource_date or http_last_modified > resource_date:
if not resource_date or last_modified > resource_date:
status = "modified"
what_changed.append(status)
if etag_unchanged:
why_get.append(status)
get_resource = True
elif http_last_modified < resource_date:
elif last_modified < resource_date:
what_changed.append("modified: http<resource")
else:
if resource[4]:
Expand All @@ -96,8 +96,8 @@ def process(self) -> None:
dict_of_lists_add(self._get_output, why_get, resource_id)
if not etag_unchanged:
self._resources_to_update[resource_id] = (
http_size,
http_last_modified,
size,
last_modified,
etag,
)

Expand Down
10 changes: 5 additions & 5 deletions src/hdx/resource/changedetection/head_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ async def fetch(
status = response.status
if status == 200:
headers = response.headers
http_size = headers.get("Content-Length")
if http_size:
http_size = int(http_size)
http_last_modified = headers.get("Last-Modified")
size = headers.get("Content-Length")
if size:
size = int(size)
last_modified = headers.get("Last-Modified")
etag = headers.get("Etag")
return resource_id, http_size, http_last_modified, etag, 200
return resource_id, size, last_modified, etag, 200
else:
exception = ClientResponseError(
code=status,
Expand Down
28 changes: 14 additions & 14 deletions src/hdx/resource/changedetection/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def process(self) -> None:
for resource_id, result in self._results.items():
what_changed = []
resource = self._resources[resource_id]
http_size, http_last_modified, etag, status = result
size, last_modified, etag, status = result
if status != 0 and status != HTTPStatus.OK:
status_str = status_lookup[status]
if status < 0:
Expand All @@ -55,8 +55,8 @@ def process(self) -> None:
status = f"no {etag_str}"
what_changed.append(status)

if http_size:
if http_size != resource[3]:
if size:
if size != resource[3]:
status = "size"
what_changed.append(status)
update = True
Expand All @@ -65,34 +65,34 @@ def process(self) -> None:
what_changed.append("no size")

resource_date = resource[4]
if http_last_modified:
http_last_modified = parse_date(http_last_modified)
if not resource_date or http_last_modified > resource_date:
if last_modified:
last_modified = parse_date(last_modified)
if not resource_date or last_modified > resource_date:
status = "modified"
what_changed.append(status)
update = True
elif http_last_modified < resource_date:
elif last_modified < resource_date:
what_changed.append("modified: http<resource")
else:
if resource_date:
what_changed.append("no modified")

if update:
if not http_last_modified or (
resource_date and http_last_modified <= resource_date
if not last_modified or (
resource_date and last_modified <= resource_date
):
if resource_date:
if self._today > resource_date:
http_last_modified = self._today
last_modified = self._today
what_changed.append("today")
else:
http_last_modified = resource_date
last_modified = resource_date
else:
http_last_modified = self._today
last_modified = self._today
what_changed.append("today")
self._resources_to_update[resource_id] = (
http_size,
http_last_modified,
size,
last_modified,
etag,
)

Expand Down
14 changes: 7 additions & 7 deletions src/hdx/resource/changedetection/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ async def fetch(
http_size = headers.get("Content-Length")
if http_size:
http_size = int(http_size)
http_last_modified = headers.get("Last-Modified")
last_modified = headers.get("Last-Modified")
etag = headers.get("Etag")
if etag:
return resource_id, http_size, http_last_modified, etag, 200
return resource_id, http_size, last_modified, etag, 200
if http_size and int(http_size) > 419430400:
return resource_id, http_size, http_last_modified, None, -99
return resource_id, http_size, last_modified, None, -99

mimetype = headers.get("Content-Type")
iterator = response.content.iter_any()
Expand Down Expand Up @@ -159,7 +159,7 @@ async def fetch(
return (
resource_id,
size,
http_last_modified,
last_modified,
hash,
-1,
)
Expand All @@ -168,11 +168,11 @@ async def fetch(
if not any(
signature[: len(x)] == x for x in expected_signatures
):
return resource_id, size, http_last_modified, hash, -2
return resource_id, size, last_modified, hash, -2
if size != http_size:
return resource_id, size, http_last_modified, hash, -3
return resource_id, size, last_modified, hash, -3

return resource_id, size, http_last_modified, hash, 0
return resource_id, size, last_modified, hash, 0

async def process(
self,
Expand Down

0 comments on commit ec53f46

Please sign in to comment.