Commit fda677d6 authored by Alexander Bock's avatar Alexander Bock
Browse files

Remove unused coding scripts

parent c206da4a
Showing with 0 additions and 297 deletions
+0 -297
"""
OpenSpace
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This script traverses the file tree of OpenSpace and converts all tabs into spaces.
If this script is executed from the base directory of OpenSpace, no arguments need to
be passed, otherwise the first and only argument has to point to the base directory.
Thus, the default value of the first argument is '.'
"""
import glob
import sys
basePath = './'
if len(sys.argv) > 1:
basePath = sys.argv[1] + '/'
positivePathList = [
'src/**/*.cpp',
'src/**/*.inl',
'include/**/*.h',
'include/**/*.inl',
'apps/**/*.cpp',
'apps/**/*.h',
'apps/**/*.inl',
'modules/**/*.cpp',
'modules/**/*.h',
'modules/**/*.inl',
'modules/**/*.glsl',
'ext/ghoul/src/**/*.cpp',
'ext/ghoul/include/**/*.h',
'ext/ghoul/include/**/*.inl',
'shaders/**/*.glsl',
'shaders/**/*.hglsl',
'shaders/**/*.vert',
'shaders/**/*.gs',
'shaders/**/*.frag',
'data/**/*.mod'
]
negativePathList = [
'modules/**/ext/**',
'apps/**/ext/**'
]
def convertFile(file):
result = False
with open(file, 'r+') as f:
lines = f.readlines()
for l in lines:
if l.find('\t') != -1:
result = True
break
if result:
lines[:] = [l.replace('\t', ' ') for l in lines]
# print(lines)
f.seek(0)
f.writelines(lines)
f.truncate()
return result
# Collect all the files that we might apply this script to
files = []
for p in positivePathList:
f = glob.glob(basePath + p, recursive=True)
files = files + f
# Collect all files that we want to remove from the full list
# These are mostly the external directories from modules
negativeFiles = []
for p in negativePathList:
f = glob.glob(basePath + p, recursive=True)
negativeFiles = negativeFiles + f
# Actually remove the negative files from the positive ones
files = [f for f in files if f not in negativeFiles]
totalNumber = 0
for f in files:
hasChanged = convertFile(f)
if hasChanged:
print("Changed tabs to spaces in " + f)
totalNumber = totalNumber + 1
print("Total number of changed files: " + str(totalNumber))
sys.exit(totalNumber)
\ No newline at end of file
"""
OpenSpace
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file takes the output of compiling in Visual Studio with /showIncludes enabled and
counts the number of times that each header file is included (excluding system headers).
This gives an indicator as to which header files can be made more efficient the most
efficiently
The script requires one argument, which is the text file of one or many runs of the
Visual Studio compiler
"""
import sys
if len(sys.argv) != 2:
print("Usage: count_includes.py <text file containing /showIncludes results")
exit(0)
file = sys.argv[1]
with open(file) as f:
lines = f.readlines()
# Only get the lines that actually have includes
lines = [l for l in lines if "Note: including file" in l]
# Prefix to remove from each line an
prefix = "> Note: including file:"
lines = [l[l.find(prefix) + len(prefix):-1].strip() for l in lines]
# Remove system header
lines = [l for l in lines if "windows kits" not in l.lower()]
lines = [l for l in lines if "microsoft visual studio " not in l.lower()]
lines = [l for l in lines if "boost\\include\\boost-" not in l.lower()]
# Remove external headers
lines = [l for l in lines if "ghoul\\ext\\" not in l.lower()]
count = {}
for l in lines:
if l in count:
count[l] = count[l] + 1
else:
count[l] = 1
for key, value in sorted(count.iteritems(), key=lambda (k,v): (v,k)):
print("%s: %s" % (key.ljust(100), value))
"""
OpenSpace
Copyright (c) 2014-2020
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This script creates new files for use in individual modules. The files are created in the
current working directory. The script will ask for required parameters interactively.
"""
import sys
Project = {
'OpenSpace Core': 'OpenSpace',
'OpenSpace Module': 'OpenSpace',
'Ghoul': 'Ghoul'
}
License = {
'OpenSpace': '/*****************************************************************************************\n * *\n * OpenSpace *\n * *\n * Copyright (c) 2014-2022 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/',
'Ghoul': '/*****************************************************************************************\n * *\n * GHOUL *\n * General Helpful Open Utility Library *\n * *\n * Copyright (c) 2012-2020 *\n * *\n * Permission is hereby granted, free of charge, to any person obtaining a copy of this *\n * software and associated documentation files (the "Software"), to deal in the Software *\n * without restriction, including without limitation the rights to use, copy, modify, *\n * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *\n * permit persons to whom the Software is furnished to do so, subject to the following *\n * conditions: *\n * *\n * The above copyright notice and this permission notice shall be included in all copies *\n * or substantial portions of the Software. *\n * *\n * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *\n * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *\n * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *\n * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *\n * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *\n ****************************************************************************************/'
}
Namespace = {
'OpenSpace': 'openspace',
'Ghoul': 'ghoul'
}
def buildIncludeGuard(information):
Include = {
'OpenSpace Core': 'OPENSPACE_CORE',
'OpenSpace Module': 'OPENSPACE_MODULE',
'Ghoul': 'GHOUL'
}
if information.module:
# If there is a module name
m = information.module.upper()
beg = Include[information.project] + '_' + m
end = information.className.upper()
return '__' + beg + '___' + end + '___H__'
else:
# If there is no module name
beg = Include[information.project]
end = information.className.upper()
return '__' + beg + '___' + end + '___H__'
class FileInformation:
def __init__(self):
# Input variables
self.project = ''
self.module = ''
self.className = ''
# Derived variables
def deriveValues(self):
self.license = License[Project[self.project]]
self.namespace = Namespace[Project[self.project]]
self.filename = self.className.lower()
self.includeGuard = buildIncludeGuard(self)
def writeFiles(self):
# Header file
header = open(self.filename + '.h', 'w')
header.write(self.license + '\n')
header.write('\n')
header.write('#ifndef ' + self.includeGuard + '\n')
header.write('#define ' + self.includeGuard + '\n')
header.write('\n')
header.write('namespace ' + self.namespace + ' {\n')
header.write('\n\n\n')
header.write('} // namespace ' + self.namespace + '\n')
header.write('\n')
header.write('#endif // ' + self.includeGuard)
header.write('\n')
header.close()
source = open(self.filename + '.cpp', 'w')
source.write(self.license + '\n')
source.write('\n')
source.write('#include "' + self.filename + '.h' + '"\n')
source.write('\n')
source.write('namespace ' + self.namespace + ' {\n')
source.write('\n\n\n')
source.write('} // namespace ' + self.namespace)
source.write('\n')
source.close()
i = FileInformation()
p = int(input('Project (1: OpenSpace Core; 2: OpenSpace Module; 3: Ghoul): '))
if p == 1:
i.project = "OpenSpace Core"
elif p == 2:
i.project = "OpenSpace Module"
i.module = input('Module name: ')
elif p == 3:
i.project = "Ghoul"
i.className = input('Class name: ')
i.deriveValues()
i.writeFiles()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment