Skip to content

Commit

Permalink
Merge pull request #26 from p4irin/fix-index-error
Browse files Browse the repository at this point in the history
Fix IndexError
  • Loading branch information
p4irin committed May 4, 2024
2 parents 03c710f + 9b214b9 commit ac2a454
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/c4t/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,12 @@ def switch(self) -> None:

try:
selection = int(input("Select a version by number: "))
except ValueError:
selection = None
except IndexError:
version = versions[selection]
except (ValueError, IndexError):
print(f'Invalid selection. Select a number from 0 to {len(versions) - 1}!')
selection = None

if selection is not None:
version = versions[selection]
self._create_symlink(to_binary='chrome', version=version)
self._create_symlink(to_binary='chromedriver', version=version)
print(f'Active version is now: {version}')
Expand Down Expand Up @@ -466,26 +465,25 @@ def install_last_known_good_version(self) -> None:
versions = self.last_known_good_versions()
try:
selection = int(input('Select a version by number: '))
except ValueError:
selection = None
except IndexError:
version = versions[selection]
except (ValueError, IndexError):
print(f'Invalid selection. Select a number from 0 to {len(versions) - 1}!')
selection = None

if selection is not None:
self.install(version=versions[selection])
self.install(version=version)

def delete(self) -> None:
versions = self.installed()

try:
selection = int(input("Select a version by number: "))
except ValueError:
selection = None
except IndexError:
version = versions[selection]
except (ValueError, IndexError):
print(f'Invalid selection. Select a number from 0 to {len(versions) - 1}!')
selection = None

if selection is not None:
version = versions[selection]
if version == self.active_version:
print('The version you selected is the active version.')
print('Switch the active version first!')
Expand Down

0 comments on commit ac2a454

Please sign in to comment.