mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #3669: gettext builder fails with "ValueError: substring not found"
This commit is contained in:
parent
50609f2000
commit
f8b58e41cd
1
CHANGES
1
CHANGES
@ -16,6 +16,7 @@ Bugs fixed
|
|||||||
----------
|
----------
|
||||||
|
|
||||||
* #3661: sphinx-build crashes on parallel build
|
* #3661: sphinx-build crashes on parallel build
|
||||||
|
* #3669: gettext builder fails with "ValueError: substring not found"
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
--------
|
--------
|
||||||
|
@ -194,14 +194,18 @@ ltz = LocalTimeZone()
|
|||||||
def should_write(filepath, new_content):
|
def should_write(filepath, new_content):
|
||||||
if not path.exists(filepath):
|
if not path.exists(filepath):
|
||||||
return True
|
return True
|
||||||
with open(filepath, 'r', encoding='utf-8') as oldpot: # type: ignore
|
try:
|
||||||
old_content = oldpot.read()
|
with open(filepath, 'r', encoding='utf-8') as oldpot: # type: ignore
|
||||||
old_header_index = old_content.index('"POT-Creation-Date:')
|
old_content = oldpot.read()
|
||||||
new_header_index = new_content.index('"POT-Creation-Date:')
|
old_header_index = old_content.index('"POT-Creation-Date:')
|
||||||
old_body_index = old_content.index('"PO-Revision-Date:')
|
new_header_index = new_content.index('"POT-Creation-Date:')
|
||||||
new_body_index = new_content.index('"PO-Revision-Date:')
|
old_body_index = old_content.index('"PO-Revision-Date:')
|
||||||
return ((old_content[:old_header_index] != new_content[:new_header_index]) or
|
new_body_index = new_content.index('"PO-Revision-Date:')
|
||||||
(new_content[new_body_index:] != old_content[old_body_index:]))
|
return ((old_content[:old_header_index] != new_content[:new_header_index]) or
|
||||||
|
(new_content[new_body_index:] != old_content[old_body_index:]))
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user