Skip to content

Instantly share code, notes, and snippets.

@andymitchhank
Last active August 29, 2015 14:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andymitchhank/293eb1c6c665bf15d7ae to your computer and use it in GitHub Desktop.
Save andymitchhank/293eb1c6c665bf15d7ae to your computer and use it in GitHub Desktop.
import os
# your xcode project directory
directory = ''
for root, _, files in os.walk(directory):
for f in files:
edited = False
fullpath = os.path.join(root, f)
with open(fullpath, 'r') as open_file:
contents = open_file.read()
if contents[:3] == "'''" or contents[:3] == '"""':
edited = True
contents = "#dummycomment\n" + contents
if contents[:2] == '#!':
edited = True
contents = contents.splitlines(True)
contents[0] = '#dummycomment\n'
contents = ''.join(contents)
if edited:
with open(fullpath, 'w') as open_file:
open_file.write(contents)
print "Done"
@highfestiva
Copy link

Made my night, thanks!

@fedry
Copy link

fedry commented May 13, 2015

Thank you so much! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment