logger.debug("EXIT!")
def valid(value: str, column: str) -> bool:
- logger.debug("value='%s' - CALLED!", value)
+ logger.debug("value='%s',column='%s' - CALLED!", value, column)
+
if not isinstance(value, str):
raise ValueError(f"Parameter value[]='{type(value)}' is not of type 'str'")
elif value == "":
logger.debug("is_valid='%s' - EXIT!", is_valid)
return is_valid
-def delete(domain: str) -> None:
- logger.debug("domain='%s' - CALLED!", domain)
- domain_helper.raise_on(domain)
+def delete(domain: str, column: str = "domain") -> None:
+ logger.debug("domain='%s, column='%s'' - CALLED!", domain, column)
+
+ if not isinstance(domain, str):
+ raise ValueError(f"Parameter domain[]='{type(domain)}' is not of type 'str'")
+ elif domain == "":
+ raise ValueError("Parameter 'domain' is empty")
+ elif not isinstance(column, str):
+ raise ValueError(f"Parameter column[]='{type(column)}' is not of type 'str'")
+ elif column == "":
+ raise ValueError("Parameter 'column' is empty")
+ elif column in ["domain", "origin"]:
+ domain_helper.raise_on(domain)
- database.cursor.execute(f"DELETE FROM instances WHERE domain = ? LIMIT 1", [domain])
+ database.cursor.execute(f"DELETE FROM instances WHERE {column} = ? LIMIT 1", [domain])
logger.debug("Invoking commit() ...")
database.connection.commit()
logger.debug("EXIT!")
def translate_idnas(rows: list, column: str) -> None:
- logger.debug("rows[]='%s' - CALLED!", type(rows))
+ logger.debug("rows[]='%s',column='%s' - CALLED!", type(rows), column)
if not isinstance(rows, list):
raise ValueError("rows[]='{type(rows)}' is not of type 'list'")
logger.info("punycode row[%s]='%s' to '%s'", column, row[column], punycode)
if is_registered(punycode, True):
logger.warning("Deleting row[%s]='%s' as punycode='%s' already exist", column, row[column], punycode)
- database.cursor.execute(f"DELETE FROM instances WHERE {column} = ? LIMIT 1", [row[column]])
+ delete(row[column], column)
else:
logger.debug("Updating row[%s]='%s' to punycode='%s' ...", column, row[column], punycode)
database.cursor.execute(f"UPDATE instances SET {column} = ? WHERE {column} = ? LIMIT 1", [punycode, row[column]])