<commit_before>#!/bin/bash

#Copyright (C) 2014 OpenBet Limited
#
#Permission is hereby granted, free of charge, to any person obtaining a copy 
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.

set -e

function usage {
	cat > /dev/stdout << END
$0 PATH MODULE_NAME [SCRIPT]

PATH        - absolute path to new directory for module
MODULE_NAME - name for your module
SCRIPT      - pre-existing shell script to integrate into module
END
exit
}

if [[ $0 != create_skeleton.sh ]] && [[ $0 != ./create_skeleton.sh ]]
then
	cat > /dev/stdout << END
Must be run from bin dir like:

	create_skeleton.sh <absolute_directory_name> <module_name> [<shell script to integrate>]

or

	./create_skeleton.sh <absolute_directory_name> <module_name> [<shell script to integrate>]
END
	sleep 2
	usage
fi


if [[ x$1 == "x" ]] || [[ $(echo $1 | head -c 1) != "/" ]]
then
	echo "Must supply a directory and it must be absolute"
	sleep 2
	usage
fi

if [[ -a $1 ]]
then
	echo "$1 already exists"
	sleep 2
	usage
fi

if [[ x$2 == "x" ]]
then
	echo "Must supply a name for your module, eg mymodulename"
	sleep 2
	usage
fi

# TODO: make patch
SKELETON_DIR=$1
MODULE_NAME=$2
SHUTIT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

mkdir -p ${SKELETON_DIR}
mkdir -p ${SKELETON_DIR}/configs
mkdir -p ${SKELETON_DIR}/resources
mkdir -p ${SKELETON_DIR}/bin
# Copy self to new directory.
cp ${BASH_SOURCE[0]} ${SKELETON_DIR}/bin
touch ${SKELETON_DIR}/README.md
cat >> ${SKELETON_DIR}/README.md << END
${MODULE_NAME}: description of module directory in here
END
touch ${SKELETON_DIR}/build.sh
cat >> ${SKELETON_DIR}/build.sh << END
set -e
python ${SHUTIT_DIR}/shutit_main.py
# Display config
#python ${SHUTIT_DIR}/shutit_main.py --sc
# Debug
#python ${SHUTIT_DIR}/shutit_main.py --debug
# Tutorial
#python ${SHUTIT_DIR}/shutit_main.py --tutorial
END
chmod +x ${SKELETON_DIR}/build.sh
touch ${SKELETON_DIR}/resources/README.md
cat >> ${SKELETON_DIR}/resources/README.md << END
${MODULE_NAME}: resources required in this directory, eg gzips or text files.\nNote that the .gitignore file in the ${SKELETON_DIR} directory should exclude these files from being added to git repos (usually due to size), but can be added if forced with 'git add --force <file>'.
END
touch ${SKELETON_DIR}/bin/README.md
cat ${SKELETON_DIR}/bin/README.md << END
${MODULE_NAME}: test.sh to run as part of tests in this directory
END
# Module template
cp ../docs/shutit_module_template.py ${SKELETON_DIR}/${MODULE_NAME}.py
perl -p -i -e "s/template/${MODULE_NAME}/g" ${SKELETON_DIR}/${MODULE_NAME}.py
perl -p -i -e "s/GLOBALLY_UNIQUE_STRING/'com.mycorp.${MODULE_NAME}'/g" ${SKELETON_DIR}/${MODULE_NAME}.py<commit_msg>removed some extraneous work from cs<commit_after>#!/bin/bash

#Copyright (C) 2014 OpenBet Limited
#
#Permission is hereby granted, free of charge, to any person obtaining a copy 
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in
#all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#SOFTWARE.

set -e

function usage {
	cat > /dev/stdout << END
$0 PATH MODULE_NAME [SCRIPT]

PATH        - absolute path to new directory for module
MODULE_NAME - name for your module
SCRIPT      - pre-existing shell script to integrate into module
END
exit
}

if [[ $0 != create_skeleton.sh ]] && [[ $0 != ./create_skeleton.sh ]]
then
	cat > /dev/stdout << END
Must be run from bin dir like:

	create_skeleton.sh <absolute_directory_name> <module_name> [<shell script to integrate>]

or

	./create_skeleton.sh <absolute_directory_name> <module_name> [<shell script to integrate>]
END
	sleep 2
	usage
fi


if [[ x$1 == "x" ]] || [[ $(echo $1 | head -c 1) != "/" ]]
then
	echo "Must supply a directory and it must be absolute"
	sleep 2
	usage
fi

if [[ -a $1 ]]
then
	echo "$1 already exists"
	sleep 2
	usage
fi

if [[ x$2 == "x" ]]
then
	echo "Must supply a name for your module, eg mymodulename"
	sleep 2
	usage
fi

# TODO: make patch
SKELETON_DIR=$1
MODULE_NAME=$2
SHUTIT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.."

mkdir -p ${SKELETON_DIR}
mkdir -p ${SKELETON_DIR}/configs
mkdir -p ${SKELETON_DIR}/resources
mkdir -p ${SKELETON_DIR}/bin
## Copy self to new directory.
#cp ${BASH_SOURCE[0]} ${SKELETON_DIR}/bin
touch ${SKELETON_DIR}/README.md
cat >> ${SKELETON_DIR}/README.md << END
${MODULE_NAME}: description of module directory in here
END
touch ${SKELETON_DIR}/build.sh
cat >> ${SKELETON_DIR}/build.sh << END
set -e
python ${SHUTIT_DIR}/shutit_main.py
# Display config
#python ${SHUTIT_DIR}/shutit_main.py --sc
# Debug
#python ${SHUTIT_DIR}/shutit_main.py --debug
# Tutorial
#python ${SHUTIT_DIR}/shutit_main.py --tutorial
END
chmod +x ${SKELETON_DIR}/build.sh
touch ${SKELETON_DIR}/resources/README.md
cat >> ${SKELETON_DIR}/resources/README.md << END
${MODULE_NAME}: resources required in this directory, eg gzips or text files.\nNote that the .gitignore file in the ${SKELETON_DIR} directory should exclude these files from being added to git repos (usually due to size), but can be added if forced with 'git add --force <file>'.
END
# Module template
cp ../docs/shutit_module_template.py ${SKELETON_DIR}/${MODULE_NAME}.py
perl -p -i -e "s/template/${MODULE_NAME}/g" ${SKELETON_DIR}/${MODULE_NAME}.py
perl -p -i -e "s/GLOBALLY_UNIQUE_STRING/'com.mycorp.${MODULE_NAME}'/g" ${SKELETON_DIR}/${MODULE_NAME}.py
{'fraction_non_alphanumeric': 0.11484951731970472, 'fraction_numerical': 0.00596252129471891, 'mean_word_length': 4.569169960474309, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 33, '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': '4973415', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2286, 'n_words': 875}