From 159004bc7f70615d7bcc9469b86131fef1dcf147 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Sat, 9 Sep 2017 08:33:55 +0100 Subject: removed sourceme and added tools --- tools/add_version_headers | 94 +++++++++++++++++++++++++++++++++++++++++++++++ tools/update_docs | 27 ++++++++++++++ 2 files changed, 121 insertions(+) create mode 100755 tools/add_version_headers create mode 100755 tools/update_docs (limited to 'tools') diff --git a/tools/add_version_headers b/tools/add_version_headers new file mode 100755 index 00000000..def7d55a --- /dev/null +++ b/tools/add_version_headers @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# ----------------------------------------------------------------------------- +# add_version_headers +# +# Add version header +# +# Copyright (c) 2017 Yann Herklotz Grave -- MIT License +# See file LICENSE for more details +# ----------------------------------------------------------------------------- + +"""\file add_version_headers +\brief Adds the version headers to every file. + +Add Version Headers +=================== + +This file adds the version headers to every file in the directory + + +Improvements +------------ + +Add the ability to input command line arguments. +""" + +import os +import re +import sys + + +header = """/* ---------------------------------------------------------------\ +------------- + * {0} + * + * Copyright (c) 2017 Yann Herklotz Grave + * MIT License, see LICENSE file for more details. + * ---------------------------------------------------------------------------- + */ + +""" + + +class HeaderUpdate(object): + """Updates the header in all the source and header files in the code""" + def __init__(self, **kwargs): + self.match_re = ".*[.]cpp$|.*[.]hpp$" + self.exclude_re = "^$" + self.exclude_build = True + self.exclude_dir = ".*build.*" + self.match_dir = "" + self.comment_match = "^\/[*] -+" + self.starting_dir = os.getcwd() + for key, value in kwargs.items(): + setattr(self, key, value) + + def writeHeader(self): + def writeFileOperation(filePath, src): + if not re.match(self.comment_match, src): + print(filePath, end=" ") + with open(filePath, 'w') as src_file_lic: + src_file_lic.write(header.format(filePath)) + src_file_lic.write(src) + print("-- done") + + self._traverseDir(self.starting_dir, writeFileOperation) + + def updateHeader(self): + ... + + def removeHeader(self): + ... + + def _traverseDir(self, path, fileOperation): + for subdir, dirs, files in os.walk(os.getcwd()): + if (not re.match(self.exclude_dir, subdir)) and \ + (re.match(self.match_dir, subdir)): + for fileName in files: + if (re.match(self.match_re, fileName)) and \ + (not re.match(self.exclude_re, fileName)): + with open(os.path.join(subdir, fileName), 'r') \ + as src_file: + src = src_file.read() + fileOperation(os.path.join(subdir, fileName), src) + + +def main(argv): + update = HeaderUpdate(exclude_re="^picopng[.]cpp", + exclude_dir=".*build.*|.*google.*", + match_dir=".*src.*|.*include.*|.*test.*") + update.writeHeader() + + +if __name__ == "__main__": + main(sys.argv) diff --git a/tools/update_docs b/tools/update_docs new file mode 100755 index 00000000..113fe39e --- /dev/null +++ b/tools/update_docs @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +printf "running doxygen on all files in %s: " $( pwd ) +doxygen ./docs/Doxyfile >/dev/null 2>&1 +printf "Done\n" +printf "cloning gh-pages from git@github.com:ymherklotz/YAGE: " +git clone -b gh-pages git@github.com:ymherklotz/YAGE >/dev/null 2>&1 +printf "Done\n" +printf "updating repository: " +cd YAGE/ >/dev/null 2>&1 +git rm -rf * >/dev/null 2>&1 +mv ../html/* . >/dev/null 2>&1 +rm -rf ../html >/dev/null 2>&1 +printf "Done\n" +printf "adding files: " +git add -A >/dev/null 2>&1 +printf "Done\n" +printf "commiting files: " +git commit -a -m 'Updating docs' >/dev/null 2>&1 +printf "Done\n" +printf "pushing commit: " +git push origin gh-pages >/dev/null 2>&1 +printf "Done\n" +printf "cleaning up files: " +cd .. >/dev/null 2>&1 +rm -rf YAGE >/dev/null 2>&1 +printf "Done\n" -- cgit