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

Hardcode "ignore" method #678

Closed
wants to merge 1 commit into from
Closed

Hardcode "ignore" method #678

wants to merge 1 commit into from

Conversation

sebleblanc
Copy link
Contributor

@sebleblanc sebleblanc commented Dec 3, 2019

The "ignore" method forces the opening of a file, but this is pointless.

Some editors (emacs) create symbolic links to use as synchronization locks. These links have an extension that matches the opened file, but the links themselves do not point to an existing file, thus causing Babel to attempt to open a file that does not exist.

For example, on my machine, I have a file opened in my editor (project/i18n.py) resulting in the following link being created:

.#i18n.py -> sebleblanc@host.11171:1575144024

Babel will catch this file with the default **.py mapping, so I created a mapping with the pattern [ignore: **/.*] thinking it would ignore all files beginning with a dot, but instead, it pointlessly attempts to open such files and pass them through a "no-op" processor. Since it does not discriminate against links, this results in a FileNotFoundError, aborting extraction of all messages.

This fix skips opening of a file altogether when using the method "ignore" in the mapping file, by short-circuiting the extract_from_file function when the method matches "ignore".

Maybe Babel should by default silently skip a file when:

  • it raises FileNotFoundError
  • it is a symlink

The "ignore" method used to force the opening of the file. Some editors (emacs) create symbolic links to use as synchronization locks. Those links have an extension that matches the opened file, but the links themselves do not point to an existing file, thus causing Babel to attempt to open a file that does not exist.

This fix skips opening of a file altogether when using the method "ignore" in the mapping file.
Copy link
Member

@akx akx left a comment

Aside from that else: nitpick, this looks good, thank you!

babel/messages/extract.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants