From: Oleg Broytman Date: Mon, 4 Sep 2023 16:52:48 +0000 (+0300) Subject: Style: Fix flake8 E261 at least two spaces before inline comment X-Git-Tag: 5.0.0~87 X-Git-Url: https://git.phdru.name/?p=bookmarks_db.git;a=commitdiff_plain;h=c2ea4e82718b903aa123dd77490f36657383b0ca Style: Fix flake8 E261 at least two spaces before inline comment --- diff --git a/Robots/bkmk_rforking.py b/Robots/bkmk_rforking.py index 2aa49e0..6250af9 100644 --- a/Robots/bkmk_rforking.py +++ b/Robots/bkmk_rforking.py @@ -47,7 +47,7 @@ def restart_subp(log): _set_subproc = True class robot_forking(Robot): - subproc = 'urllib2' # Default subprocess + subproc = 'urllib2' # Default subprocess def check_url(self, bookmark): global _set_subproc @@ -66,14 +66,14 @@ class robot_forking(Robot): os.environ['BKMK_ROBOT'] = subproc if not check_subp: - restart_subp(self.log) # Not restart, just start afresh + restart_subp(self.log) # Not restart, just start afresh try: save_parent = bookmark.parent bookmark.parent = None subp_pipe.write_record(pickle.dumps(bookmark)) - if check_subp.waitForPendingChar(60): # wait a minute + if check_subp.waitForPendingChar(60): # wait a minute new_b = pickle.loads(subp_pipe.read_record()) for attr in ( "error", "no_error", @@ -103,4 +103,4 @@ class robot_forking(Robot): return 1 def stop(self): - stop_subp(None) # Stop subprocess; do not log restarting + stop_subp(None) # Stop subprocess; do not log restarting diff --git a/Robots/bkmk_rforking_sub.py b/Robots/bkmk_rforking_sub.py index 9b25b5b..cb3ca5c 100755 --- a/Robots/bkmk_rforking_sub.py +++ b/Robots/bkmk_rforking_sub.py @@ -6,7 +6,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 1999-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 1999-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = [] @@ -15,7 +15,7 @@ __all__ = [] import sys, os lib_dir = os.path.normpath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir)) -sys.path.append(lib_dir) # for bkmk_objects.py +sys.path.append(lib_dir) # for bkmk_objects.py try: import cPickle diff --git a/Robots/bkmk_robot_base.py b/Robots/bkmk_robot_base.py index 395d4f8..9c9d8c5 100644 --- a/Robots/bkmk_robot_base.py +++ b/Robots/bkmk_robot_base.py @@ -106,7 +106,7 @@ class robot_base(Robot): bookmark.last_modified = last_modified md5 = md5wrapper() - if url_type == "ftp": # Pass welcome message through MD5 + if url_type == "ftp": # Pass welcome message through MD5 md5.update(self.get_ftp_welcome()) md5.update(content) @@ -200,7 +200,7 @@ class robot_base(Robot): try: timeout = int(refresh.split(';')[0]) except ValueError: - pass # float timeout + pass # float timeout self.set_redirect(bookmark, "html", "%s (%s sec)" % (url, timeout)) except KeyError as key: diff --git a/Robots/bkmk_rurllib.py b/Robots/bkmk_rurllib.py index 0188963..2c32291 100644 --- a/Robots/bkmk_rurllib.py +++ b/Robots/bkmk_rurllib.py @@ -91,7 +91,7 @@ class robot_urllib(robot_base): fname, headers = urllib.urlretrieve(url) finally: if accept_charset and bookmark.charset: - del urllib._urlopener.addheaders[-1] # Remove Accept-Charset + del urllib._urlopener.addheaders[-1] # Remove Accept-Charset infile = open(fname, 'rb') content = infile.read() diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 2322291..8965bbe 100644 --- a/Storage/bkmk_stflad.py +++ b/Storage/bkmk_stflad.py @@ -93,7 +93,7 @@ Charset: %s root_folder.comment = string.join(header[7:], '')[4:] save_level = 0 - got_folder = 1 # Start as if we already have one folder + got_folder = 1 # Start as if we already have one folder for record in bookmarks_db: level = int(record["Level"]) @@ -109,7 +109,7 @@ Charset: %s raise ValueError("new level (%d) too big; must be %d - %d" % (level, save_level-1, save_level+1)) save_level = level - got_folder = record.has_key("Folder") # Test here to save got_folder for next loop + got_folder = record.has_key("Folder") # Test here to save got_folder for next loop if record.has_key("URL"): comment = record["Comment"].replace("\\n", '\n') diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index ad84a53..64542bb 100644 --- a/Writers/bkmk_wflad.py +++ b/Writers/bkmk_wflad.py @@ -17,7 +17,7 @@ from bkmk_objects import Writer def strftime(s): try: return time.strftime("%a %d %b %Y %T", time.localtime(int(s))) - except (TypeError, ValueError): # s is None or is already formatted + except (TypeError, ValueError): # s is None or is already formatted return s diff --git a/bkmk-add.py b/bkmk-add.py index df12452..01ed29f 100755 --- a/bkmk-add.py +++ b/bkmk-add.py @@ -6,7 +6,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2002-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2002-2023 PhiloSoft Design" __license__ = "GNU GPL" import sys, os, time @@ -57,8 +57,8 @@ def run(): global robot robot = robot(None) - if robot.check_url(bookmark): # get real title and last modified date - if title: # forced title + if robot.check_url(bookmark): # get real title and last modified date + if title: # forced title bookmark.name = title elif hasattr(bookmark, "real_title"): bookmark.name = bookmark.real_title diff --git a/bkmk2db.py b/bkmk2db.py index 721371b..0beea07 100755 --- a/bkmk2db.py +++ b/bkmk2db.py @@ -40,7 +40,7 @@ def run(): filename = args[0] else: - filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX + filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX if report_stats: @@ -73,7 +73,7 @@ def run(): if os.name == 'dos' or os.name == 'nt': dos_add = 1 else: - dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct + dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct infile = open(filename, 'r') diff --git a/bkmk_objects.py b/bkmk_objects.py index b1d2073..f313bd3 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -29,7 +29,7 @@ class Folder(list): self.last_modified = last_modified def walk_depth(self, walker, level=0): - if hasattr(self, "header"): # root folder + if hasattr(self, "header"): # root folder prune = 0 walker.root_folder(self) else: @@ -140,7 +140,7 @@ class Robot(object): self.log = log def stop(self): - pass # Nothing to do on cleanup + pass # Nothing to do on cleanup # Helper class to make inverese links (nodes linked to their parent) @@ -150,7 +150,7 @@ class InverseLinker(Walker): def start_folder(self, f, level): f.parent = self.parent_stack[-1] - self.parent_stack.append(f) # Push the folder onto the stack of parents + self.parent_stack.append(f) # Push the folder onto the stack of parents def end_folder(self, f, level): del self.parent_stack[-1] # Pop off the stack diff --git a/bkmk_parser.py b/bkmk_parser.py index 329b4e5..00cfcd4 100644 --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -110,7 +110,7 @@ class BkmkParser(HTMLParser): folder = Folder(add_date, last_modified=last_modified) self.current_object = folder self.current_folder.append(folder) - self.folder_stack.append(folder) # push new folder + self.folder_stack.append(folder) # push new folder self.current_folder = folder self.objects += 1 @@ -186,7 +186,7 @@ class BkmkParser(HTMLParser): debug("End folder") debug("Folder stack: %s" % dump_names(self.folder_stack)) if self.folder_stack: - del self.folder_stack[-1] # pop last folder + del self.folder_stack[-1] # pop last folder if self.folder_stack: self.current_folder = self.folder_stack[-1] else: diff --git a/check_title.py b/check_title.py index ffab6fa..775679b 100755 --- a/check_title.py +++ b/check_title.py @@ -10,7 +10,7 @@ from bkmk_objects import make_linear, quote_title, unquote_title __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2002-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2002-2023 PhiloSoft Design" __license__ = "GNU GPL" @@ -29,7 +29,7 @@ def run(): pass if report_stats: - print("Broytman check_title, Copyright (C) 2002-2017 PhiloSoft Design") + print("Broytman check_title, Copyright (C) 2002-2023 PhiloSoft Design") if args: sys.stderr.write("check_title: too many arguments\n") @@ -56,7 +56,7 @@ def run(): if object.isBookmark: if hasattr(object, "moved") or hasattr(object, "error") \ - or object.href.startswith('place:'): # Firefox SmartBookmarks + or object.href.startswith('place:'): # Firefox SmartBookmarks continue if hasattr(object, "real_title") and (object.real_title is not None): diff --git a/check_urls.py b/check_urls.py index 000141f..8eba42c 100755 --- a/check_urls.py +++ b/check_urls.py @@ -107,8 +107,8 @@ def run(): if object.isBookmark: href = object.href - if (href.startswith('place:') # Firefox SmartBookmarks - or '%s' in href): # Bookmark with keyword + if (href.startswith('place:') # Firefox SmartBookmarks + or '%s' in href): # Bookmark with keyword log("Skipped %s" % href) continue @@ -138,7 +138,7 @@ def run(): try: size = size + int(object.size) except (AttributeError, TypeError, ValueError): - pass # Some object does not have a size :( + pass # Some object does not have a size :( else: log("Interrupted by user (^C)") break diff --git a/db2bkmk.py b/db2bkmk.py index 78618e7..da9bf52 100755 --- a/db2bkmk.py +++ b/db2bkmk.py @@ -22,7 +22,7 @@ def run(): output_filename = writer.filename transl = 0 - transl_name = "" # dictionary translation; default is no translation + transl_name = "" # dictionary translation; default is no translation for _opt, _arg in optlist: if _opt == '-s': @@ -79,7 +79,7 @@ def run(): else: raise ValueError("transl (%d) must be 1 or 2" % transl) - del transl_db # Save few bytes of memory + del transl_db # Save few bytes of memory from bkmk_objects import Walker class Transl(Walker): diff --git a/parse_html/bkmk_parse_html.py b/parse_html/bkmk_parse_html.py index af9395b..5da37a9 100644 --- a/parse_html/bkmk_parse_html.py +++ b/parse_html/bkmk_parse_html.py @@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 1997-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 1997-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = ['parse_html', 'parse_filename', 'universal_charset'] @@ -14,7 +14,7 @@ __all__ = ['parse_html', 'parse_filename', 'universal_charset'] import codecs universal_charset = "utf-8" -DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic +DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic parsers = [] @@ -86,7 +86,7 @@ def recode_entities(title, charset): try: part = unichr(int(part[2:-1])).encode(charset) except UnicodeEncodeError: - pass # Leave the entity as is + pass # Leave the entity as is output.append(part) return ''.join(output) @@ -101,7 +101,7 @@ def parse_html(html_text, charset=None, log=None): if charset: try: - codecs.lookup(charset) # In case of unknown charset... + codecs.lookup(charset) # In case of unknown charset... except (ValueError, LookupError): charset = None # ...try charset from HTML diff --git a/parse_html/bkmk_ph_beautifulsoup.py b/parse_html/bkmk_ph_beautifulsoup.py index 99cff4f..1479f03 100644 --- a/parse_html/bkmk_ph_beautifulsoup.py +++ b/parse_html/bkmk_ph_beautifulsoup.py @@ -16,7 +16,7 @@ from sgmllib import SGMLParser, SGMLParseError from BeautifulSoup import BeautifulSoup, CData from .bkmk_ph_util import HTMLParser -DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic +DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic # http://groups.google.com/group/beautifulsoup/browse_thread/thread/69093cb0d3a3cf63 class BadDeclParser(BeautifulSoup): @@ -62,7 +62,7 @@ def parse_html(html_text, charset=None, log=None): return None _charset = root.originalEncoding - if _charset in ("ISO-8859-2", "windows-1252", "MacCyrillic"): # Replace default + if _charset in ("ISO-8859-2", "windows-1252", "MacCyrillic"): # Replace default _charset = DEFAULT_CHARSET root = _parse_html(html_text, _charset) if root is None: @@ -74,7 +74,7 @@ def parse_html(html_text, charset=None, log=None): head = html.head if head is None: - head = html # Some sites put TITLE in HTML without HEAD + head = html # Some sites put TITLE in HTML without HEAD title = head.title if (title is None) and (html is not head): @@ -104,7 +104,7 @@ def parse_html(html_text, charset=None, log=None): __charset = meta_content.lower().split('charset=')[1].split(';')[0] else: __charset = False - except IndexError: # No charset in the META Content-Type + except IndexError: # No charset in the META Content-Type meta_charset = False else: meta_charset = _charset == __charset diff --git a/parse_html/bkmk_ph_beautifulsoup4.py b/parse_html/bkmk_ph_beautifulsoup4.py index 10e06a9..b7f60ff 100644 --- a/parse_html/bkmk_ph_beautifulsoup4.py +++ b/parse_html/bkmk_ph_beautifulsoup4.py @@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2017-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = ['parse_html'] @@ -16,7 +16,7 @@ from bs4 import BeautifulSoup from .bkmk_ph_util import HTMLParser universal_charset = "utf-8" -DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic +DEFAULT_CHARSET = "cp1251" # Stupid default for Russian Cyrillic def _parse_html(html_text, charset): try: @@ -36,7 +36,7 @@ def parse_html(html_text, charset=None, log=None): head = html.head if head is None: - head = html # Some sites put TITLE in HTML without HEAD + head = html # Some sites put TITLE in HTML without HEAD title = head.title if (title is None) and (html is not head): @@ -66,7 +66,7 @@ def parse_html(html_text, charset=None, log=None): __charset = meta_content.lower().split('charset=')[1].split(';')[0] else: __charset = False - except IndexError: # No charset in the META Content-Type + except IndexError: # No charset in the META Content-Type meta_charset = False else: meta_charset = _charset = __charset diff --git a/parse_html/bkmk_ph_htmlparser.py b/parse_html/bkmk_ph_htmlparser.py index 70cba32..05ad658 100644 --- a/parse_html/bkmk_ph_htmlparser.py +++ b/parse_html/bkmk_ph_htmlparser.py @@ -5,7 +5,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 1997-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 1997-2023 PhiloSoft Design" __license__ = "GNU GPL" __all__ = ['parse_html'] @@ -62,7 +62,7 @@ class HTMLParser(_HTMLParser): self.accumulator = '' def end_title(self): - if not self.title: # use only the first title + if not self.title: # use only the first title self.title = self.accumulator def do_link(self, attrs): diff --git a/set-title-list.py b/set-title-list.py index 6a49742..be96b53 100755 --- a/set-title-list.py +++ b/set-title-list.py @@ -9,7 +9,7 @@ import sys __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2003-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2003-2023 PhiloSoft Design" __license__ = "GNU GPL" @@ -28,7 +28,7 @@ def run(): pass if report_stats: - print("Broytman set-title-list, Copyright (C) 2003-2017 PhiloSoft Design") + print("Broytman set-title-list, Copyright (C) 2003-2023 PhiloSoft Design") if len(args) != 1: sys.stderr.write("Usage: set-title-list [-s] title_list_file\n") @@ -42,17 +42,17 @@ def run(): title_list_file = open(args[0], 'r') for line in title_list_file: - line = line[:-1] # strip trailing newline + line = line[:-1] # strip trailing newline if URL is None: URL = line elif title is None: title = line - elif line: # the third line in every 3 lines must be empty + elif line: # the third line in every 3 lines must be empty raise ValueError("line is not empty for URL `%s', title `%s': line `%s'" % (URL, title, line)) - else: # We've got 3 lines - add new entry to the mapping + else: # We've got 3 lines - add new entry to the mapping if titles_dict.has_key(URL): if title != titles_dict[URL]: raise ValueError("titles are not identical for URL `%s': `%s' != `%s'" % (URL, title, titles_dict[URL])) diff --git a/sort_db.py b/sort_db.py index 03026e6..4418973 100755 --- a/sort_db.py +++ b/sort_db.py @@ -13,7 +13,7 @@ This file is a part of Bookmarks database and Internet robot. """ __author__ = "Oleg Broytman " -__copyright__ = "Copyright (C) 2000-2017 PhiloSoft Design" +__copyright__ = "Copyright (C) 2000-2023 PhiloSoft Design" __license__ = "GNU GPL" import sys @@ -89,7 +89,7 @@ def run(): make_linear(root_folder) linear = root_folder.linear - del linear[0] # exclude root folder from sorting + del linear[0] # exclude root folder from sorting by = SortBy(sort_by) linear.sort(by)