<commit_before>#!/usr/bin/python
# This script walks recursivly thorugh the entire structure and wrtes a CMAkeLists.txt file where requested (using a CMakeLists.in.txt file)
import os

def isOneOf(x, lst):
	for l in lst:
		if x == l:
			return True
	return False

def makeCmakeFile(path, sub):
	cmakefile = os.path.join(path, sub)
	folder = os.path.dirname(cmakefile)
	filenameWithoutExt = os.path.basename(sub)
	varname = "autogen_"+os.path.splitext(filenameWithoutExt)[0].replace(".", "_").replace("-", "_")
	relpath = os.path.dirname(sub)
	#open as binary to force unix/linux(LF) type of lineendings on other systems than unix/linux such as windows(that uses CRLF)
	with open(cmakefile, 'wb') as f:
		f.write("# atuogenerated file from cmakegen.py through listdir\n")
		f.write("# do not edit, since this file might get overwritten\n")
		f.write("# delete the comment where this file is included to remove the autogeneration\n")
		f.write("\n")
		f.write("set ( " + varname + "\n")
		for fname in sorted(os.listdir(folder)):
			filepath = os.path.join(folder, fname)
			if os.path.isfile(filepath):
				ext = os.path.splitext(fname)[1][1:]
				if isOneOf(ext, ["c", "cpp", "cxx", "h", "hpp"]):
					print " - adding " + fname + " to " + varname
					f.write("\t" + relpath + "/" +fname+"\n")
		f.write(")\n")
	

def parseCmakeFile(path):
	cmakefile = os.path.join(path, "CMakeLists.txt")
	if os.path.exists(cmakefile):
		lastline = ""
		with open(cmakefile) as f:
			for line in f:
				line = line.strip()<commit_msg>autogenerated variables doesnt need autogen_ prefix<commit_after>#!/usr/bin/python
# This script walks recursivly thorugh the entire structure and wrtes a CMAkeLists.txt file where requested (using a CMakeLists.in.txt file)
import os

def isOneOf(x, lst):
	for l in lst:
		if x == l:
			return True
	return False

def makeCmakeFile(path, sub):
	cmakefile = os.path.join(path, sub)
	folder = os.path.dirname(cmakefile)
	filenameWithoutExt = os.path.basename(sub)
	varname = os.path.splitext(filenameWithoutExt)[0].replace(".", "_").replace("-", "_")
	relpath = os.path.dirname(sub)
	#open as binary to force unix/linux(LF) type of lineendings on other systems than unix/linux such as windows(that uses CRLF)
	with open(cmakefile, 'wb') as f:
		f.write("# atuogenerated file from cmakegen.py through listdir\n")
		f.write("# do not edit, since this file might get overwritten\n")
		f.write("# delete the comment where this file is included to remove the autogeneration\n")
		f.write("\n")
		f.write("set ( " + varname + "\n")
		for fname in sorted(os.listdir(folder)):
			filepath = os.path.join(folder, fname)
			if os.path.isfile(filepath):
				ext = os.path.splitext(fname)[1][1:]
				if isOneOf(ext, ["c", "cpp", "cxx", "h", "hpp"]):
					print " - adding " + fname + " to " + varname
					f.write("\t" + relpath + "/" +fname+"\n")
		f.write(")\n")
	

def parseCmakeFile(path):
	cmakefile = os.path.join(path, "CMakeLists.txt")
	if os.path.exists(cmakefile):
		lastline = ""
		with open(cmakefile) as f:
			for line in f:
				line = line.strip()
{'fraction_non_alphanumeric': 0.15161395500489078, 'fraction_numerical': 0.0019563090968373, 'mean_word_length': 3.9805194805194803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1485431', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1106, 'n_words': 312}