Skip to content

Commit 1580fad

Browse files
committed
autopatch_capi.py: fix applying to one file
1 parent 8c1b512 commit 1580fad

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

graalpython/lib-graalpython/modules/autopatch_capi.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def consume_whitespace_forward(idx):
165165

166166
def auto_patch(path, dryrun):
167167
"reads the given file, applies all replacements, and writes back the result if there were changes"
168-
168+
169169
with open(path, mode='r') as f:
170170
try:
171171
contents = f.read()
@@ -201,11 +201,16 @@ def auto_patch(path, dryrun):
201201

202202

203203
def auto_patch_tree(location, dryrun=False):
204-
for root, dirs, files in os.walk(location):
205-
for name in files:
206-
if '.c' in name or '.h' in name or '.inc' in name:
207-
path = os.path.join(root, name)
208-
auto_patch(path, dryrun)
204+
if os.path.isfile(location):
205+
files = [location]
206+
else:
207+
files = [os.path.join(root, name)
208+
for root, dirs, files in os.walk(location)
209+
for name in files]
210+
211+
for path in files:
212+
if '.c' in path or '.h' in path or '.inc' in path:
213+
auto_patch(path, dryrun)
209214

210215

211216
if __name__ == "__main__":

0 commit comments

Comments
 (0)