From aaa16e28a73fcc01ff9fa5709c72970bb50629d7 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 10 Nov 2023 17:07:27 +0300 Subject: [PATCH] Fix(Py3): Fix `.has_key()` --- Robots/bkmk_rurllib.py | 4 ++-- Storage/bkmk_stflad.py | 8 ++++---- bkmk_parser.py | 2 +- check_dups.py | 2 +- check_urls.py | 2 +- db2bkmk.py | 2 +- set-title-list.py | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index 1b3182e..00a4a42 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -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" diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 156e956..7f417b0 100644 --- a/Storage/bkmk_stflad.py +++ b/Storage/bkmk_stflad.py @@ -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: diff --git a/bkmk_parser.py b/bkmk_parser.py index 42c0712..0cd8f1f 100644 --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -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): diff --git a/check_dups.py b/check_dups.py index 47a77df..25c2936 100755 --- a/check_dups.py +++ b/check_dups.py @@ -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 diff --git a/check_urls.py b/check_urls.py index 629fa86..a8f634a 100755 --- a/check_urls.py +++ b/check_urls.py @@ -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 ( diff --git a/db2bkmk.py b/db2bkmk.py index c649ae9..07e2756 100755 --- a/db2bkmk.py +++ b/db2bkmk.py @@ -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)) diff --git a/set-title-list.py b/set-title-list.py index 065407e..4644a81 100755 --- a/set-title-list.py +++ b/set-title-list.py @@ -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 -- 2.39.5