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"
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"],
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"]
self.folder_stack.append(folder)
self.current_folder = folder
- elif record.has_key("Ruler"):
+ elif "Ruler" in record:
self.current_folder.append(Ruler())
else:
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):
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
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 (
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))
)
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'"
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