2 """Convert Netscape Navigator's or Mozilla's bookmarks.html to a database
4 This file is a part of Bookmarks database and Internet robot.
7 __version__ = "$Revision$"[11:-2]
8 __revision__ = "$Id$"[5:-2]
9 __date__ = "$Date$"[7:-2]
10 __author__ = "Oleg Broytman <phd@phdru.name>"
11 __copyright__ = "Copyright (C) 1997-2011 PhiloSoft Design"
12 __license__ = "GNU GPL"
15 from getopt import getopt
16 from bkmk_parser import BkmkParser
20 optlist, args = getopt(sys.argv[1:], "is")
25 for _opt, _arg in optlist:
37 sys.stderr.write("bkmk2db: too many arguments\n")
38 sys.stderr.write("Usage: bkmk2db [-is] bookmarks.html\n")
44 filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX
48 from storage import storage_name
49 sys.stdout.write("Converting %s to %s: " % (filename, storage_name))
53 show_pbar = sys.stderr.isatty()
57 from m_lib.pbar.tty_pbar import ttyProgressBar
63 size = os.path.getsize(filename)
65 print filename, ": no such file"
70 pbar = ttyProgressBar(0, size)
73 # This is for DOS - it counts CRLF, which len() counts as 1 char!
74 if os.name == 'dos' or os.name == 'nt' :
77 dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct
80 infile = open(filename, 'r')
89 lng = lng + len(line) + dos_add
113 print line_no, "lines proceed"
114 print parser.urls, "urls found"
115 print parser.objects, "objects created"
118 from storage import storage
120 storage.store(parser.root_folder)
124 traceback.print_exc()
128 if __name__ == '__main__':