#!/bin/bash
UICPROG='pyside6-uic'
OUTPUT='ui6_u2dplot.py'

${UICPROG} u2dplot.ui            -o ui_tmp0.py
cat ui_tmp0.py |grep -v "import u2dplot_rc" > ${OUTPUT}
echo "try:" >> ${OUTPUT}
echo "    import u2dplot_rc" >> ${OUTPUT}
echo "except:" >> ${OUTPUT}
echo "    import uGao.u2dplot_rc" >> ${OUTPUT}

${UICPROG} dg_overplot.ui        -o ui_tmp1.py
${UICPROG} dg_region.ui          -o ui_tmp2o1.py
cat ui_tmp2o1.py |grep -v "import u2dplot_rc" > ui_tmp2o.py
cat ui_tmp2o.py |grep -v "import dg_region_rc" > ui_tmp2.py
echo "try:" >> ui_tmp2.py
echo "    import dg_region_rc" >> ui_tmp2.py
echo "except:" >> ui_tmp2.py
echo "    import uGao.dg_region_rc" >> ui_tmp2.py

${UICPROG} dg_slice.ui           -o ui_tmp3o.py
cat ui_tmp3o.py | grep -v "import u2dplot_rc" > ui_tmp3.py

${UICPROG} dg_view_prms.ui       -o ui_tmp4o.py
cat ui_tmp4o.py | grep -v "import u2dplot_rc" > ui_tmp4.py

cat ui_tmp1.py | grep -v "coding: utf-8" | grep -v "from PySide6 import " >> ${OUTPUT}
cat ui_tmp2.py | grep -v "coding: utf-8" | grep -v "from PySide6 import " >> ${OUTPUT}
cat ui_tmp3.py | grep -v "coding: utf-8" | grep -v "from PySide6 import " >> ${OUTPUT}
cat ui_tmp4.py | grep -v "coding: utf-8" | grep -v "from PySide6 import " >> ${OUTPUT}

rm ui_tmp*.py

