Skip to content

Commit

Permalink
STY: Changes to abide by PEP8.
Browse files Browse the repository at this point in the history
  • Loading branch information
hhslepicka committed Mar 14, 2022
1 parent 5af2de3 commit 5339c5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion botcity/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .bot import WebBot, Browser, BROWSER_CONFIGS, By # noqa: F401, F403
from .parsers import table_to_dict, data_from_row, sanitize_header # noqa: F401, F403
from .util import element_as_select # noqa: F401, F403
from .util import element_as_select # noqa: F401, F403

from botcity.web._version import get_versions
__version__ = get_versions()['version']
Expand Down
11 changes: 8 additions & 3 deletions botcity/web/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,8 @@ def wait_for_downloads(self, timeout: int = 120000):
# waits for all the files to be completed
WebDriverWait(self._driver, timeout/1000.0, 1).until(wait_method)

def find_elements(self, selector: str, by: By = By.CSS_SELECTOR, waiting_time=10000, ensure_visible: bool = True) -> List[WebElement]:
def find_elements(self, selector: str, by: By = By.CSS_SELECTOR,
waiting_time=10000, ensure_visible: bool = True) -> List[WebElement]:
"""Find elements using the specified selector with selector type specified by `by`.
Args:
Expand All @@ -1084,7 +1085,10 @@ def find_elements(self, selector: str, by: By = By.CSS_SELECTOR, waiting_time=10
...
```
"""
condition = EC.visibility_of_all_elements_located if ensure_visible else EC.presence_of_all_elements_located
if ensure_visible:
condition = EC.visibility_of_all_elements_located
else:
condition = EC.presence_of_all_elements_located

try:
elements = WebDriverWait(
Expand All @@ -1097,7 +1101,8 @@ def find_elements(self, selector: str, by: By = By.CSS_SELECTOR, waiting_time=10
print("Exception on find_elements", ex)
return None

def find_element(self, selector: str, by: str = By.CSS_SELECTOR, waiting_time=10000, ensure_visible: bool = False, ensure_clickable: bool = False) -> WebElement:
def find_element(self, selector: str, by: str = By.CSS_SELECTOR, waiting_time=10000,
ensure_visible: bool = False, ensure_clickable: bool = False) -> WebElement:
"""Find an element using the specified selector with selector type specified by `by`.
If more than one element is found, the first instance is returned.
Expand Down
5 changes: 3 additions & 2 deletions botcity/web/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def sanitize_header(labels: List[str]):
label = label.lower()

# remove punctuations
label = ''.join([l for l in label if l not in string.punctuation])
label = ''.join([l for l in label if l not in string.punctuation]) # noqa: E741

# replace spaces with underscores
label = label.replace(" ", "_")
Expand All @@ -47,7 +47,8 @@ def sanitize_header(labels: List[str]):
return labels


def table_to_dict(table: WebElement, has_header: bool = True, skip_rows: int = 0, header_tag: str = "th") -> List[Dict]:
def table_to_dict(table: WebElement, has_header: bool = True,
skip_rows: int = 0, header_tag: str = "th") -> List[Dict]:
"""Convert a table WebElement to a dict of lists.
Args:
Expand Down

0 comments on commit 5339c5f

Please sign in to comment.