File indexing completed on 2026-05-27 07:24:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 print_help()
0013 {
0014 echo "Syntax: generate_metadata.sh [-m|b|o|v|vv|h]"
0015 echo "Options:"
0016 echo " m Full path and filename of the python metadata script"
0017 echo " in the \"detray/detectors/python\" directory."
0018 echo " p Where to find the detray python package (e.g. build/python)."
0019 echo " o Output directory."
0020 echo " v Verbose logging."
0021 echo " vv Debug level logging."
0022 echo " h Print this help."
0023 echo
0024
0025 return
0026 }
0027
0028
0029 log_lvl=0
0030
0031
0032 while getopts ":hvp:vv:m:o:" opt; do
0033 case ${opt} in
0034 h)
0035 echo "Generate custom detray Detector Metadata"
0036 echo
0037 print_help
0038 exit 0
0039 ;;
0040 v)
0041 ((log_lvl++))
0042 ;;
0043 p)
0044 python_dir=${OPTARG}
0045 ;;
0046 m)
0047 metadata_generator=${OPTARG}
0048 ;;
0049 o)
0050 out_dir=${OPTARG}
0051 ;;
0052 \?)
0053 >&2 echo
0054 >&2 echo "ERROR: Invalid option ${opt}! Usage:"
0055 >&2 echo
0056 print_help
0057 exit 1
0058 ;;
0059 *)
0060 >&2 echo
0061 >&2 echo "ERROR: Unknown option ${opt}! Usage:"
0062 >&2 echo
0063 print_help
0064 exit 1
0065 ;;
0066 esac
0067 done
0068
0069 if [ -z "${metadata_generator}" ];then
0070 >&2 echo
0071 >&2 echo "ERROR: No detector metadata script supplied! Usage:"
0072 >&2 echo
0073 print_help
0074 exit 1
0075 fi
0076
0077 if [ -z "${python_dir}" ];then
0078 >&2 echo
0079 >&2 echo "ERROR: Path to the detray python package not supplied! Usage:"
0080 >&2 echo
0081 print_help
0082 exit 1
0083 fi
0084
0085
0086 python_command="python3"
0087 if command -v {$python_command} > /dev/null; then
0088
0089 python_command="python"
0090 if command -v {$python_command} > /dev/null; then
0091 >&2 echo
0092 >&2 echo "ERROR: No python command found: exiting"
0093 >&2 echo
0094 exit 2
0095 fi
0096 fi
0097
0098 generator_command="${python_command} ${metadata_generator}"
0099
0100
0101 if [ ${log_lvl} -eq 1 ]; then
0102 generator_command="${generator_command} -v"
0103 elif [ ${log_lvl} -eq 2 ]; then
0104 generator_command="${generator_command} -vv"
0105 fi
0106
0107
0108 if [ ! -z "${out_dir}" ]; then
0109 generator_command="${generator_command} -o ${out_dir}"
0110 fi
0111
0112
0113 export PYTHONPATH="${python_dir}/python":$PYTHONPATH
0114
0115
0116 eval ${generator_command}