Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a20f90

Browse files
Alternative implementation
1 parent15bf463 commit2a20f90

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

‎Tools/clinic/clinic.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,11 +1975,7 @@ def file_changed(filename: str, new_contents: str) -> bool:
19751975
returnTrue
19761976

19771977

1978-
defwrite_file(filename:str,new_contents:str,force=False):
1979-
ifnotforceandnotfile_changed(filename,new_contents):
1980-
# no change: avoid modifying the file modification time
1981-
return
1982-
1978+
defwrite_file(filename:str,new_contents:str):
19831979
# Atomic write using a temporary file and os.replace()
19841980
filename_new=f"{filename}.new"
19851981
withopen(filename_new,"w",encoding="utf-8")asfp:
@@ -2241,11 +2237,12 @@ def parse_file(filename, *, verify=True, output=None):
22412237
clinic=Clinic(language,verify=verify,filename=filename)
22422238
src_out,clinic_out=clinic.parse(raw)
22432239

2244-
# If clinic output changed, force updating the source file as well.
2245-
force=any(file_changed(fn,data)forfn,datainclinic_out)
2246-
write_file(output,src_out,force=force)
2247-
forfn,datainclinic_out:
2248-
write_file(fn,data)
2240+
changes= [(fn,data)forfn,datainclinic_outiffile_changed(fn,data)]
2241+
ifchanges:
2242+
# Always (re)write the source file.
2243+
write_file(output,src_out)
2244+
forfn,datainclinic_out:
2245+
write_file(fn,data)
22492246

22502247

22512248
defcompute_checksum(input,length=None):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp