@@ -1943,12 +1943,12 @@ def dump(self):
1943
1943
return_converters = {}
1944
1944
1945
1945
1946
- def write_file (filename , new_contents ):
1946
+ def write_file (filename , new_contents , force = False ):
1947
1947
try :
1948
1948
with open (filename , 'r' , encoding = "utf-8" ) as fp :
1949
1949
old_contents = fp .read ()
1950
1950
1951
- if old_contents == new_contents :
1951
+ if old_contents == new_contents and not force :
1952
1952
# no change: avoid modifying the file modification time
1953
1953
return
1954
1954
except FileNotFoundError :
@@ -2112,6 +2112,8 @@ def parse(self, input):
2112
2112
traceback .format_exc ().rstrip ())
2113
2113
printer .print_block (block )
2114
2114
2115
+ clinic_out = []
2116
+
2115
2117
# these are destinations not buffers
2116
2118
for name , destination in self .destinations .items ():
2117
2119
if destination .type == 'suppress' :
@@ -2151,10 +2153,11 @@ def parse(self, input):
2151
2153
block .input = 'preserve\n '
2152
2154
printer_2 = BlockPrinter (self .language )
2153
2155
printer_2 .print_block (block , core_includes = True )
2154
- write_file (destination .filename , printer_2 .f .getvalue ())
2156
+ pair = destination .filename , printer_2 .f .getvalue ()
2157
+ clinic_out .append (pair )
2155
2158
continue
2156
2159
2157
- return printer .f .getvalue ()
2160
+ return printer .f .getvalue (), clinic_out
2158
2161
2159
2162
2160
2163
def _module_and_class (self , fields ):
@@ -2210,9 +2213,12 @@ def parse_file(filename, *, verify=True, output=None):
2210
2213
return
2211
2214
2212
2215
clinic = Clinic (language , verify = verify , filename = filename )
2213
- cooked = clinic .parse (raw )
2216
+ src_out , clinic_out = clinic .parse (raw )
2214
2217
2215
- write_file (output , cooked )
2218
+ force = bool (clinic_out )
2219
+ write_file (output , src_out , force = force )
2220
+ for fn , data in clinic_out :
2221
+ write_file (fn , data )
2216
2222
2217
2223
2218
2224
def compute_checksum (input , length = None ):
0 commit comments