Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand file globs in command line arguments #82

Open
mauritsvanrees opened this issue Oct 27, 2020 · 1 comment
Open

Expand file globs in command line arguments #82

mauritsvanrees opened this issue Oct 27, 2020 · 1 comment

Comments

@mauritsvanrees
Copy link
Member

This command works, because the shell automatically expands the star before passing it to i18ndude:

i18ndude sync --pot locales/plone.pot locales/*/LC_MESSAGES/plone.po

The same command in tox fails, because tox does not do expansion:

$ cat tox.ini
...
[testenv:locales]
basepython = python3
skip_install = true
deps =
    i18ndude
commands =
    i18ndude sync --pot locales/plone.pot locales/*/LC_MESSAGES/plone.po
$ tox -e locales
...
locales run-test: commands[1] | i18ndude sync --pot locales/plone.pot 'locales/*/LC_MESSAGES/plone.po'
Warning: locales/*/LC_MESSAGES/plone.po is not a file or is ignored.

When I replace the star with nl the tox command works fine for the Dutch locale.

See https://stackoverflow.com/a/62113401/621201, also for basic glob code example.

@mauritsvanrees
Copy link
Member Author

I just noticed that since Python 3.5, ** is supported by glob. Trying it out:

$ ls **/*.po
ls: **/*.po: No such file or directory
$ python -i **/*.po
python: can't open file '.../plone/app/locales/**/*.po': [Errno 2] No such file or directory
>>> import glob
>>> import sys
>>> sys.argv
['**/*.po']
>>> glob.glob(sys.argv[0])
[]
>>> glob.glob(sys.argv[0], recursive=True)
['locales/sl/LC_MESSAGES/widgets.po', ... 'locales-addons/es/LC_MESSAGES/plone.app.ldap.po']
>>> len(glob.glob(sys.argv[0], recursive=True))
472

That would mean that you could write the command like this, if we start supporting it:

i18ndude sync --pot locales/plone.pot **/plone.po

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant