diff options
author | Philipp Hansch <dev@phansch.net> | 2016-03-20 10:49:33 +0100 |
---|---|---|
committer | Philipp Hansch <dev@phansch.net> | 2016-03-20 10:49:33 +0100 |
commit | 8000af1664d2feefb16e3be992cb211f0e5aa818 (patch) | |
tree | 559da239c22eb5b9d435cfd50207dde2f53f0d65 /scripts/importer.py | |
parent | 93e0f292541fd1c790ce6ef2e38b663a44dcb8de (diff) | |
download | qutebrowser-8000af1664d2feefb16e3be992cb211f0e5aa818.tar.gz qutebrowser-8000af1664d2feefb16e3be992cb211f0e5aa818.zip |
Generalize bookmarks import
This change adds `firefox` and `ie` as possible arguments to the importer
script.
Diffstat (limited to 'scripts/importer.py')
-rwxr-xr-x | scripts/importer.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/scripts/importer.py b/scripts/importer.py index 51e01c106..027d48264 100755 --- a/scripts/importer.py +++ b/scripts/importer.py @@ -21,7 +21,7 @@ """Tool to import data from other browsers. -Currently only importing bookmarks from Chromium is supported. +Currently only importing bookmarks from Netscape Bookmark files is supported. """ @@ -30,24 +30,27 @@ import argparse def main(): args = get_args() - if args.browser == 'chromium': - import_chromium(args.bookmarks) + if args.browser in ['chromium', 'firefox', 'ie']: + import_netscape_bookmarks(args.bookmarks) def get_args(): """Get the argparse parser.""" parser = argparse.ArgumentParser( - epilog="To import bookmarks from Chromium, export them to HTML in " - "Chromium's bookmark manager.") - parser.add_argument('browser', help="Which browser?", choices=['chromium'], + epilog="To import bookmarks from Chromium, Firefox or IE, " + "export them to HTML in your browsers bookmark manager.") + parser.add_argument('browser', help="Which browser?", + choices=['chromium', 'firefox', 'ie'], metavar='browser') parser.add_argument('bookmarks', help="Bookmarks file") args = parser.parse_args() return args +def import_netscape_bookmarks(bookmarks_file): + """Import bookmarks from a NETSCAPE-Bookmark-file v1 -def import_chromium(bookmarks_file): - """Import bookmarks from a HTML file generated by Chromium.""" + Generated by Chromium, Firefox, Internet Explorer and possibly more browsers + """ import bs4 with open(bookmarks_file, encoding='utf-8') as f: soup = bs4.BeautifulSoup(f, 'html.parser') |