symbolic links not followed during extract
Problem
Python files that are under symlinked directories are not processed by pybabel.
Expected result
The ** glob pattern in the configuration file instructs pybabel to traverse recursively all sub-directories, including symbolic links.
Am I missing some option in my configuration or command line or is this a bug/missing feature? Thank you.
Background
- My python project has a complex structure that includes symbolic links to other directories and files.
- I want to extract a template file for all translation strings in the project including those under directories that are sym-linked.
- My configuration line includes
[python: **.py]. - I am on Debian Linux.
I looked at the source code and realized that at the core of the traversal is function extract_from_dir which uses os.walk to traverse the directory. os.walk by default does not traverse symlinks. But it has a parameter followlinks that can be used to instruct it to follow them.
Since I needed this feature I went ahead and added an optional follow-links parameter in extract_from_dir and frontend. Now passing follow_links=True or --follow-links respectively one is able to tell babel to instruct os.walk to follow symbolic links. If no parameter is passed babel defaults to not follow links, just as before so this new feature should not impact any existing code or workflows.
I made a PR with the new feature #1212 , including documentation and a unit test.