From b22257b610682f09db29bb7a966efe65de21f413 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Sat, 2 Mar 2013 15:26:55 -0600 Subject: [PATCH] Added some tools to manipulate source code in bulk --- build_tools/apply_license.py | 26 ++++++++++++++++++++++++++ build_tools/gather_sources.py | 11 +++++++++++ build_tools/header.txt | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 build_tools/apply_license.py create mode 100644 build_tools/gather_sources.py create mode 100644 build_tools/header.txt diff --git a/build_tools/apply_license.py b/build_tools/apply_license.py new file mode 100644 index 0000000..2c64077 --- /dev/null +++ b/build_tools/apply_license.py @@ -0,0 +1,26 @@ +import shutil +import tempfile +import sys +import re + +rex = "@FILENAME@" + +filename = sys.argv[1] + + +fh = file("header.txt") +header = fh.read() +header_translated = re.sub(r'@FILENAME@', filename, header) +fh.close() + +f = file(filename) +lines = f.read() +f.close() + +lines = re.sub(r'(?s)/\*\+.*\+\*/','',lines) +lines = header_translated + lines + +with tempfile.NamedTemporaryFile(delete=False) as tmp_sources: + tmp_sources.write(lines) + +shutil.move(tmp_sources.name, filename) diff --git a/build_tools/gather_sources.py b/build_tools/gather_sources.py new file mode 100644 index 0000000..b4fed6c --- /dev/null +++ b/build_tools/gather_sources.py @@ -0,0 +1,11 @@ +from git import Repo + +repo = Repo(".") + +assert repo.bare == False + +t = repo.tree() + + +for entry in t.travers(): + print entry diff --git a/build_tools/header.txt b/build_tools/header.txt new file mode 100644 index 0000000..fa4e972 --- /dev/null +++ b/build_tools/header.txt @@ -0,0 +1,19 @@ +/*+ + VIDE -- Void IDEntification pipeline -- @FILENAME@ + Copyright (C) 2010-2013 Guilhem Lavaux + Copyright (C) 2011-2013 Paul M. Sutter + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ++*/