From c9cfb54ef36e77aee7187e4533f063d407073ad8 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 4 Jan 2011 19:31:21 +0000 Subject: [PATCH] Added __all__. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@318 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/bkmk_rforking.py | 14 ++++++++------ Robots/bkmk_rforking_sub.py | 3 +++ Robots/bkmk_rsimple.py | 4 +++- Robots/bkmk_rsimple_tos.py | 3 +++ Storage/bkmk_stflad.py | 6 +++--- Storage/bkmk_stjson.py | 4 +++- Storage/bkmk_stpickle.py | 5 +++-- Writers/bkmk_wflad.py | 5 +++-- Writers/bkmk_wflad_err.py | 3 +++ Writers/bkmk_whtml.py | 3 +++ Writers/bkmk_wtxt.py | 5 ++++- bkmk_objects.py | 6 ++++++ bkmk_parser.py | 18 +++--------------- parse_html/__init__.py | 3 +++ parse_html/beautifulsoup.py | 3 +++ parse_html/etreetidy.py | 3 +++ parse_html/html5.py | 3 +++ parse_html/htmlparser.py | 6 +++--- parse_html/lxml.py | 3 +++ parse_html/util.py | 3 +++ robots.py | 3 +++ storage.py | 3 +++ writers.py | 3 +++ 23 files changed, 78 insertions(+), 34 deletions(-) diff --git a/Robots/bkmk_rforking.py b/Robots/bkmk_rforking.py index 843a0d2..d33c38d 100644 --- a/Robots/bkmk_rforking.py +++ b/Robots/bkmk_rforking.py @@ -10,14 +10,19 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['robot_forking'] + + +import sys, os + try: - import cPickle - pickle = cPickle + import cPickle as pickle except ImportError: import pickle -import sys, os from subproc import Subprocess, RecordFile +from bkmk_objects import Robot + # This is to catch 'close failed: [Errno 9] Bad file descriptor' message # from os.close() in Subprocess.die() and errors from from the subprocess. @@ -42,8 +47,6 @@ def restart_subp(log): subp_pipe = RecordFile(check_subp) -from bkmk_objects import Robot - class robot_forking(Robot): def check_url(self, bookmark): if not check_subp: @@ -81,6 +84,5 @@ class robot_forking(Robot): # Tested return 1 - def stop(self): stop_subp(None) # Stop subprocess; do not log restarting diff --git a/Robots/bkmk_rforking_sub.py b/Robots/bkmk_rforking_sub.py index 36338f4..e392080 100755 --- a/Robots/bkmk_rforking_sub.py +++ b/Robots/bkmk_rforking_sub.py @@ -11,6 +11,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1999-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = [] + + import sys, os lib_dir = os.path.normpath(os.path.dirname(sys.argv[0]) + os.sep + os.pardir) diff --git a/Robots/bkmk_rsimple.py b/Robots/bkmk_rsimple.py index 8bfa429..871082f 100644 --- a/Robots/bkmk_rsimple.py +++ b/Robots/bkmk_rsimple.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['robot_simple', 'get_error'] + + import sys, os import time, urllib from base64 import b64encode @@ -285,7 +288,6 @@ class robot_simple(Robot): # Tested return 1 - def finish_check_url(self, bookmark, fname=None): # Calculate these attributes even in case of an error if fname and os.path.exists(fname): diff --git a/Robots/bkmk_rsimple_tos.py b/Robots/bkmk_rsimple_tos.py index 25fa88f..df1827c 100644 --- a/Robots/bkmk_rsimple_tos.py +++ b/Robots/bkmk_rsimple_tos.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['robot_simple_tos'] + + import socket socket.setdefaulttimeout(900) diff --git a/Storage/bkmk_stflad.py b/Storage/bkmk_stflad.py index 86c42b3..ddcdc63 100644 --- a/Storage/bkmk_stflad.py +++ b/Storage/bkmk_stflad.py @@ -12,6 +12,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['storage_flad'] + + import string from m_lib.flad import fladm from bkmk_objects import Folder, Bookmark, Ruler, Walker @@ -58,17 +61,14 @@ Charset: %s b.keyword, b.comment.replace('\n', "\\n"), b.icon_href or '', b.icon or '', b.charset or '')) - def ruler(self, r, level): self.outfile.write("\nLevel: %s\nRuler: YES\n" % (level+1)) - def store(self, root_folder): self.outfile = open(self.filename, 'w') root_folder.walk_depth(self) self.outfile.close() - def unindent(self, old_level, new_level): while old_level > new_level: old_level = old_level - 1 diff --git a/Storage/bkmk_stjson.py b/Storage/bkmk_stjson.py index 437ca6d..88429b6 100644 --- a/Storage/bkmk_stjson.py +++ b/Storage/bkmk_stjson.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['storage_json'] + + try: import json except ImportError: @@ -104,7 +107,6 @@ class storage_json(Walker): outfile.close() del self.dict - def load(self): infile = open(self.filename, 'rb') bkmk_s = infile.read() diff --git a/Storage/bkmk_stpickle.py b/Storage/bkmk_stpickle.py index 702cea5..c957bfe 100644 --- a/Storage/bkmk_stpickle.py +++ b/Storage/bkmk_stpickle.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['storage_pickle'] + + try: import cPickle pickle = cPickle @@ -21,13 +24,11 @@ except ImportError: class storage_pickle: filename = "bookmarks_db.pickle" - def store(self, root_folder): outfile = open(self.filename, 'wb') pickle.dump(root_folder, outfile, 1) outfile.close() - def load(self): infile = open(self.filename, 'rb') root_folder = pickle.load(infile) diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index d5cb7e0..a4e88fc 100644 --- a/Writers/bkmk_wflad.py +++ b/Writers/bkmk_wflad.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['writer_flad'] + + import time from bkmk_objects import Writer @@ -28,7 +31,6 @@ class writer_flad(Writer): Writer.__init__(self, outfile, prune) self.first_object = 1 - def start_folder(self, f, level): self.outfile.write(""" Level: %d @@ -38,7 +40,6 @@ Comment: %s LastModified: %s """ % (level, f.name, strftime(f.add_date), f.comment, f.last_modified or '')) - def bookmark(self, b, level): self.outfile.write(""" Level: %d diff --git a/Writers/bkmk_wflad_err.py b/Writers/bkmk_wflad_err.py index b7b2977..5370d1b 100644 --- a/Writers/bkmk_wflad_err.py +++ b/Writers/bkmk_wflad_err.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['writer_flad_err'] + + import time from bkmk_wflad import writer_flad diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index 00591b0..97a17e4 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['writer_html'] + + from bkmk_objects import Writer, BKMK_FORMAT, quote_title diff --git a/Writers/bkmk_wtxt.py b/Writers/bkmk_wtxt.py index 628d9b2..d39c63b 100644 --- a/Writers/bkmk_wtxt.py +++ b/Writers/bkmk_wtxt.py @@ -10,11 +10,14 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" -ind_s = " "*4 +__all__ = ['writer_txt'] from bkmk_objects import Writer +ind_s = " "*4 + + class writer_txt(Writer): filename = "dump.txt" diff --git a/bkmk_objects.py b/bkmk_objects.py index d15c38e..27e621b 100644 --- a/bkmk_objects.py +++ b/bkmk_objects.py @@ -10,6 +10,12 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2000-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['Folder', 'Bookmark', 'Ruler', 'Walker', 'Writer', 'Robot', + 'InverseLinker', 'Linear', 'make_linear', 'make_tree', 'break_tree', + 'quote_title', 'unquote_title', +] + + import os, cgi BKMK_FORMAT = os.environ.get("BKMK_FORMAT", "MOZILLA") diff --git a/bkmk_parser.py b/bkmk_parser.py index 2ec412c..e3b3db0 100644 --- a/bkmk_parser.py +++ b/bkmk_parser.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['BkmkParser'] + + import sys, os from m_lib.net.www.html import HTMLParser from bkmk_objects import Folder, Bookmark, Ruler @@ -46,14 +49,12 @@ class BkmkParser(HTMLParser): self.charset = "" self.recode = None - def handle_data(self, data): if data: if DEFAULT_CHARSET: data = unicode(data, self.charset, "replace").encode(DEFAULT_CHARSET, "xmlcharrefreplace") self.accumulator += data - # Mozilla - get charset def do_meta(self, attrs): http_equiv = "" @@ -83,7 +84,6 @@ class BkmkParser(HTMLParser): else: DEFAULT_CHARSET = locale.getpreferredencoding() - def start_title(self, attrs): if DEFAULT_CHARSET: self.accumulator += '\n' % DEFAULT_CHARSET @@ -92,7 +92,6 @@ class BkmkParser(HTMLParser): def end_title(self): self.accumulator += "" - # Start root folder def start_h1(self, attrs): root_folder = Folder() @@ -111,7 +110,6 @@ class BkmkParser(HTMLParser): debug("Root folder name: `%s'" % accumulator) self.root_folder.name = accumulator - # Start a folder def start_h3(self, attrs): last_modified = None @@ -137,7 +135,6 @@ class BkmkParser(HTMLParser): debug("Folder name: `%s'" % accumulator) self.current_folder.name = accumulator - # Start a bookmark def start_a(self, attrs): add_date = None @@ -180,7 +177,6 @@ class BkmkParser(HTMLParser): bookmark = self.current_folder[-1] bookmark.name = accumulator - def flush(self): accumulator = self.accumulator @@ -192,13 +188,11 @@ class BkmkParser(HTMLParser): current_object.comment += accumulator.strip() debug("Comment: `%s'" % current_object.comment) - def start_dl(self, attrs): self.flush() do_dt = start_dl - # End of folder def end_dl(self): self.flush() @@ -214,19 +208,16 @@ class BkmkParser(HTMLParser): debug("FOLDER STACK is EMPTY!!! (2)") self.current_object = None - def close(self): HTMLParser.close(self) if self.folder_stack: raise ValueError, "wrong folder stack: %s" % self.folder_stack - def do_dd(self, attrs): pass do_p = do_dd - # Start ruler def do_hr(self, attrs): self.flush() @@ -235,17 +226,14 @@ class BkmkParser(HTMLParser): self.current_object = None self.objects += 1 - # BR in comment def do_br(self, attrs): self.accumulator += "
" - # Allow < in the text def unknown_starttag(self, tag, attrs): self.accumulator += "<%s>" % tag - # Do not allow unknow end tags def unknown_endtag(self, tag): raise NotImplementedError("Unknow end tag `%s'" % tag) diff --git a/parse_html/__init__.py b/parse_html/__init__.py index 95ab357..96fa696 100644 --- a/parse_html/__init__.py +++ b/parse_html/__init__.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + import codecs universal_charset = "utf-8" diff --git a/parse_html/beautifulsoup.py b/parse_html/beautifulsoup.py index ec5542a..1b2d3a4 100644 --- a/parse_html/beautifulsoup.py +++ b/parse_html/beautifulsoup.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2007-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + import re from sgmllib import SGMLParser, SGMLParseError from BeautifulSoup import BeautifulSoup, CData diff --git a/parse_html/etreetidy.py b/parse_html/etreetidy.py index 5d89700..0b36ecd 100644 --- a/parse_html/etreetidy.py +++ b/parse_html/etreetidy.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + from elementtidy import TidyHTMLTreeBuilder from .util import HTMLParser diff --git a/parse_html/html5.py b/parse_html/html5.py index 08fb6b1..a6443f1 100644 --- a/parse_html/html5.py +++ b/parse_html/html5.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + from html5lib import HTMLParser as HTML5Parser from .util import HTMLParser diff --git a/parse_html/htmlparser.py b/parse_html/htmlparser.py index 0932873..295df2b 100644 --- a/parse_html/htmlparser.py +++ b/parse_html/htmlparser.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + from HTMLParser import HTMLParseError from m_lib.net.www.html import HTMLParser as _HTMLParser @@ -29,7 +32,6 @@ class HTMLParser(_HTMLParser): def end_head(self): raise HTMLHeadDone() - def do_meta(self, attrs): http_equiv = "" content = "" @@ -54,7 +56,6 @@ class HTMLParser(_HTMLParser): if http_equiv == "refresh": self.refresh = content - def start_title(self, attrs): self.accumulator = '' @@ -62,7 +63,6 @@ class HTMLParser(_HTMLParser): if not self.title: # use only the first title self.title = self.accumulator - def do_link(self, attrs): has_icon = False href = None diff --git a/parse_html/lxml.py b/parse_html/lxml.py index 30d43a4..01dd759 100644 --- a/parse_html/lxml.py +++ b/parse_html/lxml.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['parse_html'] + + from lxml.html import parse from .util import HTMLParser diff --git a/parse_html/util.py b/parse_html/util.py index 12bab4c..b26d9d9 100644 --- a/parse_html/util.py +++ b/parse_html/util.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['HTMLParser'] + + from HTMLParser import HTMLParser class HTMLParser(HTMLParser): diff --git a/robots.py b/robots.py index 4aa7372..ca4f3c3 100644 --- a/robots.py +++ b/robots.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['import_robot', 'robot'] + + from os import environ robot_name = environ.get("BKMK_ROBOT", "forking") diff --git a/storage.py b/storage.py index 5d309bf..0e2b679 100644 --- a/storage.py +++ b/storage.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['import_storage', 'storage'] + + from os import environ storage_name = environ.get("BKMK_STORAGE", "pickle") diff --git a/writers.py b/writers.py index 46fb08a..7a0ec8c 100644 --- a/writers.py +++ b/writers.py @@ -10,6 +10,9 @@ __author__ = "Oleg Broytman " __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design" __license__ = "GNU GPL" +__all__ = ['import_writer', 'writer'] + + from os import environ writer_name = environ.get("BKMK_WRITER", "html") -- 2.39.5