Skip to content

Commit e085df3

Browse files
committed
blurb: don't overwrite output when not necessary
This speeds up doc generation. With this change, blurb won't update the NEWS file unnecessarily, which means Sphinx will then use a cache instead of parsing it again.
1 parent 0dd9f16 commit e085df3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

blurb/blurb.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from collections import OrderedDict
5050
import glob
5151
import hashlib
52+
import io
5253
import inspect
5354
import itertools
5455
import math
@@ -1068,9 +1069,11 @@ def merge(output=None, *, forced=False):
10681069

10691070

10701071
def write_news(output, *, versions):
1072+
buff = io.StringIO()
1073+
10711074
def print(*a, sep=" "):
10721075
s = sep.join(str(x) for x in a)
1073-
return builtins.print(s, file=news)
1076+
return builtins.print(s, file=buff)
10741077

10751078
print ("""
10761079
+++++++++++
@@ -1131,8 +1134,17 @@ def print(*a, sep=" "):
11311134
print(text)
11321135
print()
11331136
print("**(For information about older versions, consult the HISTORY file.)**")
1134-
news.close()
11351137

1138+
with open(output, "r", encoding="utf-8") as file:
1139+
previous_contents = file.read()
1140+
1141+
new_contents = buff.getvalue()
1142+
1143+
if new_contents != previous_contents:
1144+
with open(output, "wt", encoding="utf-8") as file:
1145+
file.write(buff.getvalue())
1146+
else:
1147+
builtins.print(output, "is already up to date")
11361148

11371149
git_add_files = []
11381150
def flush_git_add_files():

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy