refactor: optimize imports and docstrings correction
This commit is contained in:
+11
-11
@@ -3,21 +3,21 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import click
|
from click import command, option, Choice, group
|
||||||
|
|
||||||
|
|
||||||
def get_package_dir():
|
def get_package_dir():
|
||||||
return Path(os.path.dirname(__file__))
|
return Path(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
|
||||||
def run_command(command, line):
|
def run_command(cmd, line):
|
||||||
print(f"Installing {line}...")
|
print(f"Installing {line}...")
|
||||||
_ = subprocess.check_call(command, shell=False) # nosec B603
|
_ = subprocess.check_call(cmd, shell=False) # nosec B603
|
||||||
# I meant to not use try except here
|
# I meant to not use try except here
|
||||||
|
|
||||||
|
|
||||||
@click.command(help="Install all Scrapling's Fetchers dependencies")
|
@command(help="Install all Scrapling's Fetchers dependencies")
|
||||||
@click.option(
|
@option(
|
||||||
"-f",
|
"-f",
|
||||||
"--force",
|
"--force",
|
||||||
"force",
|
"force",
|
||||||
@@ -43,14 +43,14 @@ def install(force):
|
|||||||
[sys.executable, "-m", "camoufox", "fetch", "--browserforge"],
|
[sys.executable, "-m", "camoufox", "fetch", "--browserforge"],
|
||||||
"Camoufox browser and databases",
|
"Camoufox browser and databases",
|
||||||
)
|
)
|
||||||
# if no errors raised by above commands, then we add below file
|
# if no errors raised by the above commands, then we add the below file
|
||||||
get_package_dir().joinpath(".scrapling_dependencies_installed").touch()
|
get_package_dir().joinpath(".scrapling_dependencies_installed").touch()
|
||||||
else:
|
else:
|
||||||
print("The dependencies are already installed")
|
print("The dependencies are already installed")
|
||||||
|
|
||||||
|
|
||||||
@click.command(help="Interactive scraping console")
|
@command(help="Interactive scraping console")
|
||||||
@click.option(
|
@option(
|
||||||
"-c",
|
"-c",
|
||||||
"--code",
|
"--code",
|
||||||
"code",
|
"code",
|
||||||
@@ -59,13 +59,13 @@ def install(force):
|
|||||||
type=str,
|
type=str,
|
||||||
help="Evaluate the code in the shell, print the result and exit",
|
help="Evaluate the code in the shell, print the result and exit",
|
||||||
)
|
)
|
||||||
@click.option(
|
@option(
|
||||||
"-L",
|
"-L",
|
||||||
"--loglevel",
|
"--loglevel",
|
||||||
"level",
|
"level",
|
||||||
is_flag=False,
|
is_flag=False,
|
||||||
default="debug",
|
default="debug",
|
||||||
type=click.Choice(
|
type=Choice(
|
||||||
["debug", "info", "warning", "error", "critical", "fatal"], case_sensitive=False
|
["debug", "info", "warning", "error", "critical", "fatal"], case_sensitive=False
|
||||||
),
|
),
|
||||||
help="Log level (default: DEBUG)",
|
help="Log level (default: DEBUG)",
|
||||||
@@ -77,7 +77,7 @@ def shell(code, level):
|
|||||||
console.start()
|
console.start()
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@group()
|
||||||
def main():
|
def main():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user