1 #! /usr/local/bin/python -O
3 Convert Netscape Navigator's or Mozilla's bookmarks.html to a database
5 Written by BroytMann. Copyright (C) 1997-2003 PhiloSoft Design
10 from getopt import getopt
11 from bkmk_parser import BkmkParser
15 optlist, args = getopt(sys.argv[1:], "is")
17 show_pbar = not __debug__
20 for _opt, _arg in optlist:
32 sys.stderr.write("bkmk2db: too many arguments\n")
33 sys.stderr.write("Usage: bkmk2db [-is] bookmarks.html\n")
39 filename = 'bookmarks.html' # good name both for DOS (bookmark.htm) and UNIX
43 from storage import storage_name
44 sys.stdout.write("Converting %s to %s: " % (filename, storage_name))
48 show_pbar = sys.stderr.isatty()
52 from m_lib.pbar.tty_pbar import ttyProgressBar
58 size = os.path.getsize(filename)
60 print filename, ": no such file"
65 pbar = ttyProgressBar(0, size)
68 # This is for DOS - it counts CRLF, which len() counts as 1 char!
69 if os.name == 'dos' or os.name == 'nt' :
72 dos_add = 0 # UNIX' and Mac's len() counts CR or LF correct
75 infile = open(filename, 'r')
84 lng = lng + len(line) + dos_add
108 print line_no, "lines proceed"
109 print parser.urls, "urls found"
110 print parser.objects, "objects created"
113 from storage import storage
115 storage.store(parser.root_folder)
119 traceback.print_exc()
123 if __name__ == '__main__':