Skip to content

Commit

Permalink
clean up chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyPirogov committed Jul 25, 2023
1 parent 2295ed3 commit e512ba8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
13 changes: 6 additions & 7 deletions webdriver_manager/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ class Driver(object):
def __init__(
self,
name,
driver_version,
driver_version_to_download,
url,
latest_release_url,
http_client,
os_system_manager):
self._name = name
self._url = url
self._driver_version = driver_version
self._latest_release_url = latest_release_url
self._http_client = http_client
self._browser_version = None
self._driver_to_download_version = None
self._driver_version_to_download = driver_version_to_download
self._os_system_manager = os_system_manager
if not self._os_system_manager:
self._os_system_manager = OperationSystemManager()
Expand All @@ -43,10 +42,10 @@ def get_driver_version_to_download(self):
Downloads latest, if version is "latest" or browser could not been determined.
Downloads determined browser version driver in all other ways as a bonus fallback for lazy users.
"""
if not self._driver_to_download_version:
self._driver_to_download_version = self._driver_version if self._driver_version not in (None, "latest") \
else self.get_latest_release_version()
return self._driver_to_download_version
if self._driver_version_to_download:
return self._driver_version_to_download

return self.get_latest_release_version()

def get_latest_release_version(self):
# type: () -> str
Expand Down
22 changes: 11 additions & 11 deletions webdriver_manager/core/driver_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@ def load_metadata_content(self):
return {}

def __get_metadata_key(self, driver: Driver):
if self._metadata_key is None:
driver_version = self.get_cache_key_driver_version(driver)
browser_version = driver.get_browser_version_from_os()
browser_version = browser_version if browser_version else ""
self._metadata_key = f"{self.get_os_type()}_{driver.get_name()}_{driver_version}" \
f"_for_{browser_version}"
return self._metadata_key
if self._metadata_key:
return self._metadata_key

driver_version = self.get_cache_key_driver_version(driver)
browser_version = driver.get_browser_version_from_os()
browser_version = browser_version if browser_version else ""
self._metadata_key = f"{self.get_os_type()}_{driver.get_name()}_{driver_version}" \
f"_for_{browser_version}"

def get_cache_key_driver_version(self, driver: Driver):
if self._cache_key_driver_version is None:
self._cache_key_driver_version = "latest" if driver._driver_version in (
None, "latest") else driver._driver_version
return self._cache_key_driver_version
if self._cache_key_driver_version:
return self._cache_key_driver_version
return driver.get_driver_version_to_download()

def __get_path(self, driver: Driver):
if self._driver_binary_path is None:
Expand Down

0 comments on commit e512ba8

Please sign in to comment.