<commit_before>#!/bin/bash
# BASH_SOURCE - BASH_ARGV - BASH_LINENO - FUNCNAME

_BANG_PATH="$(dirname $(realpath ${BASH_ARGV[0]}))"
_BANG_MODULE_DIRS=("$_BANG_PATH/modules" "./modules")
_BANG_RAISED_EXCEPTION=""
_BANG_DEFAULT_CATCH=""
declare -A _BANG_CATCHED_EXCEPTIONS=()

# Return whether the argument is a valid module
# @param module - the name of the module
function is_module? () {
	resolve_module_path "$1" &>/dev/null
	return $?
}

# Adds a directory to the end of the module lookup array of directories
# @param dirname - the path for the desired directory
function append_module_dir () {
	[ -z "$1" ] && return 1
	_BANG_MODULE_DIRS+=("$1")
}

# Adds a directory to the beginning of the module lookup of directories
# @param dirname - the path for the desired directory
function prepend_module_dir () {
	[ -z "$1" ] && return 1
	_BANG_MODULE_DIRS=("$1" "${_BANG_MODULE_DIRS}")
}

# Resolves a module name for its path
# @param module - the name of the module
function resolve_module_path () {
	for path in $_BANG_MODULE_DIRS; do
		path=$(realpath "$path")
		[ -x "$path/$1.sh" ] && echo "$path/$1.sh" && return 0
	done
	return 1<commit_msg>File does not need to have +x to be sourced<commit_after>#!/bin/bash
# BASH_SOURCE - BASH_ARGV - BASH_LINENO - FUNCNAME

_BANG_PATH="$(dirname $(realpath ${BASH_ARGV[0]}))"
_BANG_MODULE_DIRS=("$_BANG_PATH/modules" "./modules")
_BANG_RAISED_EXCEPTION=""
_BANG_DEFAULT_CATCH=""
declare -A _BANG_CATCHED_EXCEPTIONS=()

# Return whether the argument is a valid module
# @param module - the name of the module
function is_module? () {
	resolve_module_path "$1" &>/dev/null
	return $?
}

# Adds a directory to the end of the module lookup array of directories
# @param dirname - the path for the desired directory
function append_module_dir () {
	[ -z "$1" ] && return 1
	_BANG_MODULE_DIRS+=("$1")
}

# Adds a directory to the beginning of the module lookup of directories
# @param dirname - the path for the desired directory
function prepend_module_dir () {
	[ -z "$1" ] && return 1
	_BANG_MODULE_DIRS=("$1" "${_BANG_MODULE_DIRS}")
}

# Resolves a module name for its path
# @param module - the name of the module
function resolve_module_path () {
	for path in $_BANG_MODULE_DIRS; do
		path=$(realpath "$path")
		[ -r "$path/$1.sh" ] && echo "$path/$1.sh" && return 0
	done
	return 1
{'fraction_non_alphanumeric': 0.12843642611683848, 'fraction_numerical': 0.010309278350515464, 'mean_word_length': 4.652912621359223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5139274', 'n_tokens_mistral': 850, 'n_tokens_neox': 818, 'n_words': 256}