-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[jarun#807] fixed import in single-parent-folder-tag mode #814
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4014,35 +4014,21 @@ def import_html(html_soup: BeautifulSoup, add_parent_folder_as_tag: bool, newtag | |
desc = comment_tag.find(string=True, recursive=False) | ||
|
||
if add_parent_folder_as_tag: | ||
# add parent folder as tag | ||
if use_nested_folder_structure: | ||
# New method that would generalize for else case to | ||
# structure of folders | ||
# dt | ||
# h3 (folder name) | ||
# dl | ||
# dt | ||
# a (could be h3, and continue recursively) | ||
parents = tag.find_parents('dl') | ||
for parent in parents: | ||
header = parent.find_previous_sibling('h3') | ||
if header: | ||
if tag.has_attr('tags'): | ||
tag['tags'] += (DELIM + strip_delim(header.text)) | ||
else: | ||
tag['tags'] = strip_delim(header.text) | ||
else: | ||
# could be its folder or not | ||
possible_folder = tag.find_previous('h3') | ||
# get list of tags within that folder | ||
tag_list = tag.parent.parent.find_parent('dl') | ||
|
||
if ((possible_folder) and possible_folder.parent in list(tag_list.parents)): | ||
# then it's the folder of this bookmark | ||
# New method that would generalize for else case to | ||
# structure of folders | ||
# dt | ||
# h3 (folder name) | ||
# dl | ||
# dt | ||
# a (could be h3, and continue recursively) | ||
parents = tag.find_parents('dl') | ||
for parent in (parents if use_nested_folder_structure else parents[:1]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the |
||
header = parent.find_previous_sibling('h3') | ||
if header: | ||
if tag.has_attr('tags'): | ||
tag['tags'] += (DELIM + strip_delim(possible_folder.text)) | ||
tag['tags'] += (DELIM + strip_delim(header.text)) | ||
else: | ||
tag['tags'] = strip_delim(possible_folder.text) | ||
tag['tags'] = strip_delim(header.text) | ||
|
||
# add unique tag if opted | ||
if newtag: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,7 +791,7 @@ def test_import_html_and_add_parent(): | |
[ | ||
("http://example11.com", None, ",folder11,", None, 0, True, False), | ||
("http://example121.com", None, ",folder121,", None, 0, True, False), | ||
("http://example12.com", None, None, None, 0, True, False), | ||
("http://example12.com", None, ",folder12,", None, 0, True, False), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corresponds to a snippet (below) that matches the usecase in question <DT><H3>Folder12</H3><DL><p>
<DT><H3>Folder121</H3><DL><p>
<DT><A HREF="http://example121.com"></A></DT>
</DL><p></DT>
<DT><A HREF="http://example12.com"></A></DT> |
||
("http://example13.com", None, ",folder13 (blah blah),tag3,tag4,", None, 0, True, False), | ||
], | ||
), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this comment (since it was merely quoting the line immediately before it)