fix: dev: export
This commit is contained in:
parent
40c1a90147
commit
f98f5fdac0
8
buku
8
buku
@ -2784,14 +2784,14 @@ def convert_bookmark_set(
|
|||||||
out = ''
|
out = ''
|
||||||
if export_type == 'markdown':
|
if export_type == 'markdown':
|
||||||
for row in resultset:
|
for row in resultset:
|
||||||
if row[2] == '':
|
if not row[2]:
|
||||||
out += '- [Untitled](' + row[1] + ')\n'
|
out += '- [Untitled](' + row[1] + ')\n'
|
||||||
else:
|
else:
|
||||||
out += '- [' + row[2] + '](' + row[1] + ')\n'
|
out += '- [' + row[2] + '](' + row[1] + ')\n'
|
||||||
count += 1
|
count += 1
|
||||||
elif export_type == 'org':
|
elif export_type == 'org':
|
||||||
for row in resultset:
|
for row in resultset:
|
||||||
if row[2] == '':
|
if row[2]:
|
||||||
out += '* [[{}][Untitled]]\n'.format(row[1])
|
out += '* [[{}][Untitled]]\n'.format(row[1])
|
||||||
else:
|
else:
|
||||||
out += '* [[{}][{}]]\n'.format(row[1], row[2])
|
out += '* [[{}][{}]]\n'.format(row[1], row[2])
|
||||||
@ -2809,10 +2809,10 @@ def convert_bookmark_set(
|
|||||||
' <DL><p>\n'.format(timestamp))
|
' <DL><p>\n'.format(timestamp))
|
||||||
|
|
||||||
for row in resultset:
|
for row in resultset:
|
||||||
out += (' <DT><A HREF="%s" ADD_DATE="%s" LAST_MODIFIED="%s"' % (row[1], timestamp, timestamp))
|
out += ' <DT><A HREF="%s" ADD_DATE="%s" LAST_MODIFIED="%s"' % (row[1], timestamp, timestamp)
|
||||||
if row[3] != DELIM:
|
if row[3] != DELIM:
|
||||||
out += ' TAGS="' + row[3][1:-1] + '"'
|
out += ' TAGS="' + row[3][1:-1] + '"'
|
||||||
out += '>' + row[2] if row[2] else '' + '</A>\n'
|
out += '>{}</A>\n'.format(row[2] if row[2] else '')
|
||||||
if row[4] != '':
|
if row[4] != '':
|
||||||
out += ' <DD>' + row[4] + '\n'
|
out += ' <DD>' + row[4] + '\n'
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -738,11 +738,12 @@ def test_copy_to_clipboard(platform, params):
|
|||||||
' <DT><H3 ADD_DATE="1556430615" LAST_MODIFIED="1556430615" PERSONAL_TOOLBAR_FOLDER="true">Buku bookmarks</H3>\n'
|
' <DT><H3 ADD_DATE="1556430615" LAST_MODIFIED="1556430615" PERSONAL_TOOLBAR_FOLDER="true">Buku bookmarks</H3>\n'
|
||||||
' <DL><p>\n'
|
' <DL><p>\n'
|
||||||
' <DT><A HREF="htttp://example.com" ADD_DATE="1556430615" LAST_MODIFIED="1556430615"></A>\n'
|
' <DT><A HREF="htttp://example.com" ADD_DATE="1556430615" LAST_MODIFIED="1556430615"></A>\n'
|
||||||
|
' <DT><A HREF="htttp://example.org" ADD_DATE="1556430615" LAST_MODIFIED="1556430615"></A>\n'
|
||||||
' <DT><A HREF="http://google.com" ADD_DATE="1556430615" LAST_MODIFIED="1556430615">Google</A>\n'
|
' <DT><A HREF="http://google.com" ADD_DATE="1556430615" LAST_MODIFIED="1556430615">Google</A>\n'
|
||||||
' </DL><p>\n</DL><p>'
|
' </DL><p>\n</DL><p>'
|
||||||
],
|
],
|
||||||
['org', '* [[htttp://example.com][Untitled]]\n* [[http://google.com][Google]]\n'],
|
['org', '* [[htttp://example.com][]]\n* [[htttp://example.org][None]]\n* [[http://google.com][Untitled]]\n'],
|
||||||
['markdown', '- [Untitled](htttp://example.com)\n- [Google](http://google.com)\n'],
|
['markdown', '- [Untitled](htttp://example.com)\n- [Untitled](htttp://example.org)\n- [Google](http://google.com)\n'],
|
||||||
['random', None],
|
['random', None],
|
||||||
])
|
])
|
||||||
def test_convert_bookmark_set(export_type, exp_res, monkeypatch):
|
def test_convert_bookmark_set(export_type, exp_res, monkeypatch):
|
||||||
@ -750,7 +751,7 @@ def test_convert_bookmark_set(export_type, exp_res, monkeypatch):
|
|||||||
import buku
|
import buku
|
||||||
bms = [
|
bms = [
|
||||||
(1, 'htttp://example.com', '', ',', '', 0),
|
(1, 'htttp://example.com', '', ',', '', 0),
|
||||||
(1, 'htttp://example.com', None, ',', '', 0),
|
(1, 'htttp://example.org', None, ',', '', 0),
|
||||||
(2, 'http://google.com', 'Google', ',', '', 0)]
|
(2, 'http://google.com', 'Google', ',', '', 0)]
|
||||||
if export_type == 'random':
|
if export_type == 'random':
|
||||||
with pytest.raises(AssertionError):
|
with pytest.raises(AssertionError):
|
||||||
@ -761,5 +762,5 @@ def test_convert_bookmark_set(export_type, exp_res, monkeypatch):
|
|||||||
return 1556430615
|
return 1556430615
|
||||||
monkeypatch.setattr(buku.time, 'time', return_fixed_number)
|
monkeypatch.setattr(buku.time, 'time', return_fixed_number)
|
||||||
res = convert_bookmark_set(bms, export_type=export_type)
|
res = convert_bookmark_set(bms, export_type=export_type)
|
||||||
assert res['count'] == 2
|
assert res['count'] == 3
|
||||||
assert exp_res == res['data']
|
assert exp_res == res['data']
|
||||||
|
Loading…
Reference in New Issue
Block a user