Esempio n. 1
0
ap.add_argument(
    '--syncdate',
    action='store',
    default=None,
    help=
    'Sync links on or after a desired date. Defaults to 1970-01-01 00:00:00')
args = ap.parse_args()

# Reinterpretation of fiddly options
if 'tab' == args.separator:
    args.separator = '\t'

# Input
if not os.path.exists(args.input):
    raise SystemExit, "The input file does not exist: %s" % args.input
rlr = ReadingListReader(args.input)

bookmarks = rlr.read(
    show=None if 'all' == args.show else args.show,
    sortfield=args.sortfield,
    ascending=True if 'ascending' == args.sortorder else False,
    dateformat=args.timestamp,
    syncdate=args.syncdate)

if args.bookmarks:

    # Netscape Bookmarks File formatted output
    # eg http://msdn.microsoft.com/en-us/library/ie/aa753582(v=vs.85).aspx

    print >> args.output, '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<HTML>\n<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8">\n<Title>Bookmarks</Title>\n<H1>Bookmarks</H1>\n<DT><H3 FOLDED>Reading List Bookmarks</H3>\n<DL>'
    for bookmark in bookmarks:
Esempio n. 2
0
#!/usr/bin/python

from readinglistlib import ReadingListReader

rlr = ReadingListReader()
bookmarks = rlr.read(ascending=False)

print '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Reading List</title></head><body><h1>Reading List</h1><ul>'

for bookmark in bookmarks:
    print '<li><p><a href="%(url)s">%(title)s</a><br />%(url)s</p><blockquote>%(preview)s</blockquote></li>' % {
        'url': bookmark['url'].encode('utf-8'),
        'title': bookmark['title'].encode('utf-8'),
        'preview': bookmark['preview'].encode('utf-8')
    }

print '</ul></body></html>'