Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions delver/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,14 @@ def action_url(self):
:return: str
"""
action_url = self.action
return urljoin(
self._url if urlparse(action_url).scheme else '',
self.action
)
return urljoin(self._url if urlparse(action_url).scheme else '', action_url)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FormWrapper.action_url refactored with the following changes:

  • Use previously assigned local variable (use-assigned-variable)


def has_fields(self, fields):
"""Return ``True`` if all fields are present

:return: bool
"""
for field in fields:
if field not in dict(self._lxml_form.inputs):
return False
return True
return all(field in dict(self._lxml_form.inputs) for field in fields)
Comment on lines -144 to +141
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FormWrapper.has_fields refactored with the following changes:

  • Use any() instead of for loop (use-any)
  • Invert any/all to simplify comparisons (invert-any-all)


def __getattr__(self, item):
"""Wraps some chosen methods (PARENT_METHODS) from ``lxml.html.FormElement``
Expand Down
2 changes: 1 addition & 1 deletion delver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def process_row():
headers.append(row_child.text_content())
elif row_child.tag == 'td':
if headers[subindex] in colspans:
if not headers[subindex] in table_dict[index]:
if headers[subindex] not in table_dict[index]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function table_to_dict.process_row refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

table_dict[index][headers[subindex]] = [row_child.text_content()]
else:
table_dict[index][headers[subindex]].append(row_child.text_content())
Expand Down