Skip to content

Commit

Permalink
Fix issues reported by flake8 (#73)
Browse files Browse the repository at this point in the history
* Wrap long line from commands.py
* Fix flake8 issues in transifex.py
* Fix typo in tx_cli_url variable name
  • Loading branch information
rffontenelle committed Oct 23, 2022
1 parent 797a28d commit 0084499
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 4 additions & 2 deletions sphinx_intl/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,16 @@ def create_txconfig():
@option_transifex_project_name
@option_locale_dir
@option_pot_dir
def update_txconfig_resources(transifex_organization_name, transifex_project_name, locale_dir, pot_dir):
def update_txconfig_resources(transifex_organization_name, transifex_project_name,
locale_dir, pot_dir):
"""
Update resource sections of `./.tx/config`.
"""
if not pot_dir:
pot_dir = os.path.join(locale_dir, 'pot')

transifex.update_txconfig_resources(transifex_organization_name, transifex_project_name, locale_dir, pot_dir)
transifex.update_txconfig_resources(transifex_organization_name, transifex_project_name,
locale_dir, pot_dir)


if __name__ == '__main__':
Expand Down
24 changes: 14 additions & 10 deletions sphinx_intl/transifex.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,31 @@ def normalize_resource_name(name):

return name


def check_transifex_cli_installed():
tx_cli_url = 'https://raw.githubusercontent.com/transifex/cli/master/install.sh'
if not which("tx"):
msg = textwrap.dedent("""\
msg = textwrap.dedent(f"""\
Could not run "tx".
You need to install the Transifex CLI external library.
Please install the below command and restart your terminal if you want to use this action:
Please install the below command and restart your terminal \
if you want to use this action:
$ curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
$ curl -o- {tx_cli_url} | bash
""")
raise click.BadParameter(msg)

version_msg = subprocess.check_output("tx --version", shell=True, encoding="utf-8")

if not version_msg.startswith("TX Client"):
msg = textwrap.dedent("""\
msg = textwrap.dedent(f"""\
The old transifex_client library was found.
You need to install the Transifex CLI external library.
Please install the below command and restart your terminal if you want to use this action:
Please install the below command and restart your terminal \
if you want to use this action:
$ curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
$ curl -o- {tx_cli_url} | bash
""")
raise click.BadParameter(msg)
Expand All @@ -91,7 +95,7 @@ def check_transifex_cli_installed():
$ tx update
""")
raise click.BadParameter(msg)
raise click.BadParameter(msg)


# ==================================
Expand Down Expand Up @@ -137,7 +141,8 @@ def create_txconfig():
click.echo('Create: {0}'.format(target))


def update_txconfig_resources(transifex_organization_name, transifex_project_name, locale_dir, pot_dir):
def update_txconfig_resources(transifex_organization_name, transifex_project_name,
locale_dir, pot_dir):
"""
Update resource sections of `./.tx/config`.
"""
Expand All @@ -162,7 +167,7 @@ def update_txconfig_resources(transifex_organization_name, transifex_project_nam
pot_paths = sorted(pot_dir.glob('**/*.pot'))
with click.progressbar(
pot_paths,
length = len(pot_paths),
length=len(pot_paths),
color="green",
label="adding pots...",
item_show_func=lambda p: str(p),
Expand All @@ -177,4 +182,3 @@ def update_txconfig_resources(transifex_organization_name, transifex_project_nam
subprocess.check_output(cmd, shell=False)
else:
click.echo('{0} is empty, skipped'.format(pot_path))

0 comments on commit 0084499

Please sign in to comment.