-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize the parsing logic to avoid unnecessary operations
- Loading branch information
dmy.berezovskyi
committed
Jan 15, 2025
1 parent
c1c8305
commit 479fdb8
Showing
10 changed files
with
189 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
"""Top-level package for RP To-Do.""" | ||
# rptodo/__init__.py | ||
|
||
__app_name__, __version__ = "Scrap", "1.0" | ||
|
||
|
||
SUCCESS, DIR_ERROR = range(2) | ||
|
||
ERRORS = { | ||
DIR_ERROR: "config directory error" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,12 @@ | ||
import argparse | ||
from pathlib import Path | ||
|
||
from pyfiglet import Figlet | ||
from rich.console import Console | ||
from colorama import Fore, Style | ||
|
||
from scraper.chrome_scraper import ChromePageScraper | ||
|
||
|
||
def create_cli(): | ||
# Initialize ArgumentParser | ||
parser = argparse.ArgumentParser(prog="sstf", description="SSTF Command Line Tool") | ||
|
||
# Add the 'get' subcommand | ||
subparsers = parser.add_subparsers(dest="command") | ||
|
||
# Add subcommand for 'get' | ||
get_parser = subparsers.add_parser("get", help="Download and manage Chromedriver") | ||
get_subparsers = get_parser.add_subparsers(dest="subcommand") | ||
|
||
# Add subcommand for 'chromedriver' | ||
chromedriver_parser = get_subparsers.add_parser("chromedriver", | ||
help="Download chromedriver for a specified version and platform") | ||
chromedriver_parser.add_argument('--milestone', type=str, | ||
help=f"{Fore.CYAN}Chromium milestone version (e.g., 131).{Style.RESET_ALL}") | ||
chromedriver_parser.add_argument('--version', type=str, | ||
help=f"{Fore.CYAN}Chromium browser version.{Style.RESET_ALL}") | ||
chromedriver_parser.add_argument('--platform', type=str, choices=["windows", "mac", "linux"], | ||
help=f"{Fore.CYAN}Operating system platform.{Style.RESET_ALL}") | ||
chromedriver_parser.add_argument('--output-dir', type=str, default=None, | ||
help=f"{Fore.CYAN}Directory to save the downloaded Chromedriver.{Style.RESET_ALL}") | ||
chromedriver_parser.add_argument('--extract', action='store_true', | ||
help=f"{Fore.CYAN}Extract the Chromedriver after download.{Style.RESET_ALL}") | ||
|
||
# Parse arguments | ||
args = parser.parse_args() | ||
|
||
# Handle 'get chromedriver' logic | ||
if args.command == "get" and args.subcommand == "chromedriver": | ||
console = Console() | ||
|
||
# ASCII Art Header with Figlet (using Rich) | ||
fig = Figlet(font="slant") # You can use different fonts like 'slant', 'block', etc. | ||
console.print(fig.renderText("Chromedriver Download"), style="bold green") | ||
|
||
# Run the actual logic for downloading chromedriver | ||
ChromePageScraper.get_chromedriver( | ||
platform=args.platform, | ||
version=args.version, | ||
milestone=args.milestone, | ||
d_dir=Path(args.output_dir) if args.output_dir else None, | ||
is_extracted=args.extract | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
create_cli() | ||
@click.command() | ||
@click.option("--platform", default=None, help="OS and architecture (e.g., 'win64', 'mac64')") | ||
@click.option("--version", default=None, help="The version of Chrome (e.g., '89.0.4389.82')") | ||
@click.option("--milestone", default=None, help="Milestone version (e.g., '129')") | ||
@click.option("--dir", default=None, type=pathlib.Path, help="Directory to save the chromedriver") | ||
@click.option("--extract", is_flag=True, help="Extract the chromedriver after downloading") | ||
def cli(platform, version, milestone, dir, extract): | ||
""" | ||
CLI command to fetch the latest Chrome driver | ||
""" | ||
print(f"Fetching ChromeDriver for platform: {platform}, version: {version}, milestone: {milestone}") | ||
ChromePageScraper.get_chromedriver(platform=platform, version=version, milestone=milestone, d_dir=dir, is_extracted=extract) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.