Skip to content

Instantly share code, notes, and snippets.

@informationsea
Created April 9, 2016 12:53
Show Gist options
  • Save informationsea/d7d8348b1d6f8de5a1d35d47e65b8817 to your computer and use it in GitHub Desktop.
Save informationsea/d7d8348b1d6f8de5a1d35d47e65b8817 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import sys
LICENSE = '''/*
* hogehoge
* Copyright (C) 2016 NAME
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
'''
def _main():
parser = argparse.ArgumentParser(description="Header")
parser.add_argument('input', type=argparse.FileType('r'))
parser.add_argument('--inplace', '-i', action='store_true')
options = parser.parse_args()
text = LICENSE + options.input.read()
if not options.inplace:
sys.stdout.write(text)
else:
out = file(options.input.name, 'w')
out.seek(0)
out.write(text)
if __name__ == '__main__':
_main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment