Handle add and update description from editor

This commit is contained in:
Arun Prakash Jana 2018-08-05 20:34:32 +05:30
parent 5ed1e96368
commit cc6151a775
No known key found for this signature in database
GPG Key ID: A75979F35C080412

37
buku.py
View File

@ -563,19 +563,19 @@ class BukuDb:
logerr('URL [%s] already exists at index %d', url, id)
return -1
# Process title
# Fetch data
meta, pdesc, ptags, mime, bad = network_handler(url)
if bad:
print('Malformed URL\n')
elif mime:
logdbg('HTTP HEAD requested')
elif meta == '' and title_in is None:
print('No title\n')
else:
logdbg('Title: [%s]', meta)
if title_in is not None:
meta = title_in
else:
meta, pdesc, ptags, mime, bad = network_handler(url)
if bad:
print('Malformed URL\n')
elif mime:
logdbg('HTTP HEAD requested')
elif meta == '':
print('No title\n')
else:
logdbg('Title: [%s]', meta)
# Fix up tags, if broken
if tags_in and tags_in != DELIM:
@ -4079,11 +4079,13 @@ def to_temp_file_content(url, title_in, tags_in, desc):
strings += (tags_in.strip(DELIM),) if not None else ''
# DESC
strings += ('# Add COMMENTS in next line(s).',)
if desc is not None and desc != '':
strings += (desc,)
else:
strings += ('# Add COMMENTS in next line(s). Leave blank to web fetch, "-" for no comments.',)
if desc is None:
strings += ('\n',)
elif desc == '':
strings += ('-',)
else:
strings += (desc,)
return '\n'.join(strings)
@ -4141,6 +4143,11 @@ def parse_temp_file_content(content):
comments = comments[0:i+1]
comments = '\n'.join(comments)
if comments == '':
comments = None
elif comments == '-':
comments = ''
return url, title, tags, comments