From b805203e6f27e08bb1e9d121d19d03ab30c508c0 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Tue, 13 Feb 2024 15:54:07 -0800 Subject: [PATCH] clean up issues of winners in tmp While not that important we fixed tmp progs. --- tmp/example.dot_entry.json | 4 +-- tmp/gen_entry_json.sh | 74 +++++++++++++++++++------------------- tmp/run_all.sh | 42 +++++++++++----------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/tmp/example.dot_entry.json b/tmp/example.dot_entry.json index a8c2a213f..075e24999 100644 --- a/tmp/example.dot_entry.json +++ b/tmp/example.dot_entry.json @@ -17,7 +17,7 @@ "OK_to_edit" : false, "display_as" : "html", "display_via_github" : false, - "entry_text" : "winner home page" + "entry_text" : "entry home page" }, { "file_path" : "prog.c", @@ -113,7 +113,7 @@ "OK_to_edit" : true, "display_as" : "json", "display_via_github" : true, - "entry_text" : "description of winner in JSON" + "entry_text" : "description of entry in JSON" }, { "file_path" : "README.md", diff --git a/tmp/gen_entry_json.sh b/tmp/gen_entry_json.sh index 4c20aec74..735313fd7 100755 --- a/tmp/gen_entry_json.sh +++ b/tmp/gen_entry_json.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# gen_entry_json.sh - generate .entry.json for a winner +# gen_entry_json.sh - generate .entry.json for an entry # # XXX - This is a temporary utility that will be replaced when # the .entry.json files are built. @@ -62,14 +62,14 @@ export USAGE="usage: $0 [-h] [-v level] -t topdir path to top of the local tree (def: $TOPDIR) -P /path/to/pandoc path to the pandoc tool (def: $PANDOC) - year[/dir] path to winner directory (or just year if there is a path arg - [dir] optional winner directory (1st arg is just year) + year[/dir] path ton entry directory (or just year if there is a path arg + [dir] optionaln entry directory (1st arg is just year) Exit codes: 0 all OK 2 -h and help string printed or -V and version string printed 3 command line error - 4 cannot find writable winner directory + 4 cannot find writablen entry directory 5 cannot find readable author_wins.csv 6 cannot find readable year_prize.csv 7 cannot find readable manifest.csv @@ -123,32 +123,32 @@ shift $(( OPTIND - 1 )); # # verify arg count and parse args # -export WINNER_PATH +export ENTRY_PATH export YEAR -export WINNER +export ENTRY case "$#" in -1) WINNER_PATH="$1" - YEAR="${WINNER_PATH%/*}" - WINNER="${WINNER_PATH#*/}" +1) ENTRY_PATH="$1" + YEAR="${ENTRY_PATH%/*}" + ENTRY="${ENTRY_PATH#*/}" ;; -2) WINNER_PATH="$1/$2" +2) ENTRY_PATH="$1/$2" YEAR="$1" - WINNER="$2" + ENTRY="$2" ;; *) echo "$0: ERROR: expected 1 or 2 args, found: $#" 1>&2 echo "$USAGE" 1>&2 exit 3 ;; esac -export FULL_WINNER_PATH="$TOPDIR/$WINNER_PATH" -export ENTRY_ID="${YEAR}_${WINNER}" +export FULL_ENTRY_PATH="$TOPDIR/$ENTRY_PATH" +export ENTRY_ID="${YEAR}_${ENTRY}" -export URL_PATH="https://$DOMAIN$DOCPATH/$YEAR/$WINNER" +export URL_PATH="https://$DOMAIN$DOCPATH/$YEAR/$ENTRY" # setup temporary files # -export ENTRY_JSON_PATH="$FULL_WINNER_PATH/$DOT_ENTRY_JSON_BASENAME" -export TMP_DOT_ENTRY_JSON="$FULL_WINNER_PATH/tmp.$$.$DOT_ENTRY_JSON_BASENAME" +export ENTRY_JSON_PATH="$FULL_ENTRY_PATH/$DOT_ENTRY_JSON_BASENAME" +export TMP_DOT_ENTRY_JSON="$FULL_ENTRY_PATH/tmp.$$.$DOT_ENTRY_JSON_BASENAME" trap 'rm -f $TMP_DOT_ENTRY_JSON' 0 1 2 3 15 # print running info if verbose @@ -167,11 +167,11 @@ if [[ $V_FLAG -ge 5 ]]; then echo "$0: debug[5]: GITHUB_REPO=$GITHUB_REPO" 1>&2 echo "$0: debug[5]: TOPDIR=$TOPDIR" 1>&2 echo "$0: debug[5]: PANDOC=$PANDOC" 1>&2 - echo "$0: debug[5]: FULL_WINNER_PATH=$FULL_WINNER_PATH" 1>&2 + echo "$0: debug[5]: FULL_ENTRY_PATH=$FULL_ENTRY_PATH" 1>&2 echo "$0: debug[5]: ENTRY_ID=$ENTRY_ID" 1>&2 echo "$0: debug[5]: YEAR=$YEAR" 1>&2 - echo "$0: debug[5]: WINNER=$WINNER" 1>&2 - echo "$0: debug[5]: WINNER_PATH=$WINNER_PATH" 1>&2 + echo "$0: debug[5]: ENTRY=$ENTRY" 1>&2 + echo "$0: debug[5]: ENTRY_PATH=$ENTRY_PATH" 1>&2 echo "$0: debug[5]: URL_PATH=$URL_PATH" 1>&2 echo "$0: debug[5]: DOT_ENTRY_JSON_BASENAME=$DOT_ENTRY_JSON_BASENAME" 1>&2 echo "$0: debug[5]: ENTRY_JSON_PATH=$ENTRY_JSON_PATH" 1>&2 @@ -182,18 +182,18 @@ fi # IFS="$IFS," -# verify winner directory is writable +# verify entry directory is writable # -if [[ ! -e $FULL_WINNER_PATH ]]; then - echo "$0: ERROR: FULL_WINNER_PATH does not exist: $FULL_WINNER_PATH" 1>&2 +if [[ ! -e $FULL_ENTRY_PATH ]]; then + echo "$0: ERROR: FULL_ENTRY_PATH does not exist: $FULL_ENTRY_PATH" 1>&2 exit 4 fi -if [[ ! -d $FULL_WINNER_PATH ]]; then - echo "$0: ERROR: FULL_WINNER_PATH is not a directory: $FULL_WINNER_PATH" 1>&2 +if [[ ! -d $FULL_ENTRY_PATH ]]; then + echo "$0: ERROR: FULL_ENTRY_PATH is not a directory: $FULL_ENTRY_PATH" 1>&2 exit 4 fi -if [[ ! -w $FULL_WINNER_PATH ]]; then - echo "$0: ERROR: FULL_WINNER_PATH is not a writable directory: $FULL_WINNER_PATH" 1>&2 +if [[ ! -w $FULL_ENTRY_PATH ]]; then + echo "$0: ERROR: FULL_ENTRY_PATH is not a writable directory: $FULL_ENTRY_PATH" 1>&2 exit 4 fi @@ -289,7 +289,7 @@ fi # collect inventory # -NUMBER_RANKED_MANIFEST_SET=$(grep -E "^$YEAR,$WINNER,[^,][^,]*,[0-9]" "$MANIFEST_CSV" | sort -t, -k4n) +NUMBER_RANKED_MANIFEST_SET=$(grep -E "^$YEAR,$ENTRY,[^,][^,]*,[0-9]" "$MANIFEST_CSV" | sort -t, -k4n) declare -a FILE_PATH INVENTORY_ORDER OK_TO_EDIT DISPLAY_AS DISPLAY_VIA_GITHUB ENTRY_TEXT # # process inventory with a numerical inventory_order @@ -299,11 +299,11 @@ while IFS=, read -r year dir file_path inventory_order OK_to_edit display_as dis # firewall - year dir much match # if [[ $YEAR != "$year" ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order YEAR: $YEAR != $year" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order YEAR: $YEAR != $year" 1>&2 exit 30 fi - if [[ $WINNER != "$dir" ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order WINNER: $WINNER != $dir" 1>&2 + if [[ $ENTRY != "$dir" ]]; then + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order ENTRY: $ENTRY != $dir" 1>&2 exit 31 fi if [[ $V_FLAG -ge 7 ]]; then @@ -315,27 +315,27 @@ while IFS=, read -r year dir file_path inventory_order OK_to_edit display_as dis # firewall - nothing except extra should be empty # if [[ -z $file_path ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty file_path" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty file_path" 1>&2 exit 32 fi if [[ -z $inventory_order ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty inventory_order" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty inventory_order" 1>&2 exit 33 fi if [[ -z $OK_to_edit ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty OK_to_edit" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty OK_to_edit" 1>&2 exit 34 fi if [[ -z $display_as ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty display_as" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty display_as" 1>&2 exit 37 fi if [[ -z $display_via_github ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty display_via_github" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty display_via_github" 1>&2 exit 38 fi if [[ -z $entry_text ]]; then - echo "$0: ERROR: ^$YEAR,$WINNER inventory_order: $inventory_order empty entry_text" 1>&2 + echo "$0: ERROR: ^$YEAR,$ENTRY inventory_order: $inventory_order empty entry_text" 1>&2 exit 39 fi @@ -367,7 +367,7 @@ cat > "$TMP_DOT_ENTRY_JSON" << EOF "entry_JSON_format_version" : "$ENTRY_JSON_FORMAT_VERSION", "award" : "$AWARD", "year" : $YEAR, - "dir" : "$WINNER", + "dir" : "$ENTRY", "entry_id" : "$ENTRY_ID", "author_set" : [ EOF diff --git a/tmp/run_all.sh b/tmp/run_all.sh index 4108d2538..09bbc5a4a 100755 --- a/tmp/run_all.sh +++ b/tmp/run_all.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# run_all.sh - run a command for all winners +# run_all.sh - run a command for all entrys # # XXX - This is a temporary utility that will be replaced when # the .entry.json files are built @@ -41,12 +41,12 @@ export DOMAIN="ioccc-src.github.io" export DOCPATH="/temp-test-ioccc" export GITHUB_REPO="https://github.com/ioccc-src/temp-test-ioccc/blob/master" export TOPDIR=".." -export WINNER_DIR_TXT="winner_dir.txt" +export ENTRY_DIR_TXT="entry_dir.txt" # usage # export USAGE="usage: $0 [-h] [-v level] [-D level] - [-d www.domain.org] [-p /path/to/docroot] [-g github_url ] [-t topdir] [-w winner_dir.txt] + [-d www.domain.org] [-p /path/to/docroot] [-g github_url ] [-t topdir] [-w entry_dir.txt] tool -h print help message and exit @@ -58,17 +58,17 @@ export USAGE="usage: $0 [-h] [-v level] [-D level] -g github_url path to the GitHub repo (def: $GITHUB_REPO) -t topdir path to top of the local GitHub repo tree (def: $TOPDIR) - -w winner_dir.txt + -w entry_dir.txt - tool the tool to run over all winners + tool the tool to run over all entrys Exit codes: 0 all OK 2 -h and help string printed or -V and version string printed 3 command line error - 4 cannot find writable winner directory + 4 cannot find writable entry directory 5 tool is not an executable file - 6 missing winner directory as found in winner_dir.txt + 6 missing entry directory as found in entry_dir.txt 7 tool exited non-zero >= 10 internal error @@ -93,7 +93,7 @@ while getopts :hv:D:d:p:g:t:w: flag; do ;; t) TOPDIR="$OPTARG" ;; - w) WINNER_DIR_TXT="$OPTARG" + w) ENTRY_DIR_TXT="$OPTARG" ;; \?) echo "$0: ERROR: invalid option: -$OPTARG" 1>&2 echo 1>&2 @@ -139,25 +139,25 @@ if [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: GITHUB_REPO=$GITHUB_REPO" 1>&2 echo "$0: debug[3]: TOPDIR=$TOPDIR" 1>&2 echo "$0: debug[3]: TOOL=$TOOL" 1>&2 - echo "$0: debug[3]: WINNER_DIR_TXT=$WINNER_DIR_TXT" 1>&2 + echo "$0: debug[3]: ENTRY_DIR_TXT=$ENTRY_DIR_TXT" 1>&2 fi # make it easier to process CSV files # IFS="$IFS," -# verify winner_dir.txt is readable +# verify entry_dir.txt is readable # -if [[ ! -e $WINNER_DIR_TXT ]]; then - echo "$0: ERROR: WINNER_DIR_TXT does not exist: $WINNER_DIR_TXT" 1>&2 +if [[ ! -e $ENTRY_DIR_TXT ]]; then + echo "$0: ERROR: ENTRY_DIR_TXT does not exist: $ENTRY_DIR_TXT" 1>&2 exit 4 fi -if [[ ! -f $WINNER_DIR_TXT ]]; then - echo "$0: ERROR: WINNER_DIR_TXT is not a regular file: $WINNER_DIR_TXT" 1>&2 +if [[ ! -f $ENTRY_DIR_TXT ]]; then + echo "$0: ERROR: ENTRY_DIR_TXT is not a regular file: $ENTRY_DIR_TXT" 1>&2 exit 4 fi -if [[ ! -r $WINNER_DIR_TXT ]]; then - echo "$0: ERROR: WINNER_DIR_TXT is not a readable file: $WINNER_DIR_TXT" 1>&2 +if [[ ! -r $ENTRY_DIR_TXT ]]; then + echo "$0: ERROR: ENTRY_DIR_TXT is not a readable file: $ENTRY_DIR_TXT" 1>&2 exit 4 fi @@ -176,12 +176,12 @@ if [[ ! -x $TOOL ]]; then exit 5 fi -# verify that the winner directories exist +# verify that the entry directories exist # -for d in $(< "$WINNER_DIR_TXT"); do +for d in $(< "$ENTRY_DIR_TXT"); do dir="$TOPDIR/$d" if [[ ! -e $dir ]]; then - echo "$0: ERROR: winner directory does not exist: $dir" 1>&2 + echo "$0: ERROR: entry directory does not exist: $dir" 1>&2 exit 6 fi if [[ ! -d $dir ]]; then @@ -194,9 +194,9 @@ for d in $(< "$WINNER_DIR_TXT"); do fi done -# process tool for each winner +# process tool for each entry # -for dir in $(< "$WINNER_DIR_TXT"); do +for dir in $(< "$ENTRY_DIR_TXT"); do if [[ $V_FLAG -ge 1 ]]; then echo "$0: debug[1]: $TOOL -d $DOMAIN -p $DOCPATH -g $GITHUB_REPO -t $TOPDIR -v $CAP_D_FLAG -- $dir" 1>&2 fi