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 from __future__ import print_function
9 from getopt import getopt
10 from bkmk_parser import BkmkParser
13 __author__ = "Oleg Broytman <phd@phdru.name>"
14 __copyright__ = "Copyright (C) 1997-2017 PhiloSoft Design"
15 __license__ = "GNU GPL"
19 optlist, args = getopt(sys.argv[1:], "is")
24 for _opt, _arg in optlist:
36 sys.stderr.write("bkmk2db: too many arguments\n")
37 sys.stderr.write("Usage: bkmk2db [-is] bookmarks.html\n")
43 filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX
47 from storage import storage_name
48 sys.stdout.write("Converting %s to %s: " % (filename, storage_name))
52 show_pbar = sys.stderr.isatty()
56 from m_lib.pbar.tty_pbar import ttyProgressBar
62 size = os.path.getsize(filename)
64 print(filename, ": no such file")
69 pbar = ttyProgressBar(0, size)
72 # This is for DOS - it counts CRLF, which len() counts as 1 char!
73 if os.name == 'dos' or os.name == 'nt' :
76 dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct
79 infile = open(filename, 'r')
88 lng = lng + len(line) + dos_add
112 print(line_no, "lines proceed")
113 print(parser.urls, "urls found")
114 print(parser.objects, "objects created")
117 from storage import storage
119 storage.store(parser.root_folder)
123 traceback.print_exc()
127 if __name__ == '__main__':