Script 'parse-games': modify the setup function.

This commit is contained in:
vonavi 2015-01-08 13:26:28 +03:00
parent e9bafd8838
commit d57bc132ad

View File

@ -8,17 +8,13 @@ REPO_DIR=
TOURNAMENT= TOURNAMENT=
function parse_setup { function parse_setup {
[[ -z $REPO_DIR ]] && REPO_DIR=`dirname "$0"` : ${REPO_DIR:=`dirname "$0"`}
# Convert REPO_DIR to an absolute path
[[ ! $REPO_DIR =~ ^/ ]] && REPO_DIR=$(cd ${REPO_DIR}; pwd)
# If no tournament given, set it to the last one # If no tournament given, set it to the last one
if [[ -z $TOURNAMENT ]]; then if [[ -z $TOURNAMENT ]]; then
local year_dir=$(ls -1 -d ${REPO_DIR}/[0-9][0-9][0-9][0-9]/ | tail -1) local year_dir=$(ls -1 -d ${REPO_DIR}/[0-9][0-9][0-9][0-9]/ | tail -1)
TOURNAMENT=$(ls -1 -d ${year_dir}[0-9]-*/ | tail -1 \ TOURNAMENT=$(ls -1 -d ${year_dir}[0-9]-*/ | tail -1 \
| sed -E "s|${REPO_DIR}/(.*)|\1|") | sed -E "s|${REPO_DIR}/(.*)/|\1|")
# Remove the trailing slash
TOURNAMENT=${TOURNAMENT%/}
fi fi
} }
@ -57,7 +53,7 @@ ply_ini=${REPO_DIR}/${TOURNAMENT}/players.ini
ply_count=$(grep "^\[player" "$ply_ini" | wc -l) ply_count=$(grep "^\[player" "$ply_ini" | wc -l)
tour_seq=$(ls -1 -d ${REPO_DIR}/${TOURNAMENT}/tours/[0-9][0-9]/ \ tour_seq=$(ls -1 -d ${REPO_DIR}/${TOURNAMENT}/tours/[0-9][0-9]/ \
| sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|") | sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|")
game_counter=1 game_counter=1
for tour in $tour_seq; do for tour in $tour_seq; do