File: build_ui.sh

package info (click to toggle)
anki 2.1.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,976 kB
  • sloc: python: 26,992; xml: 67; sh: 49; makefile: 45
file content (41 lines) | stat: -rwxr-xr-x 961 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
#
# generate python files based on the designer ui files. pyuic5 and pyrcc5
# should be on the path.
#

if [ ! -d "designer" ]
then
    echo "Please run this from the project root"
    exit
fi

mkdir -p aqt/forms

init=aqt/forms/__init__.py
temp=aqt/forms/scratch
rm -f $init $temp
echo "# This file auto-generated by build_ui.sh. Don't edit." > $init
echo "__all__ = [" >> $init

echo "Generating forms.."
for i in designer/*.ui
do
    base=$(basename $i .ui)
    py="aqt/forms/${base}.py"
    echo "	\"$base\"," >> $init
    echo "from . import $base" >> $temp
    if [ $i -nt $py ]; then
        echo " * "$py
        pyuic5 --from-imports $i -o $py
        # munge the output to use gettext
        perl -pi.bak -e 's/(QtGui\.QApplication\.)?_?translate\(".*?", /_(/; s/, None.*/))/' $py
        rm $py.bak
    fi
done
echo "]" >> $init
cat $temp >> $init
rm $temp

echo "Building resources.."
pyrcc5 designer/icons.qrc -o aqt/forms/icons_rc.py