REF(buku) ff json import improve debug logging
This commit is contained in:
parent
c32cf5911b
commit
b5844ee1c1
39
buku
39
buku
@ -2428,7 +2428,7 @@ class BukuDb:
|
|||||||
|
|
||||||
items = import_firefox_json(data, add_bookmark_folder_as_tag, newtag)
|
items = import_firefox_json(data, add_bookmark_folder_as_tag, newtag)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
LOGERR("JSON Decode Error: {}".format(e))
|
LOGERR("ff_json: JSON Decode Error: {}".format(e))
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGERR(e)
|
LOGERR(e)
|
||||||
@ -2981,7 +2981,7 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
|
|||||||
]
|
]
|
||||||
return d[0]['value']
|
return d[0]['value']
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGDBG("No description found for entry: {} {}".format(entry['uri'], entry['title']))
|
LOGDBG("ff_json: No description found for entry: {} {}".format(entry['uri'], entry['title']))
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def extract_tags(entry):
|
def extract_tags(entry):
|
||||||
@ -2989,7 +2989,7 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
|
|||||||
try:
|
try:
|
||||||
tags = entry['tags'].split(',')
|
tags = entry['tags'].split(',')
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGDBG("No tags found for entry: {} {}".format(entry['uri'], entry['title']))
|
LOGDBG("ff_json: No tags found for entry: {} {}".format(entry['uri'], entry['title']))
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
@ -2998,17 +2998,18 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
|
|||||||
try:
|
try:
|
||||||
typeCode = bm_entry['typeCode']
|
typeCode = bm_entry['typeCode']
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGDBG("item without typeCode found, ignoring: {}".format(bm_entry['title']))
|
LOGDBG("ff_json: item without typeCode found, ignoring: {}".format(bm_entry['title']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
LOGDBG("ff_json: processing typeCode '{}', title '{}'".format(typeCode, bm_entry['title']))
|
||||||
if TypeCode.uri.value == typeCode:
|
if TypeCode.uri.value == typeCode:
|
||||||
try:
|
try:
|
||||||
if is_smart(bm_entry):
|
if is_smart(bm_entry):
|
||||||
LOGDBG("SmartBookmark found, ignoring: {}".format(bm_entry['title']))
|
LOGDBG("ff_json: SmartBookmark found, ignoring: {}".format(bm_entry['title']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if is_nongeneric_url(bm_entry['uri']):
|
if is_nongeneric_url(bm_entry['uri']):
|
||||||
LOGDBG("Non-Generic URL found, ignoring: {}".format(bm_entry['title']))
|
LOGDBG("ff_json: Non-Generic URL found, ignoring: {}".format(bm_entry['title']))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
desc = extract_desc(bm_entry)
|
desc = extract_desc(bm_entry)
|
||||||
@ -3024,11 +3025,11 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
|
|||||||
formatted_tags = [DELIM + tag for tag in bookmark_tags]
|
formatted_tags = [DELIM + tag for tag in bookmark_tags]
|
||||||
tags = parse_tags(formatted_tags)
|
tags = parse_tags(formatted_tags)
|
||||||
|
|
||||||
LOGDBG("Entry found: {}, {}, {}, {} "
|
LOGDBG("ff_json: Entry found: {}, {}, {}, {} " .format(bm_entry['uri'], bm_entry['title'], tags, desc))
|
||||||
.format(bm_entry['uri'], bm_entry['title'], tags, desc))
|
|
||||||
yield (bm_entry['uri'], bm_entry['title'], tags, desc, 0, True, False)
|
yield (bm_entry['uri'], bm_entry['title'], tags, desc, 0, True, False)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGERR("Error parsing entry '{}' Exception '{}'".format(bm_entry['title'], e))
|
LOGERR("ff_json: Error parsing entry '{}' Exception '{}'".format(bm_entry['title'], e))
|
||||||
|
|
||||||
elif TypeCode.folder.value == typeCode:
|
elif TypeCode.folder.value == typeCode:
|
||||||
try:
|
try:
|
||||||
@ -3041,28 +3042,34 @@ def import_firefox_json(json, add_bookmark_folder_as_tag=False, unique_tag=None)
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# if any of the properties does not exist, bail out silently
|
# if any of the properties does not exist, bail out silently
|
||||||
LOGDBG("No 'children' found in bookmark folder - skipping: {}".format(bm_entry['title']))
|
LOGDBG("ff_json: No 'children' found in bookmark folder - skipping: {}".format(bm_entry['title']))
|
||||||
|
|
||||||
elif TypeCode.separator.value == typeCode:
|
elif TypeCode.separator.value == typeCode:
|
||||||
LOGDBG("Unknown typeCode found : {}".format(typeCode))
|
LOGDBG("ff_json: Unknown typeCode found : {}".format(typeCode))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
main_entry_list = json['children']
|
main_entry_list = json['children']
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGERR("No children in Root entry found")
|
LOGDBG("ff_json: No children in Root entry found")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# interate over each main bookmark container, ignoring main container title
|
# interate over each main bookmark container, ignoring main container title
|
||||||
# assuming all entries with 'children' are containers, skipping typeCode test
|
# assuming all entries with 'children' are containers, skipping typeCode test
|
||||||
for main_container in main_entry_list:
|
for main_container in main_entry_list:
|
||||||
try:
|
try:
|
||||||
yield from iterate_children(None, main_container['children'])
|
main_container_title = main_container['title']
|
||||||
except Exception:
|
except Exception:
|
||||||
|
main_container_title = "<Main Bookmark Container: no title>"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
title = main_container['title']
|
main_container_children = main_container['children']
|
||||||
except Exception:
|
except Exception:
|
||||||
title = None
|
main_container_children = None
|
||||||
LOGDBG("No 'children' found in main bookmark folder - skipping: {}".format(title))
|
LOGDBG("ff_json: No 'children' found in main bookmark folder - skipping: {}".format(main_container_title))
|
||||||
|
|
||||||
|
if main_container_children:
|
||||||
|
LOGDBG("ff_json: main bookmark folder : {}".format(main_container_title))
|
||||||
|
yield from iterate_children(None, main_container_children)
|
||||||
|
|
||||||
|
|
||||||
def import_html(html_soup, add_parent_folder_as_tag, newtag):
|
def import_html(html_soup, add_parent_folder_as_tag, newtag):
|
||||||
|
Loading…
Reference in New Issue
Block a user