<commit_before>#!/usr/bin/env bash

export BATFISH_ROOT="$($GNU_READLINK -f "$BATFISH_TOOLS_PATH/..")"
export BATFISH_PATH="$BATFISH_ROOT/projects/batfish"
export BATFISH_TEST_RIG_PATH="$BATFISH_ROOT/test_rigs"
export BATFISH="$BATFISH_PATH/batfish"
export BATFISH_Z3=z3
export BATFISH_Z3_DATALOG="$BATFISH_Z3 fixedpoint.engine=datalog fixedpoint.datalog.default_relation=doc fixedpoint.print_answer=true"
export BATFISH_NLS=nls
export BATFISH_PARALLEL='parallel --tag -v --eta --halt 2'
export BATFISH_NESTED_PARALLEL='parallel --tag -v --halt 2 -j1'

export BATFISH_CLIENT_PATH="$BATFISH_ROOT/projects/batfish-client"
export BATFISH_CLIENT="$BATFISH_CLIENT_PATH/batfish-client"

export BATFISH_DOCS_ROOT="$BATFISH_ROOT/docs"
export BATFISH_DOCS_DATAMODEL="$BATFISH_DOCS_ROOT/datamodel.json"

export BATFISH_WIKI_ROOT="$BATFISH_ROOT/../batfish.wiki"
export BATFISH_WIKI_DATAMODEL="$BATFISH_WIKI_ROOT/Datamodel.md"
export BATFISH_WIKI_QUESTIONS="$BATFISH_WIKI_ROOT/Questions.md"

if [ -d "$BATFISH_ROOT/../pybatfish" ]; then
   export PYBATFISH_ROOT="$BATFISH_ROOT/../pybatfish"
   export BATFISH_DATAMODEL_PAGE_SCRIPT="${PYBATFISH_ROOT}/datamodel_page.py"
   export BATFISH_QUESTIONS_PAGE_SCRIPT="${PYBATFISH_ROOT}/questions_page.py"
fi

export COORDINATOR_PATH="$BATFISH_ROOT/projects/coordinator"
export COORDINATOR="$COORDINATOR_PATH/coordinator"

export ALLINONE_PATH="$BATFISH_ROOT/projects/allinone"
export ALLINONE="$ALLINONE_PATH/allinone"

export COMMON_PATH="$BATFISH_ROOT/projects/batfish-common-protocol"
export COMMON_JAR="$COMMON_PATH/out/batfish-common-protocol.jar"

export QUESTION_PATH="$BATFISH_ROOT/projects/question"
export BATFISH_QUESTION_PLUGIN_DIR="$BATFISH_ROOT/projects/question/out"

batfish() {
   # if cygwin, shift and replace each parameter
   if batfish_cygwin; then
      local NUMARGS=$#
      local IGNORE_CURRENT_ARG=no;
      for i in $(seq 1 $NUMARGS); do
         local CURRENT_ARG=$1
         if [ "$IGNORE_CURRENT_ARG" = "yes" ]; then
            local NEW_ARG="$CURRENT_ARG"
            local IGNORE_CURRENT_ARG=no
         else
            local NEW_ARG="$(cygpath -w -- $CURRENT_ARG)"
         fi
         if [ "$CURRENT_ARG" = "-logicdir" -o "$CURRENT_ARG" = "-workspace" ]; then
            local IGNORE_CURRENT_ARG=yes
         fi
         set -- "$@" "$NEW_ARG"
         shift
      done
   fi
   if [ "$BATFISH_PRINT_CMDLINE" = "yes" ]; then
      echo "$BATFISH $BATFISH_COMMON_ARGS $@" >&2
   fi
   $BATFISH $BATFISH_COMMON_ARGS "$@"
}
export -f batfish

batfish_answer_example_cp() {
   batfish_date
   echo ": START: Answer provided example question"
   batfish_expect_args 3 $# || return 1
   local BASE=$1
   local ENVIRONMENT=$2
   local QUESTIONNAME=$3
   local QUESTION_SRC=$BATFISH_ROOT/example_questions/${QUESTIONNAME}.q
   local QUESTION_DST_DIR=$BASE/questions/$QUESTIONNAME
   local QUESTION_DST=$QUESTION_DST_DIR/question
   mkdir -p $QUESTION_DST_DIR
   cp $QUESTION_SRC $QUESTION_DST
   batfish -autobasedir $BASE -env $ENVIRONMENT -answer -questionname $QUESTIONNAME -loglevel output
   batfish_date
   echo ": END: Answer provided example question"
}
export -f batfish_answer_example_cp

batfish_build() {
   bash -c '_batfish_build "$@"' _batfish_build "$@" || return 1
   if [ "$BATFISH_COMPLETION_FILE" -ot "$BATFISH_PATH/out/batfish.jar" -a -e "$BATFISH_PATH/out/batfish.jar" ]; then
      echo -n "Generating bash completion file.."
      BATFISH_PRINT_CMDLINE=no batfish -help | grep -o '^ *-[a-zA-Z0-9]*' | tr -d ' ' | tr '\n' ' ' > "$BATFISH_COMPLETION_FILE"
      echo "OK"
   fi
}
export -f batfish_build

_batfish_build() {
   common_build || return 1
   cd "$BATFISH_PATH"
   ant "$@" || return 1
}
export -f _batfish_build

batfish_build_all() {
   bash -c '_batfish_build_all "$@"' _batfish_build_all "$@" || return 1
   if [ "$BATFISH_COMPLETION_FILE" -ot "$BATFISH_PATH/out/batfish.jar" -a -e "$BATFISH_PATH/out/batfish.jar" ]; then
      echo -n "Generating bash completion file.."<commit_msg>one more thing for spaces<commit_after>#!/usr/bin/env bash

export BATFISH_ROOT="$($GNU_READLINK -f "$BATFISH_TOOLS_PATH/..")"
export BATFISH_PATH="$BATFISH_ROOT/projects/batfish"
export BATFISH_TEST_RIG_PATH="$BATFISH_ROOT/test_rigs"
export BATFISH="$BATFISH_PATH/batfish"
export BATFISH_Z3=z3
export BATFISH_Z3_DATALOG="$BATFISH_Z3 fixedpoint.engine=datalog fixedpoint.datalog.default_relation=doc fixedpoint.print_answer=true"
export BATFISH_NLS=nls
export BATFISH_PARALLEL='parallel --tag -v --eta --halt 2'
export BATFISH_NESTED_PARALLEL='parallel --tag -v --halt 2 -j1'

export BATFISH_CLIENT_PATH="$BATFISH_ROOT/projects/batfish-client"
export BATFISH_CLIENT="$BATFISH_CLIENT_PATH/batfish-client"

export BATFISH_DOCS_ROOT="$BATFISH_ROOT/docs"
export BATFISH_DOCS_DATAMODEL="$BATFISH_DOCS_ROOT/datamodel.json"

export BATFISH_WIKI_ROOT="$BATFISH_ROOT/../batfish.wiki"
export BATFISH_WIKI_DATAMODEL="$BATFISH_WIKI_ROOT/Datamodel.md"
export BATFISH_WIKI_QUESTIONS="$BATFISH_WIKI_ROOT/Questions.md"

if [ -d "$BATFISH_ROOT/../pybatfish" ]; then
   export PYBATFISH_ROOT="$BATFISH_ROOT/../pybatfish"
   export BATFISH_DATAMODEL_PAGE_SCRIPT="${PYBATFISH_ROOT}/datamodel_page.py"
   export BATFISH_QUESTIONS_PAGE_SCRIPT="${PYBATFISH_ROOT}/questions_page.py"
fi

export COORDINATOR_PATH="$BATFISH_ROOT/projects/coordinator"
export COORDINATOR="$COORDINATOR_PATH/coordinator"

export ALLINONE_PATH="$BATFISH_ROOT/projects/allinone"
export ALLINONE="$ALLINONE_PATH/allinone"

export COMMON_PATH="$BATFISH_ROOT/projects/batfish-common-protocol"
export COMMON_JAR="$COMMON_PATH/out/batfish-common-protocol.jar"

export QUESTION_PATH="$BATFISH_ROOT/projects/question"
export BATFISH_QUESTION_PLUGIN_DIR="$BATFISH_ROOT/projects/question/out"

batfish() {
   # if cygwin, shift and replace each parameter
   if batfish_cygwin; then
      local NUMARGS=$#
      local IGNORE_CURRENT_ARG=no;
      for i in $(seq 1 $NUMARGS); do
         local CURRENT_ARG=$1
         if [ "$IGNORE_CURRENT_ARG" = "yes" ]; then
            local NEW_ARG="$CURRENT_ARG"
            local IGNORE_CURRENT_ARG=no
         else
            local NEW_ARG="$(cygpath -w -- $CURRENT_ARG)"
         fi
         if [ "$CURRENT_ARG" = "-logicdir" -o "$CURRENT_ARG" = "-workspace" ]; then
            local IGNORE_CURRENT_ARG=yes
         fi
         set -- "$@" "$NEW_ARG"
         shift
      done
   fi
   if [ "$BATFISH_PRINT_CMDLINE" = "yes" ]; then
      echo "$BATFISH $BATFISH_COMMON_ARGS $@" >&2
   fi
   "$BATFISH" $BATFISH_COMMON_ARGS "$@"
}
export -f batfish

batfish_answer_example_cp() {
   batfish_date
   echo ": START: Answer provided example question"
   batfish_expect_args 3 $# || return 1
   local BASE=$1
   local ENVIRONMENT=$2
   local QUESTIONNAME=$3
   local QUESTION_SRC=$BATFISH_ROOT/example_questions/${QUESTIONNAME}.q
   local QUESTION_DST_DIR=$BASE/questions/$QUESTIONNAME
   local QUESTION_DST=$QUESTION_DST_DIR/question
   mkdir -p $QUESTION_DST_DIR
   cp $QUESTION_SRC $QUESTION_DST
   batfish -autobasedir $BASE -env $ENVIRONMENT -answer -questionname $QUESTIONNAME -loglevel output
   batfish_date
   echo ": END: Answer provided example question"
}
export -f batfish_answer_example_cp

batfish_build() {
   bash -c '_batfish_build "$@"' _batfish_build "$@" || return 1
   if [ "$BATFISH_COMPLETION_FILE" -ot "$BATFISH_PATH/out/batfish.jar" -a -e "$BATFISH_PATH/out/batfish.jar" ]; then
      echo -n "Generating bash completion file (after batfish_build) ..."
      BATFISH_PRINT_CMDLINE=no batfish -help | grep -o '^ *-[a-zA-Z0-9]*' | tr -d ' ' | tr '\n' ' ' > "$BATFISH_COMPLETION_FILE"
      echo "OK"
   fi
}
export -f batfish_build

_batfish_build() {
   common_build || return 1
   cd "$BATFISH_PATH"
   ant "$@" || return 1
}
export -f _batfish_build

batfish_build_all() {
   bash -c '_batfish_build_all "$@"' _batfish_build_all "$@" || return 1
   if [ "$BATFISH_COMPLETION_FILE" -ot "$BATFISH_PATH/out/batfish.jar" -a -e "$BATFISH_PATH/out/batfish.jar" ]; then
      echo -n "Generating bash completion file (after batfish_build_all) ..."
{'fraction_non_alphanumeric': 0.12082710513203787, 'fraction_numerical': 0.00523168908819133, 'mean_word_length': 4.4286680189317105, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, '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': '4577020', 'n_tokens_mistral': 3214, 'n_tokens_neox': 3068, 'n_words': 535}