~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to release/scripts/modules/bl_i18n_utils/update_branches.py

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python3
 
2
 
 
3
# ***** BEGIN GPL LICENSE BLOCK *****
 
4
#
 
5
# This program is free software; you can redistribute it and/or
 
6
# modify it under the terms of the GNU General Public License
 
7
# as published by the Free Software Foundation; either version 2
 
8
# of the License, or (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software Foundation,
 
17
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
18
#
 
19
# ***** END GPL LICENSE BLOCK *****
 
20
 
 
21
# <pep8 compliant>
 
22
 
 
23
# Update all branches:
 
24
# * Generate a temp messages.txt file.
 
25
# * Use it to generate a temp .pot file.
 
26
# * Use it to update all .po’s in /branches.
 
27
 
 
28
import subprocess
 
29
import os
 
30
import sys
 
31
import tempfile
 
32
 
 
33
try:
 
34
    import settings
 
35
except:
 
36
    from . import settings
 
37
 
 
38
 
 
39
PY3 = settings.PYTHON3_EXEC
 
40
 
 
41
FILE_NAME_POT = settings.FILE_NAME_POT
 
42
 
 
43
 
 
44
def main():
 
45
    import argparse
 
46
    parser = argparse.ArgumentParser(description="Update all branches:\n"
 
47
                                                 "* Generate a temp messages.txt file.\n"
 
48
                                                 "* Use it to generate a blender.pot file.\n"
 
49
                                                 "* Use it to update all .po’s in /branches.")
 
50
    #parser.add_argument('--pproc-contexts', action="store_true",
 
51
                        #help="Pre-process po’s to avoid having plenty of fuzzy msgids just because a context was "
 
52
                             #"added/changed!")
 
53
    parser.add_argument('-c', '--no_checks', default=True, action="store_false", help="No checks over UI messages.")
 
54
    parser.add_argument('-a', '--add', action="store_true",
 
55
                        help="Add missing po’s (useful only when one or more languages are given!).")
 
56
    parser.add_argument('langs', metavar='ISO_code', nargs='*', help="Restrict processed languages to those.")
 
57
    args = parser.parse_args()
 
58
 
 
59
    ret = 0
 
60
 
 
61
    # Generate a temp messages file.
 
62
    dummy, msgfile = tempfile.mkstemp(suffix=".txt", prefix="blender_messages_")
 
63
    os.close(dummy)
 
64
    cmd = (PY3, "./update_msg.py", "-o", msgfile)
 
65
    t = subprocess.call(cmd)
 
66
    if t:
 
67
        ret = t
 
68
 
 
69
    # Generate blender.pot file in trunk/po. It's quite useful for translators that want to start
 
70
    # a new translation and not not want to bother generating their own po from scratch!
 
71
    potfile = FILE_NAME_POT
 
72
    cmd = [PY3, "./update_pot.py", "-i", msgfile, "-o", potfile]
 
73
    if not args.no_checks:
 
74
        cmd.append("-c")
 
75
    t = subprocess.call(cmd)
 
76
    if t:
 
77
        ret = t
 
78
 
 
79
    # Update branches’ po files.
 
80
    cmd = [PY3, "./update_po.py", "-i", potfile]
 
81
    if args.langs:
 
82
        if args.add:
 
83
            cmd.append("-a")
 
84
        cmd += args.langs
 
85
    #if args.pproc_contexts:
 
86
        #cmd.append("--pproc-contexts")
 
87
    t = subprocess.call(cmd)
 
88
    if t:
 
89
        ret = t
 
90
 
 
91
    return ret
 
92
 
 
93
 
 
94
if __name__ == "__main__":
 
95
    print("\n\n *** Running {} *** \n".format(__file__))
 
96
    sys.exit(main())