From: Roland Häder Date: Mon, 24 Jul 2023 09:48:58 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7ea4c3e9256c3cc7261238f5c95758cdd3a5bbe5;p=fba.git Continued: - let's not iterate directly (always possible, of course) on the CSV reader object, but generate a list from its rows - this also allow us to check if 'reader' is not NoneType --- diff --git a/fba/commands.py b/fba/commands.py index 08b9dda..1ef5ab6 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -1614,7 +1614,14 @@ def fetch_fedilist(args: argparse.Namespace) -> int: reader = csv.DictReader(response.content.decode("utf-8").splitlines(), dialect="unix") logger.debug("reader[]='%s'", type(reader)) - for row in reader: + if reader is None: + logger.warning("Failed parsing response.content()=%d as CSV content", len(response.content)) + return 2 + + rows = list(reader) + + logger.info("Checking %d rows ...", len(rows)) + for row in rows: logger.debug("row[]='%s'", type(row)) if "hostname" not in row: logger.warning("row()=%d has no element 'hostname' - SKIPPED!", len(row))