FlyingWolFox/Netscape-Bookmarks-File-Parser

Usage

whiteday321 opened this issue · 2 comments

Hi,

Could you please provide an example of basic usage for parsing a file. This is the code that I'm using, but I get a "list index out of range" error when trying to run the parse function :

from NetscapeBookmarksFileParser import *
from NetscapeBookmarksFileParser import parser

...

file = NetscapeBookmarksFile("test.html")
bookmarks = parser.parse(file)

Thanks

Sorry for the late response. I didn't receive the notification

The constructor expects a open file descriptor or a string with the file contents. Also the parser works on self, returning it too for use in one liners. In your case, that'd be:

with open('test.html') as file:
    bookmarks = NetscapeBookmarksFile(file).parse()

Or with more verbosity:

with open('test.html') as file:
    bookmarks = NetscapeBookmarksFile(file)

bookmarks.parse()

The README is not that clear about the usage, thanks for bringing that to my attention, I'll fix it.

Fixed with b72e304