From 225eb2174daec7eba615b9d64eebbd9c7d0d904c Mon Sep 17 00:00:00 2001 From: sebleblanc Date: Tue, 3 Dec 2019 04:45:42 +0000 Subject: [PATCH] Hardcode "ignore" method 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. --- babel/messages/extract.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/babel/messages/extract.py b/babel/messages/extract.py index db429b2ea..6c1abe0d8 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -236,9 +236,12 @@ def extract_from_file(method, filename, keywords=DEFAULT_KEYWORDS, :returns: list of tuples of the form ``(lineno, message, comments, context)`` :rtype: list[tuple[int, str|tuple[str], list[str], str|None] """ - with open(filename, 'rb') as fileobj: - return list(extract(method, fileobj, keywords, comment_tags, options, - strip_comment_tags)) + if method == 'ignore': + return [] + else: + with open(filename, 'rb') as fileobj: + return list(extract(method, fileobj, keywords, comment_tags, + options, strip_comment_tags)) def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),