diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-12-23 01:56:08 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-12-23 01:56:08 +0100 |
commit | 6a51c97bddcffef78e0c3b39a0eddd69876b6907 (patch) | |
tree | dbd169b954cee0e1469173f606ecd9bd3e3bb7a7 | |
parent | eb6a5c5d225a785f2510c466b7410fc5851fa030 (diff) | |
download | www_shared-default.tar.gz www_shared-default.zip |
add mybabel wrapperdefault
-rw-r--r-- | mybabel.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mybabel.py b/mybabel.py new file mode 100644 index 0000000..50fa0c4 --- /dev/null +++ b/mybabel.py | |||
@@ -0,0 +1,25 @@ | |||
1 | #! /usr/bin/python3 | ||
2 | # | ||
3 | # This code is in the public domain. | ||
4 | # | ||
5 | # This is a wrapper around 'pybabel' that sets our include path | ||
6 | # to find the 'i18nfix' module. It takes the name of the | ||
7 | # pybabel program as the first argument (must be a Python script!) | ||
8 | # and passes the other arguments to pybabel after setting our | ||
9 | # sys.path. | ||
10 | # | ||
11 | import shutil | ||
12 | import sys | ||
13 | |||
14 | # First, extend the search path as needed (without setting PYTHONPATH!) | ||
15 | sys.path.insert(0, ".") | ||
16 | |||
17 | # Now, find the actual pybabel program in the $PATH | ||
18 | pb=shutil.which(sys.argv[1]) | ||
19 | |||
20 | # Remove 'pybabel' from argv[] so that pybabel doesn't confuse | ||
21 | # itself for the first command-line argument ;-) | ||
22 | sys.argv.remove(sys.argv[1]) | ||
23 | |||
24 | # Now we can run pybabel. Yeah! | ||
25 | exec(compile(source=open(pb).read(), filename=pb, mode='exec')) | ||