def buildHeaderPair(self, file): base, ext = os.path.splitext(file) header = base + ".h" cppfile = base + ".cpp" headerInclude = self.name + "/" + header guard = cpp.buildGuard(headerInclude) log("guard: " + guard) with open(self.directory + "\\" + header, "w+") as h: h.write("#ifndef __{0}__\n".format(guard)) h.write("#define __{0}__\n".format(guard)) h.write("#pragma once\n\n") h.write("#endif //__{0}__".format(guard)) with open(self.directory + "\\" + cppfile, "w+") as c: c.write('#include "{0}"'.format(headerInclude)) return (header, cpp)
def gatherFilesHelper(path): filesSet = set() filesSet |= set(glob.glob("{0}\*.h".format(path))) filesSet |= set(glob.glob("{0}\*.hpp".format(path))) [cpp.fixGuard(x, "", cpp.buildGuard("\\".join(x.split("\\")[1:]))) for x in filesSet] filesSet |= set(glob.glob("{0}\*.c".format(path))) filesSet |= set(glob.glob("{0}\*.cc".format(path))) filesSet |= set(glob.glob("{0}\*.cpp".format(path))) filesSet |= set(glob.glob("{0}\*.rc".format(path))) filesSet |= set(glob.glob("{0}\*.compil".format(path))) filesSet |= set(glob.glob("{0}\*.scompil".format(path))) filesSet |= set(glob.glob("{0}\*.compilprj".format(path))) filesSet |= set(glob.glob("{0}\*.scompilprj".format(path))) filesSet |= set(glob.glob("{0}\*.bat".format(path))) for root, dirs, files in os.walk(path): for d in dirs: filesSet |= gatherFilesHelper(os.path.join(root, d)) return filesSet