Permalink
Browse files

=

  • Loading branch information...
stnbu committed Sep 29, 2018
1 parent a2b0893 commit 3159e3981084479f0cb5fca7de6ec68bfdad4880
Showing with 4 additions and 4 deletions.
  1. +4 −4 patch.py
@@ -15,15 +15,15 @@ def patch_files(paths):
# not perfect, but perfect enough
name_main_re = re.compile('.*if.* .*__name__.*==.*__main__')
for path in paths:
wrote = False
orig = open(path, 'r')
with open(path+'.new', 'w') as new:
for line in orig:
if name_main_re.match(line):
new.write(magic)
new.write(line)
else:
new.write(line)
else:
wrote = True
new.write(line)
if not wrote:
new.write(magic)
orig.close()

0 comments on commit 3159e39

Please sign in to comment.