Skip to content

Commit

Permalink
Improved bs.is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sgeulette committed Jan 2, 2024
1 parent fb6e5c6 commit 65a6d35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog
[sgeulette]
- Added `load_pickle` and `dump_pickle`
[sgeulette]
- Improved `bs.is_empty`
[sgeulette]

1.0.0a (2023-11-28)
-------------------
Expand Down
2 changes: 1 addition & 1 deletion imio/pyutils/bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def is_empty(element):
:param element: bs item
:return: Bool value (True is empty)
"""
return len(element.get_text(strip=True)) == 0 and len(list(element.children)) == 0
return len(element.get_text(strip=True)) == 0 and not len([ch for ch in element.children if ch.strip()])


def remove_attributes(element, attributes=[], recursive=True):
Expand Down

0 comments on commit 65a6d35

Please sign in to comment.