summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebleblanc <seb@sebleblanc.net>2019-12-03 04:45:42 +0000
committerAarni Koskela <akx@iki.fi>2019-12-31 11:47:59 +0200
commitc42bc9e907d638b368d07a326daa841e4a0bd691 (patch)
tree7bcc58026dc326f87f54bbf25753173bf08078df
parentdf9c01c6480ef20523418079b6774612e47b8c63 (diff)
downloadbabel-c42bc9e907d638b368d07a326daa841e4a0bd691.tar.gz
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.
-rw-r--r--babel/messages/extract.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/babel/messages/extract.py b/babel/messages/extract.py
index db429b2..e7d7ad7 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]
"""
+ if method == 'ignore':
+ return []
+
with open(filename, 'rb') as fileobj:
- return list(extract(method, fileobj, keywords, comment_tags, options,
- strip_comment_tags))
+ return list(extract(method, fileobj, keywords, comment_tags,
+ options, strip_comment_tags))
def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),