# HG changeset patch # User Oleksandr Gavenko # Date 1630479970 -10800 # Node ID 870abedea142160dd30d66664866f841bba9635f # Parent 6532512bbac4ffc8369463d8fd4aedd05d9a37d0 Allow selecting Python 2 or 3 when parsing dictionaries. diff -r 6532512bbac4 -r 870abedea142 Makefile --- a/Makefile Wed Sep 01 10:03:45 2021 +0300 +++ b/Makefile Wed Sep 01 10:06:10 2021 +0300 @@ -116,6 +116,8 @@ LATEX2PDF := pdflatex +PYTHON ?= python3 + ifeq '$(ANKI_PY_DIR)' '' ANKI_PY_DIR := /usr/share/anki endif @@ -556,7 +558,7 @@ .PHONY: freq freq: dist/wordlist/gadict.list py/gadict_freq.py $(FREQ_DEP) $(BUILD_SCRIPTS) - python3 -B py/gadict_freq.py +b:dist/wordlist/gadict.list $(FREQ_FILTER) + $(PYTHON) -B py/gadict_freq.py +b:dist/wordlist/gadict.list $(FREQ_FILTER) .PHONY: missing missing: missing-words missing-stat @@ -564,39 +566,39 @@ .PHONY: missing-words missing-words: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS) @echo ===== VOA ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:dist/wordlist/voa.list + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:dist/wordlist/voa.list @echo ===== GSL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/gsl.freq + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/gsl.freq @echo ===== AWL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/awl.freq + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/awl.freq @echo ===== NGSL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/ngsl.freq + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/ngsl.freq @echo ===== NAWL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/nawl.freq + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +f:wordlist/nawl.freq @echo ===== BSL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/bsl.var + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/bsl.var @echo ===== TSL ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/tsl.var + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/tsl.var @echo ===== KET ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/ket.var + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/ket.var @echo ===== PET ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/pet.var + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:wordlist/pet.var .PHONY: missing-speakout missing-speakout: dist/wordlist/gadict.list $(FREQ_DEP) $(BUILD_SCRIPTS) @echo ===== so1 ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so1.list | tee so1.miss + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so1.list | tee so1.miss @echo ===== so2 ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so2.list | tee so2.miss + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so2.list | tee so2.miss @echo ===== so3 ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so3.list | tee so3.miss + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so3.list | tee so3.miss @echo ===== so4 ===== - python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so4.list | tee so4.miss + $(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list +b:so4.list | tee so4.miss define stat-cmd { \ stat() { \ - lack=`python3 -B py/gadict_freq.py -b:dist/wordlist/gadict.list $$2:$$3 | wc -l`; \ + lack=`$(PYTHON) -B py/gadict_freq.py -b:dist/wordlist/gadict.list $$2:$$3 | wc -l`; \ total=`grep -v '^[ ]' $$3 | wc -l`; \ cover=$$((total - lack)); \ printf " %4s %5s %5s %4s\n" $$1 $$cover $$total $$lack; \ @@ -622,7 +624,7 @@ @${stat-cmd} dist/wordlist/%.list: %.gadict py/gadict_headwords.py $(BUILD_SCRIPTS) | dist/wordlist/ - python3 -B py/gadict_headwords.py $< $@ + $(PYTHON) -B py/gadict_headwords.py $< $@ dist/wordlist/gsl.var: $(GSL_BASEWORD) | dist/wordlist/ cat $(GSL_BASEWORD) >$@ @@ -631,7 +633,7 @@ cat $(NGSL_BASEWORD) >$@ dist/wordlist/voa.list: gadict_voa.gadict py/gadict_headwords.py $(MAKEFILE_LIST) | dist/wordlist/ - python3 -B py/gadict_headwords.py gadict_voa.gadict >$@ + $(PYTHON) -B py/gadict_headwords.py gadict_voa.gadict >$@ dist/wordlist/: mkdir -p $@ @@ -669,22 +671,22 @@ # -B suppress __pycache__ dir dist/dictd/gadict.c5: gadict.gadict $(FREQLIST_DEP) py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/ - LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $(FREQLIST_OPT) $< $@ + LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $(FREQLIST_OPT) $< $@ echo "gadict En-Ru+Uk"> dist/dictd/gadict.c5.name dist/dictd/gadict_en-ru.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/ - LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $< $@ -lang:ru + LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $< $@ -lang:ru echo "gadict En-Ru"> dist/dictd/gadict_en-ru.c5.name dist/dictd/gadict_en-uk.c5: gadict.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/ - LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $< $@ -lang:uk + LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $< $@ -lang:uk echo "gadict En-Uk"> dist/dictd/gadict_en-uk.c5.name dist/dictd/gadict_voa.c5: gadict_voa.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/ - LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $< $@ -lang:en + LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $< $@ -lang:en dist/dictd/%.c5: %.gadict py/gadict.py py/gadict_c5.py $(MAKEFILE_LIST) | dist/dictd/ - LC_ALL=en_US.utf8 python3 -B py/gadict_c5.py $< $@ + LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_c5.py $< $@ dist/dictd/: mkdir -p $@ @@ -703,32 +705,32 @@ # Specific rules (due to renames or other customization). dist/anki/gadict.apkg: gadict.gadict $(GADICT_DEL_FILE) py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name="gadict_en-ru+uk" -rich $(GADICT_DEL_OPT) $(FREQLIST_OPT) $< $@ dist/anki/gadict_voa.apkg: gadict_voa.gadict py/gadict.py py/gadict_srs_anki.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name="gadict_voa" $(VOA_FREQLIST_OPT) $< $@ dist/anki/%.apkg: %.gadialog py/gadialog_srs_anki.py $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadialog_srs_anki.py -name="$*" $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadialog_srs_anki.py -name="$*" $< $@ dist/anki/%.apkg: %.gaphrase py/gaphrase_srs_anki.py $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gaphrase_srs_anki.py -name="$*" $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gaphrase_srs_anki.py -name="$*" $< $@ # General rules. dist/anki/%.apkg: %.gadict %.del py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name=$* -rich -delfile=$*.del $(FREQLIST_OPT) $< $@ dist/anki/%.apkg: %.gadict py/gadict.py py/gadict_srs_anki.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/anki/ - PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 python3 -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@ + PYTHONPATH=$(ANKI_PY_DIR): LC_ALL=en_US.utf8 $(PYTHON) -B py/gadict_srs_anki.py -name=$* -rich $(FREQLIST_OPT) $< $@ .PHONY: tab tab: $(SRS_TAB_FILES) dist/srs/gadict.tab.txt: gadict.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/ - python3 -B py/gadict_srs_tab.py $< $@ -lang:ru,uk + $(PYTHON) -B py/gadict_srs_tab.py $< $@ -lang:ru,uk dist/srs/%.tab.txt: %.gadict py/gadict.py py/gadict_srs_tab.py $(MAKEFILE_LIST) | dist/srs/ - python3 -B py/gadict_srs_tab.py $< $@ + $(PYTHON) -B py/gadict_srs_tab.py $< $@ dist/anki/ dist/srs/: mkdir -p $@ @@ -737,13 +739,13 @@ html: $(DICT_HTML_FILES) dist/html/gadict_voa.html: gadict_voa.gadict py/gadict.py py/gadict_html.py $(VOA_FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/ - python3 -B py/gadict_html.py $(VOA_FREQLIST_OPT) $< $@ + $(PYTHON) -B py/gadict_html.py $(VOA_FREQLIST_OPT) $< $@ dist/html/%.html: %.gadict py/gadict.py py/gadict_html.py $(FREQLIST_DEP) $(MAKEFILE_LIST) | dist/html/ - python3 -B py/gadict_html.py $(FREQLIST_OPT) $< $@ + $(PYTHON) -B py/gadict_html.py $(FREQLIST_OPT) $< $@ dist/html/gadialog.html: gadialog.gadialog py/gadialog.py py/gadialog_html.py | dist/html/ - python3 -B py/gadialog_html.py $< $@ + $(PYTHON) -B py/gadialog_html.py $< $@ dist/html/: mkdir -p $@ @@ -877,7 +879,7 @@ # $ sudo apt-get install python3-enchant hunspell-en-us hunspell-en-gb hunspell-en-au hunspell-en-ca .PHONY: check check: - python3 -B py/gadict_spellcheck.py gadict.gadict + $(PYTHON) -B py/gadict_spellcheck.py gadict.gadict ################################################################ # Clean targets.