<commit_before># Package management

function cleanEnabled
{
	testDir="$2"
	testFunction="$1"
	
	cd "$testDir"
	for item in *;do
		if ! $testFunction "$item"; then
			echo "$item is no longer present. Disabling."
			rm "$item"
		fi
		cd "$testDir"
	done
}

function testEnabledFile
{
	item="$1"
	cat "$item" 1>/dev/null 2>&1
	return $?
}

function testEnabledDirectory
{
	item="$1"
	cd "$item" 1>/dev/null 2>&1
	return $?
}

function createProfile
{
	name="$1"
	mkdir -p $configDir/profiles/$name/{packages,modules,macros,templates}
}

function removeProfile
{
	name="$1"
	profileToRemove="$configDir/profiles/$name"
	if [ -d "$profileToRemove" ]; then
		rm -Rf "$profileToRemove"
	elif [ -h "$profileToRemove" ]; then
		rm -f "$profileToRemove"
	else
		echo "Could not find a profile called \"$name\". I looked in \"$profileToRemove\""
	fi
}

function enableEverythingForProfile
{
	name="$1"
	repo=${2:-mass}
	
	start=`pwd`
	for thing in $things; do
		cd $configDir/profiles/$name/$thing
		if [ `ls $configDir/repos/$repo/$thing-available|wc -l 2> /dev/null` -gt 0 ]; then
			while read item;do
				if [ "$thing" == 'packages' ]; then
					if [ -e "$repo-$item" ]; then
						true
					elif [ ! -e $item ]; then
						ln -sf "$configDir/repos/$repo/$thing-available/$item" .
						mv "$item" "$repo-$item"
					elif [ "$repo" == 'mass' ]; then # Migrate old naming to new naming.
						mv "$item" "$repo-$item"
					fi
				else
					ln -sf "$configDir/repos/$repo/$thing-available/$item" .
				fi
			done < <(ls $configDir/repos/$repo/$thing-available)
		fi
	done
	
	cd $start
}

function enableItemInProfile
{
	profile="$1"
	itemType="$2" # package,module,macro,template
	item="$3" # AWS,SSH
	
	cd $configDir/profiles/$profile/$itemType
	if [ -e $configDir/profiles/$profile/$itemType/$item ]; then
		ln -sf $configDir/profiles/$profile/$itemType/$item .
	else
		echo "enableItemInProfile: Could not find $configDir/profiles/$profile/$itemType/$item" 1>&2
	fi
}

function disableItemInProfile
{
	profile="$1"
	itemType="$2" # package,module,macro,template
	item="$3" # AWS,SSH
	
	cd $configDir/profiles/$profile/$itemType
	if [ -e $configDir/profiles/$profile/$itemType/$item ]; then
		rm $configDir/profiles/$profile/$itemType/$item
	else
		echo "disableItemInProfile: Could not find $configDir/profiles/$profile/$itemType/$item" 1>&2
	fi
}

function cloneProfile
{
	from="$1"
	to="$2"
	
	cd $configDir/profiles
	rm -Rf "$to"
	cp -R "$from" "$to"
}

function cleanProfile
{
	name="$1"
	
	for thing in $fileThings;do
		cleanEnabled testEnabledFile "$configDir/profiles/$name/$thing"
	done
	
	for thing in $directoryThings;do
		cleanEnabled testEnabledDirectory "$configDir/profiles/$name/$thing"
	done
}
<commit_msg>Install: Added profileName to output when disabling packages.<commit_after># Package management

function cleanEnabled
{
	testDir="$2"
	testFunction="$1"
	profileName="$3"
	
	cd "$testDir"
	for item in *;do
		if ! $testFunction "$item"; then
			echo "$item is no longer present. Disabling in profile \"$profileName\"."
			rm "$item"
		fi
		cd "$testDir"
	done
}

function testEnabledFile
{
	item="$1"
	cat "$item" 1>/dev/null 2>&1
	return $?
}

function testEnabledDirectory
{
	item="$1"
	cd "$item" 1>/dev/null 2>&1
	return $?
}

function createProfile
{
	name="$1"
	mkdir -p $configDir/profiles/$name/{packages,modules,macros,templates}
}

function removeProfile
{
	name="$1"
	profileToRemove="$configDir/profiles/$name"
	if [ -d "$profileToRemove" ]; then
		rm -Rf "$profileToRemove"
	elif [ -h "$profileToRemove" ]; then
		rm -f "$profileToRemove"
	else
		echo "Could not find a profile called \"$name\". I looked in \"$profileToRemove\""
	fi
}

function enableEverythingForProfile
{
	name="$1"
	repo=${2:-mass}
	
	start=`pwd`
	for thing in $things; do
		cd $configDir/profiles/$name/$thing
		if [ `ls $configDir/repos/$repo/$thing-available|wc -l 2> /dev/null` -gt 0 ]; then
			while read item;do
				if [ "$thing" == 'packages' ]; then
					if [ -e "$repo-$item" ]; then
						true
					elif [ ! -e $item ]; then
						ln -sf "$configDir/repos/$repo/$thing-available/$item" .
						mv "$item" "$repo-$item"
					elif [ "$repo" == 'mass' ]; then # Migrate old naming to new naming.
						mv "$item" "$repo-$item"
					fi
				else
					ln -sf "$configDir/repos/$repo/$thing-available/$item" .
				fi
			done < <(ls $configDir/repos/$repo/$thing-available)
		fi
	done
	
	cd $start
}

function enableItemInProfile
{
	profile="$1"
	itemType="$2" # package,module,macro,template
	item="$3" # AWS,SSH
	
	cd $configDir/profiles/$profile/$itemType
	if [ -e $configDir/profiles/$profile/$itemType/$item ]; then
		ln -sf $configDir/profiles/$profile/$itemType/$item .
	else
		echo "enableItemInProfile: Could not find $configDir/profiles/$profile/$itemType/$item" 1>&2
	fi
}

function disableItemInProfile
{
	profile="$1"
	itemType="$2" # package,module,macro,template
	item="$3" # AWS,SSH
	
	cd $configDir/profiles/$profile/$itemType
	if [ -e $configDir/profiles/$profile/$itemType/$item ]; then
		rm $configDir/profiles/$profile/$itemType/$item
	else
		echo "disableItemInProfile: Could not find $configDir/profiles/$profile/$itemType/$item" 1>&2
	fi
}

function cloneProfile
{
	from="$1"
	to="$2"
	
	cd $configDir/profiles
	rm -Rf "$to"
	cp -R "$from" "$to"
}

function cleanProfile
{
	name="$1"
	
	for thing in $fileThings;do
		cleanEnabled testEnabledFile "$configDir/profiles/$name/$thing" "$name"
	done
	
	for thing in $directoryThings;do
		cleanEnabled testEnabledDirectory "$configDir/profiles/$name/$thing" "$name"
	done
}

{'fraction_non_alphanumeric': 0.15993508835196538, 'fraction_numerical': 0.010638297872340425, 'mean_word_length': 3.831881533101045, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '3805876', 'n_tokens_mistral': 2160, 'n_tokens_neox': 1935, 'n_words': 481}