Mercurial > p > roundup > code
annotate roundup/dist/command/build.py @ 5695:3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
interface and link to rest doc to features page. Add link to xmlrpc
doc to features page. Add rest doc to index. Update rest doc,
hopefully clarify confusing use of parameters in patch action
section. Fix code examples in "Adding new rest endpoints" section. Fix
example adding import of exception.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 07 Apr 2019 20:17:52 -0400 |
| parents | f2fade4552c5 |
| children | 42bf0a707763 |
| rev | line source |
|---|---|
| 4068 | 1 # |
| 2 # Copyright (C) 2009 Stefan Seefeld | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5 # | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
6 from __future__ import print_function |
| 4068 | 7 from roundup import msgfmt |
| 8 from distutils.command.build import build as base | |
| 9 import os | |
| 10 from glob import glob | |
| 11 | |
| 12 def list_message_files(suffix=".po"): | |
| 13 """Return list of all found message files and their intallation paths""" | |
| 14 _files = glob("locale/*" + suffix) | |
| 15 _list = [] | |
| 16 for _file in _files: | |
| 17 # basename (without extension) is a locale name | |
| 18 _locale = os.path.splitext(os.path.basename(_file))[0] | |
| 19 _list.append((_file, os.path.join( | |
| 20 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) | |
| 21 return _list | |
| 22 | |
| 23 def check_manifest(): | |
| 24 """Check that the files listed in the MANIFEST are present when the | |
| 25 source is unpacked. | |
| 26 """ | |
| 27 try: | |
| 28 f = open('MANIFEST') | |
| 29 except: | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
30 print('\n*** SOURCE WARNING: The MANIFEST file is missing!') |
| 4068 | 31 return |
| 32 try: | |
| 33 manifest = [l.strip() for l in f.readlines()] | |
| 34 finally: | |
| 35 f.close() | |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
36 err = set([line for line in manifest if not os.path.exists(line)]) |
| 4068 | 37 # ignore auto-generated files |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
38 err = err - set(['roundup-admin', 'roundup-demo', 'roundup-gettext', |
|
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
39 'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server']) |
| 4068 | 40 if err: |
| 41 n = len(manifest) | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
42 print('\n*** SOURCE WARNING: There are files missing (%d/%d found)!'%( |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
43 n-len(err), n)) |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
44 print('Missing:', '\nMissing: '.join(err)) |
| 4068 | 45 |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
46 def build_message_files(command): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
47 """For each locale/*.po, build .mo file in target locale directory""" |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
48 for (_src, _dst) in list_message_files(): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
49 _build_dst = os.path.join("build", _dst) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
50 command.mkpath(os.path.dirname(_build_dst)) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
51 command.announce("Compiling %s -> %s" % (_src, _build_dst)) |
|
5450
f2fade4552c5
replaced msgfmt.py with latest version supporting Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5376
diff
changeset
|
52 mo = msgfmt.Msgfmt(_src).get() |
|
f2fade4552c5
replaced msgfmt.py with latest version supporting Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5376
diff
changeset
|
53 open(_build_dst, 'wb').write(mo) |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
54 |
| 4068 | 55 |
| 56 class build(base): | |
| 57 | |
| 58 def run(self): | |
| 59 check_manifest() | |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
60 build_message_files(self) |
| 4068 | 61 base.run(self) |
| 62 |
