# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import logging
+
+logging.basicConfig(level=logging.INFO)
+logger = logging.getLogger(__name__)
+
def has_key(lists: list, key: str, value: any) -> bool:
- # DEBUG: print(f"DEBUG: lists()={len(lists)},key='{key}',value[]='{type(value)}' - CALLED!")
+ logger.debug("lists()=%d,key='%s',value[]='%s' - CALLED!", len(lists), key, type(value))
+
if not isinstance(lists, list):
- raise ValueError(f"Parameter lists[]='{type(lists)}' is not 'list'")
+ raise ValueError(f"Parameter lists[]='{type(lists)}' is not of type 'list'")
elif not isinstance(key, str):
- raise ValueError(f"Parameter key[]='{type(key)}' is not 'str'")
+ raise ValueError(f"Parameter key[]='{type(key)}' is not of type 'str'")
elif key == "":
raise ValueError("Parameter 'key' is empty")
has = False
- # DEBUG: print(f"DEBUG: Checking lists()={len(lists)} ...")
+ logger.debug("Checking lists()=%d ...", len(lists))
for row in lists:
- # DEBUG: print(f"DEBUG: row['{type(row)}']={row}")
+ logger.debug("row[%s]='%s", type(row), row)
+
if not isinstance(row, dict):
- raise ValueError(f"row[]='{type(row)}' is not 'dict'")
+ raise ValueError(f"row[]='{type(row)}' is not of type 'dict'")
elif not key in row:
raise KeyError(f"Cannot find key='{key}'")
elif row[key] == value:
+ logger.debug("row[%s][]='%s' matches value[]='%s'", key, type(row[key]), type(value))
has = True
break
- # DEBUG: print(f"DEBUG: has={has} - EXIT!")
+ logger.debug("has='%s' - EXIT!", has)
return has