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 __author__ = "Oleg Broytman <phd@phdru.name>"
8 __copyright__ = "Copyright (C) 1997-2012 PhiloSoft Design"
9 __license__ = "GNU GPL"
12 from getopt import getopt
13 from bkmk_parser import BkmkParser
17 optlist, args = getopt(sys.argv[1:], "is")
22 for _opt, _arg in optlist:
34 sys.stderr.write("bkmk2db: too many arguments\n")
35 sys.stderr.write("Usage: bkmk2db [-is] bookmarks.html\n")
41 filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX
45 from storage import storage_name
46 sys.stdout.write("Converting %s to %s: " % (filename, storage_name))
50 show_pbar = sys.stderr.isatty()
54 from m_lib.pbar.tty_pbar import ttyProgressBar
60 size = os.path.getsize(filename)
62 print filename, ": no such file"
67 pbar = ttyProgressBar(0, size)
70 # This is for DOS - it counts CRLF, which len() counts as 1 char!
71 if os.name == 'dos' or os.name == 'nt' :
74 dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct
77 infile = open(filename, 'r')
86 lng = lng + len(line) + dos_add
110 print line_no, "lines proceed"
111 print parser.urls, "urls found"
112 print parser.objects, "objects created"
115 from storage import storage
117 storage.store(parser.root_folder)
121 traceback.print_exc()
125 if __name__ == '__main__':