Mercurial > p > roundup > code
annotate roundup/dist/command/build.py @ 7596:e5fa31aad344
fix: replace bad reverted code change; allow js rate headers
Last commit included an incorrect undo. I was going to move the Allow
header/output format parsing earlier in the dispatch method. But I
reverted it incorrectly and removed it instead. It has been added back
in the former location.
Header that allows javascript access to the rest rate limit header has
been moved. The rate limit headers can be accessed by client side
javascript regardless of the rate limit being exceeded.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 03 Aug 2023 18:28:19 -0400 |
| parents | 1acdc651133b |
| children | fed0f839c260 |
| 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 |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
8 try: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
9 from setuptool.command.install import install as base |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
10 except ImportError: |
|
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
11 from distutils.command.build import build as base |
| 4068 | 12 import os |
| 13 from glob import glob | |
| 14 | |
| 15 def list_message_files(suffix=".po"): | |
| 16 """Return list of all found message files and their intallation paths""" | |
| 17 _files = glob("locale/*" + suffix) | |
| 18 _list = [] | |
| 19 for _file in _files: | |
| 20 # basename (without extension) is a locale name | |
| 21 _locale = os.path.splitext(os.path.basename(_file))[0] | |
| 22 _list.append((_file, os.path.join( | |
| 23 "share", "locale", _locale, "LC_MESSAGES", "roundup.mo"))) | |
| 24 return _list | |
| 25 | |
| 26 def check_manifest(): | |
| 27 """Check that the files listed in the MANIFEST are present when the | |
| 28 source is unpacked. | |
| 29 """ | |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
30 manifest_file = 'roundup.egg-info/SOURCES.txt' |
| 4068 | 31 try: |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
32 f=open(manifest_file) |
| 4068 | 33 except: |
|
6647
42bf0a707763
issue2551183 - Replace references to distutils in roundup/dist/command
John Rouillard <rouilj@ieee.org>
parents:
5450
diff
changeset
|
34 print('\n*** SOURCE WARNING: The MANIFEST file "%s" is missing!' % manifest_file) |
| 4068 | 35 return |
| 36 try: | |
| 37 manifest = [l.strip() for l in f.readlines()] | |
| 38 finally: | |
| 39 f.close() | |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
40 err = set([line for line in manifest if not os.path.exists(line)]) |
| 4068 | 41 # ignore auto-generated files |
|
4394
d4cd0a264098
fixed reporting of source missing warnings
Richard Jones <richard@users.sourceforge.net>
parents:
4068
diff
changeset
|
42 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
|
43 'roundup-mailgw', 'roundup-server', 'roundup-xmlrpc-server']) |
| 4068 | 44 if err: |
| 45 n = len(manifest) | |
|
5376
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
46 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
|
47 n-len(err), n)) |
|
64b05e24dbd8
Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents:
4516
diff
changeset
|
48 print('Missing:', '\nMissing: '.join(err)) |
| 4068 | 49 |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
50 def build_message_files(command): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
51 """For each locale/*.po, build .mo file in target locale directory""" |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
52 for (_src, _dst) in list_message_files(): |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
53 _build_dst = os.path.join("build", _dst) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
54 command.mkpath(os.path.dirname(_build_dst)) |
|
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
55 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
|
56 mo = msgfmt.Msgfmt(_src).get() |
|
f2fade4552c5
replaced msgfmt.py with latest version supporting Python 3
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5376
diff
changeset
|
57 open(_build_dst, 'wb').write(mo) |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
58 |
| 4068 | 59 |
| 60 class build(base): | |
| 61 | |
| 62 def run(self): | |
| 63 check_manifest() | |
|
4516
85dfe17c182e
Installation:
Bernhard Reiter <Bernhard.Reiter@intevation.de>
parents:
4394
diff
changeset
|
64 build_message_files(self) |
| 4068 | 65 base.run(self) |
| 66 |
