]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Thu, 12 Jun 2025 14:16:37 +0000 (16:16 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 12 Jun 2025 14:16:37 +0000 (16:16 +0200)
- instances.is_registered() has double-checked parameter `domain`
- added check if `column` is part of `row` "array"

fba/models/instances.py

index a7fabf0917e3838e4f119fcda4de05741f21dcf3..3ac33dc55b4548bfdf8709c45758be622a2ffaa9 100644 (file)
@@ -323,16 +323,15 @@ def set_success(domain: str) -> None:
 
 def is_registered(domain: str, skip_raise: bool = False) -> bool:
     logger.debug("domain='%s',skip_raise='%s' - CALLED!", domain, skip_raise)
-    domain_helper.raise_on(domain)
+
+    if not skip_raise:
+        domain_helper.raise_on(domain)
 
     if blacklist.is_blacklisted(domain):
         raise RuntimeError(f"domain='{domain}' is blacklisted but function has been invoked")
     elif not isinstance(skip_raise, bool):
         raise TypeError(f"skip_raise[]='{type(skip_raise)}' is not type of 'bool'")
 
-    if not skip_raise:
-        domain_helper.raise_on(domain)
-
     logger.debug("domain='%s' - CALLED!", domain)
     if not cache.key_exists("is_registered"):
         logger.debug("Cache for 'is_registered' not initialized, fetching all rows ...")
@@ -628,7 +627,10 @@ def translate_idnas(rows: list, column: str) -> None:
     logger.info("Checking/converting %d domain names ...", len(rows))
     for row in rows:
         logger.debug("row[]='%s'", type(row))
-        if row[column] in [None, ""]:
+        if column not in row:
+            logger.warning("row()=%d does not contain column='%s' - SKIPPED!", len(row), column)
+            continue
+        elif row[column] in [None, ""]:
             logger.warning("row[%s]='%s' is empty - SKIPPED!", column, row[column])
             continue
         elif not validators.domain(row[column].split("/")[0], rfc_2782=True):
@@ -638,11 +640,12 @@ def translate_idnas(rows: list, column: str) -> None:
             logger.debug("row[%s]='%s' has an unwanted TLD - SKIPPED!", column, row[column])
             continue
 
+        logger.debug("row[%s]='%s' - BEFORE!", column, row[column])
         punycode = domain_helper.encode_idna(row[column])
-        logger.debug("punycode='%s',row[%s]='%s'", punycode, column, row[column])
+        logger.debug("punycode[%s]='%s' - AFTER!", type(punycode), punycode)
 
         if punycode != row[column]:
-            logger.info("punycode row[%s]='%s' to '%s'", column, row[column], punycode)
+            logger.info("row[%s]='%s',punycode'%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)
                 delete(row[column], column)