Blacken'd

This commit is contained in:
sfigato 2019-09-04 14:56:36 +02:00
parent 0ceebdaf68
commit 589d95b5ac
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
3 changed files with 15 additions and 20 deletions

View File

@ -8,8 +8,7 @@ import click
@click.command() @click.command()
def main(args=None): def main(args=None):
"""Console script for bot_z.""" """Console script for bot_z."""
click.echo("Replace this message by putting your code into " click.echo("Replace this message by putting your code into " "bot_z.cli.main")
"bot_z.cli.main")
click.echo("See click documentation at http://click.pocoo.org/") click.echo("See click documentation at http://click.pocoo.org/")

View File

@ -21,11 +21,11 @@ import zipfile
GECKO_RELEASE_PATH = "https://github.com/mozilla/geckodriver" GECKO_RELEASE_PATH = "https://github.com/mozilla/geckodriver"
PKG_NAME = 'bot_z' PKG_NAME = "bot_z"
VERSION = '0.1.0' VERSION = "0.1.0"
AUTHOR = 'blallo' AUTHOR = "blallo"
AUTHOR_EMAIL = 'blallo@autistici.org' AUTHOR_EMAIL = "blallo@autistici.org"
BIN_PATH = 'bin/geckodriver' BIN_PATH = "bin/geckodriver"
with open("README.md") as readme_file: with open("README.md") as readme_file:
readme = readme_file.read() readme = readme_file.read()
@ -151,15 +151,15 @@ def download_driver_bin(uri: str, path: str) -> None:
os.remove(filepath) os.remove(filepath)
def preinstall(platform: T.Optional[str]=None) -> None: def preinstall(platform: T.Optional[str] = None) -> None:
""" """
Performs all the postintallation flow, donwloading in the Performs all the postintallation flow, donwloading in the
right place the geckodriver binary. right place the geckodriver binary.
""" """
# target_path = os.path.join(os.path.abspath(os.path.curdir), 'bot_z', 'bin') # target_path = os.path.join(os.path.abspath(os.path.curdir), 'bot_z', 'bin')
target_path = pkg_resources.resource_filename('bot_z', 'bin') target_path = pkg_resources.resource_filename("bot_z", "bin")
ensure_local_folder() ensure_local_folder()
version = os.environ.get('BOTZ_GECKO_VERSION') version = os.environ.get("BOTZ_GECKO_VERSION")
gecko_uri = assemble_driver_uri(version, platform) gecko_uri = assemble_driver_uri(version, platform)
print("[POSTINSTALL] gecko_uri: {}".format(gecko_uri)) print("[POSTINSTALL] gecko_uri: {}".format(gecko_uri))
download_driver_bin(gecko_uri, target_path) download_driver_bin(gecko_uri, target_path)
@ -203,7 +203,7 @@ class CustomInstallCommand(install):
def run(self): def run(self):
opts = self.distribution.get_cmdline_options() opts = self.distribution.get_cmdline_options()
platform = None platform = None
if 'bdist_wheel' in opts: if "bdist_wheel" in opts:
platform = translate_platform_to_gecko_vers( platform = translate_platform_to_gecko_vers(
opts["bdist_wheel"].get("plat-name") opts["bdist_wheel"].get("plat-name")
) )
@ -242,12 +242,8 @@ setup(
"install": CustomInstallCommand, "install": CustomInstallCommand,
"bdist_wheel": CustomBDistWheel, "bdist_wheel": CustomBDistWheel,
}, },
entry_points={ entry_points={"console_scripts": ["bot_z=bot_z.cli:main"]},
'console_scripts': [ package_data={"bot_z": ["bin/geckodriver"]},
'bot_z=bot_z.cli:main'
]
},
package_data = {'bot_z': ['bin/geckodriver']},
include_package_data=True, include_package_data=True,
install_requires=requirements, install_requires=requirements,
license="GLWTS Public Licence", license="GLWTS Public Licence",

View File

@ -28,7 +28,7 @@ class TestBot_z(unittest.TestCase):
runner = CliRunner() runner = CliRunner()
result = runner.invoke(cli.main) result = runner.invoke(cli.main)
assert result.exit_code == 0 assert result.exit_code == 0
assert 'bot_z.cli.main' in result.output assert "bot_z.cli.main" in result.output
help_result = runner.invoke(cli.main, ['--help']) help_result = runner.invoke(cli.main, ["--help"])
assert help_result.exit_code == 0 assert help_result.exit_code == 0
assert '--help Show this message and exit.' in help_result.output assert "--help Show this message and exit." in help_result.output