<commit_before>#!/usr/bin/env python

import os
import time
import SCons
import re
import string

from SCons.Script import *
from SCons.Script.SConscript import SConsEnvironment


SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod, lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))

def InstallPerm(env, dir, source, perm):
	obj = env.Install(dir, source)
	for i in obj:
		env.AddPostAction(i, env.Chmod(str(i), perm))
	return dir

SConsEnvironment.InstallPerm = InstallPerm

SConsEnvironment.InstallProgram = lambda env, dir, source: InstallPerm(env, dir, source, 0755)
SConsEnvironment.InstallData = lambda env, dir, source: InstallPerm(env, dir, source, 0644)


def MatchFiles (files, path, repath, dir_exclude_pattern,  file_exclude_pattern):

	for filename in os.listdir(path):
		fullname = os.path.join (path, filename)
		repath_file =  os.path.join (repath, filename);
		if os.path.isdir (fullname):
			if not dir_exclude_pattern.search(repath_file):
				MatchFiles (files, fullname, repath_file, dir_exclude_pattern, file_exclude_pattern)
		else:
			if not file_exclude_pattern.search(filename):
				files.append (fullname)

	
def GetSourceFiles(env, dir_exclude_pattern, file_exclude_pattern):
	dir_exclude_prog = re.compile(dir_exclude_pattern)
	file_exclude_prog = re.compile(file_exclude_pattern)
	files = []
	MatchFiles(files, env.GetLaunchDir(), os.sep, dir_exclude_prog, file_exclude_prog)
	return files
	
def GetVersionInfo(env):
	revision = os.popen('svnversion -n %s' % env.GetLaunchDir() ).read()
	revision=revision.replace(':','.')
	env.Replace(GPICK_BUILD_REVISION = revision,
		GPICK_BUILD_DATE =  time.strftime ("%Y-%m-%d"),
		GPICK_BUILD_TIME =  time.strftime ("%H:%M:%S"));		

def RegexEscape(str):
	return str.replace('\\', '\\\\')

def WriteNsisVersion(target, source, env):
	for t in target:
		for s in source:
			file = open(str(t),"w")
			file.writelines('!define VERSION "' + str(env['GPICK_BUILD_VERSION'])+'.'+str(env['GPICK_BUILD_REVISION']) + '"')<commit_msg>Strip P and S chars from svnversion output<commit_after>#!/usr/bin/env python

import os
import time
import SCons
import re
import string

from SCons.Script import *
from SCons.Script.SConscript import SConsEnvironment


SConsEnvironment.Chmod = SCons.Action.ActionFactory(os.chmod, lambda dest, mode: 'Chmod("%s", 0%o)' % (dest, mode))

def InstallPerm(env, dir, source, perm):
	obj = env.Install(dir, source)
	for i in obj:
		env.AddPostAction(i, env.Chmod(str(i), perm))
	return dir

SConsEnvironment.InstallPerm = InstallPerm

SConsEnvironment.InstallProgram = lambda env, dir, source: InstallPerm(env, dir, source, 0755)
SConsEnvironment.InstallData = lambda env, dir, source: InstallPerm(env, dir, source, 0644)


def MatchFiles (files, path, repath, dir_exclude_pattern,  file_exclude_pattern):

	for filename in os.listdir(path):
		fullname = os.path.join (path, filename)
		repath_file =  os.path.join (repath, filename);
		if os.path.isdir (fullname):
			if not dir_exclude_pattern.search(repath_file):
				MatchFiles (files, fullname, repath_file, dir_exclude_pattern, file_exclude_pattern)
		else:
			if not file_exclude_pattern.search(filename):
				files.append (fullname)

	
def GetSourceFiles(env, dir_exclude_pattern, file_exclude_pattern):
	dir_exclude_prog = re.compile(dir_exclude_pattern)
	file_exclude_prog = re.compile(file_exclude_pattern)
	files = []
	MatchFiles(files, env.GetLaunchDir(), os.sep, dir_exclude_prog, file_exclude_prog)
	return files
	
def GetVersionInfo(env):
	revision = os.popen('svnversion -n %s' % env.GetLaunchDir() ).read()
	revision=revision.replace(':','.')
	revision=revision.replace('P','')
	revision=revision.replace('S','')
	env.Replace(GPICK_BUILD_REVISION = revision,
		GPICK_BUILD_DATE =  time.strftime ("%Y-%m-%d"),
		GPICK_BUILD_TIME =  time.strftime ("%H:%M:%S"));		

def RegexEscape(str):
	return str.replace('\\', '\\\\')

def WriteNsisVersion(target, source, env):
	for t in target:
		for s in source:
			file = open(str(t),"w")
			file.writelines('!define VERSION "' + str(env['GPICK_BUILD_VERSION'])+'.'+str(env['GPICK_BUILD_REVISION']) + '"')
{'fraction_non_alphanumeric': 0.13608748481166463, 'fraction_numerical': 0.004374240583232078, 'mean_word_length': 5.660194174757281, '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': '3572206', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1426, 'n_words': 321}