annotate locale/GNUmakefile @ 5525:bb7865241f8a

Make CSV import/export compatible across Python versions (also RDBMS journals) (issue 2550976, issue 2550975). The roundup-admin export and import commands are used for migrating between different database backends. It is desirable that they should be usable also for migrations between Python 2 and Python 3, and in some cases (e.g. with the anydbm backend) this may be required. To be usable for such migrations, the format of the generated CSV files needs to be stable, meaning the same as currently used with Python 2. The export process uses repr() to produce the fields in the CSV files and eval() to convert them back to Python data structures. repr() of strings with non-ASCII characters produces different results for Python 2 and Python 3. This patch adds repr_export and eval_import functions to roundup/anypy/strings.py which provide the required operations that are just repr() and eval() in Python 2, but are more complicated in Python 3 to use data representations compatible with Python 2. These functions are then used in the required places for export and import. repr() and eval() are also used in storing the dict of changed values in the journal for the RDBMS backends. It is similarly desirable that the database be compatible between Python 2 and Python 3, so that export and import do not need to be used for a migration between Python versions for non-anydbm back ends. Thus, this patch changes rdbms_common.py in the places involved in storing journals in the database, not just in those involved in import/export. Given this patch, import/export with non-ASCII characters appear based on some limited testing to work across Python versions, and an instance using the sqlite backend appears to be compatible between Python versions without needing import/export, *if* the sessions/otks databases (which use anydbm) are deleted when changing Python version.
author Joseph Myers <jsm@polyomino.org.uk>
date Sun, 02 Sep 2018 23:48:04 +0000
parents 6e3e4f24c753
children 2c0f7f16ce04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
1 # Extract translatable strings from Roundup sources,
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
2 # update and compile all existing translations
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
3
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
4 # tool locations
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
5 XPOT ?= xpot
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
6 MSGFMT ?= msgfmt
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
7 MSGMERGE ?= msgmerge
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
8 XGETTEXT ?= xgettext
2384
33469189bf86 extract messages from web templates
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2383
diff changeset
9 PYTHON ?= python
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
10
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
11 TEMPLATE=roundup.pot
2306
1421b19cd61b build message template file
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
12
4094
5a9631828e33 update message template file building:
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3761
diff changeset
13 PACKAGES=$(shell find ../roundup ../share/roundup/templates -name '*.py' \
3761
800bc51a9c8e add template directories to the list of Python packages for message extraction
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3593
diff changeset
14 | sed -e 's,/[^/]*$$,,' | sort | uniq)
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
15 SOURCES=$(PACKAGES:=/*.py)
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
16 PO_FILES=$(wildcard *.po)
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
17 MO_FILES=$(PO_FILES:.po=.mo)
2384
33469189bf86 extract messages from web templates
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2383
diff changeset
18 RUN_PYTHON=PYTHONPATH=../build/lib $(PYTHON) -O
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
19
2455
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
20 all: dist
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
21
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
22 help:
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
23 @echo "$(MAKE) - build MO files. Run this before sdist"
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
24 @echo "$(MAKE) template - update message template from sources"
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
25 @echo "$(MAKE) locale.po - update message file from template"
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
26 @echo "$(MAKE) locale.mo - compile individual message file"
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
27 @echo "$(MAKE) help - this text"\
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
28
2455
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
29 # This will rebuild all MO files without updating their corresponding PO
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
30 # files first. Run before creating Roundup distribution (hence the name).
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
31 # PO files should be updated by their translators only, automatic update
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
32 # adds unwanted fuzzy labels.
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
33 dist:
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
34 for file in $(PO_FILES); do \
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
35 ${MSGFMT} -o `basename $$file .po`.mo $$file; \
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
36 done
2306
1421b19cd61b build message template file
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff changeset
37
2455
ece6ed48dd3d by default, build binary message catalogs only...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2384
diff changeset
38 template:
2459
fd04f41ab988 fix: 'template' target was meant to make 'roundup.pot' file
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2455
diff changeset
39 ${XPOT} -n -o $(TEMPLATE) $(SOURCES)
fd04f41ab988 fix: 'template' target was meant to make 'roundup.pot' file
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2455
diff changeset
40 ${RUN_PYTHON} ../roundup/cgi/TAL/talgettext.py -u $(TEMPLATE) \
4094
5a9631828e33 update message template file building:
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3761
diff changeset
41 ../share/roundup/templates/classic/html/*.html \
5a9631828e33 update message template file building:
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3761
diff changeset
42 ../share/roundup/templates/minimal/html/*.html
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
43 ${XGETTEXT} -j -w 80 -F \
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
44 --msgid-bugs-address=roundup-devel@lists.sourceforge.net \
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
45 --copyright-holder="See Roundup README.txt" \
2459
fd04f41ab988 fix: 'template' target was meant to make 'roundup.pot' file
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2455
diff changeset
46 -o $(TEMPLATE) $(SOURCES)
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
47
3578
782287e01b99 added template diff target: view changes in message strings
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2459
diff changeset
48 # helps to check template file before check in
782287e01b99 added template diff target: view changes in message strings
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2459
diff changeset
49 diff:
4094
5a9631828e33 update message template file building:
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3761
diff changeset
50 svn diff roundup.pot|grep -v '^[-+]#'|vim -Rv -
3578
782287e01b99 added template diff target: view changes in message strings
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2459
diff changeset
51
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
52 %.po: $(TEMPLATE)
3593
3d9e1906ba58 don't wrap po files at position 72
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 3578
diff changeset
53 ${MSGMERGE} -U --suffix=.bak $@ $<
2330
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
54
8ae58eda9331 in addition to xpot...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2306
diff changeset
55 %.mo: %.po
2342
106737dbe689 show statistics for message catalogs
Alexander Smishlajev <a1s@users.sourceforge.net>
parents: 2330
diff changeset
56 ${MSGFMT} --statistics -o $@ $<

Roundup Issue Tracker: http://roundup-tracker.org/