]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Py3): Fix `.has_key()`
authorOleg Broytman <phd@phdru.name>
Fri, 10 Nov 2023 14:07:27 +0000 (17:07 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 12 Nov 2023 19:21:09 +0000 (22:21 +0300)
Robots/bkmk_rurllib.py
Storage/bkmk_stflad.py
bkmk_parser.py
check_dups.py
check_urls.py
db2bkmk.py
set-title-list.py

index 1b3182ea04de146e44fe0ac219599a30517ca34e..00a4a42b1824ce9fe37dc6cb2f9761cb65e7f3e5 100644 (file)
@@ -27,9 +27,9 @@ class RedirectException(Exception):
 class MyURLopener(urllib.URLopener):
     # Error 301 -- relocated (permanently)
     def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
-        if headers.has_key('location'):
+        if 'location' in headers:
             newurl = headers['location']
-        elif headers.has_key('uri'):
+        elif 'uri' in headers:
             newurl = headers['uri']
         else:
             newurl = "Nowhere"
index 156e956f7244fdc09809646917d12a707d6821d7..7f417b0b778aa953c8de1b8530b47b1edc7abe71 100644 (file)
@@ -112,9 +112,9 @@ Charset: %s
 
             save_level = level
             # Test here to save got_folder for next loop
-            got_folder = record.has_key("Folder")
+            got_folder = "Folder" in record
 
-            if record.has_key("URL"):
+            if "URL" in record:
                 comment = record["Comment"].replace("\\n", '\n')
                 bookmark = Bookmark(
                     record["URL"], record["AddDate"],
@@ -123,7 +123,7 @@ Charset: %s
                 bookmark.name = record["Title"]
                 self.current_folder.append(bookmark)
 
-            elif record.has_key("Folder"):
+            elif "Folder" in record:
                 folder = Folder(
                     record["AddDate"], record["Comment"],
                     record["LastModified"]
@@ -133,7 +133,7 @@ Charset: %s
                 self.folder_stack.append(folder)
                 self.current_folder = folder
 
-            elif record.has_key("Ruler"):
+            elif "Ruler" in record:
                 self.current_folder.append(Ruler())
 
             else:
index 42c0712d79b9bf2f8602d427f7a79b9f8bf0e262..0cd8f1fe711a7fd00abe8feaecffb89d79a8d303 100644 (file)
@@ -16,7 +16,7 @@ from m_lib.net.www.html import HTMLParser
 from bkmk_objects import Folder, Bookmark, Ruler
 
 
-DEBUG = os.environ.has_key("BKMK_DEBUG")
+DEBUG = "BKMK_DEBUG" in os.environ
 
 if DEBUG:
     def debug(note):
index 47a77df19381ae8a7f29a8755bf7f1e388d9304c..25c2936da800999cf5e84b9a1e2b0e6c4ec83bd6 100755 (executable)
@@ -76,7 +76,7 @@ def run():
 
         if object.isBookmark:
             href = object.href
-            if dup_dict.has_key(href):
+            if href in dup_dict:
                 report_dup(href, dup_dict[href])
             else:
                 dup_dict[href] = object_no
index 629fa86af2d01353af3f08b07463ff793eb937d1..a8f634a0ef8e53623b2b1ce95a11140eeec7accf 100755 (executable)
@@ -118,7 +118,7 @@ def run():
                 else:
                     continue
 
-            if checked.has_key(href):
+            if href in checked:
                 log("Already checked %s" % href)
                 old_object = root_folder.linear[checked[href]]
                 for attr_name in (
index c649ae91fe806ab15538012cb9ff8a985f9de255..07e2756cae6e547d40064458db8422d86df49f41 100755 (executable)
@@ -92,7 +92,7 @@ def run():
                 href = b.href
                 transl_d = self.transl_d
 
-                if transl_d.has_key(href):
+                if href in transl_d:
                     b.href = transl_d[href]
 
         root_folder.walk_depth(Transl(transl_d))
index 065407ed1449c04adf35e6154f4620dacbcee09d..4644a81a7786eef016dc5ebf1364d10d727a8bb5 100755 (executable)
@@ -58,7 +58,7 @@ def run():
             )
 
         else:  # We've got 3 lines - add new entry to the mapping
-            if titles_dict.has_key(URL):
+            if URL in titles_dict:
                 if title != titles_dict[URL]:
                     raise ValueError(
                         "titles are not identical for URL `%s': `%s' != `%s'"
@@ -96,7 +96,7 @@ def run():
 
         if object.isBookmark:
             URL = object.href
-            if titles_dict.has_key(URL):
+            if URL in titles_dict:
                 name = titles_dict[URL]
                 if object.name != name:
                     object.name = name