Skip to content

Instantly share code, notes, and snippets.

@chrrrles
Created September 6, 2013 05:58
Show Gist options
  • Save chrrrles/6460052 to your computer and use it in GitHub Desktop.
Save chrrrles/6460052 to your computer and use it in GitHub Desktop.
preamble = """# Copyright (c) 2013 - The C3PX authors.
#
# This file is part of C3PX.
#
# C3PX is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# C3PX is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License along with C3PX. If not, see <http://www.gnu.org/licenses/>.
"""
import os
def preambling():
numlines = preamble.splitlines()
for root, dirs, files in os.walk('./'):
for name in files:
if os.path.splitext(name)[1].lower() == ".py":
pyfile = open(os.path.join(root,name),'r+')
old = pyfile.read()
if old.splitlines()[:numlines] != preamble.splitlines():
pyfile.seek(0)
pyfile.write(preamble + old)
if __name__ == "__main__":
preambling()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment