Mercurial > kallithea
annotate scripts/generate-ini.py @ 7950:eee49a119592
i18n: added translation for Turkish
Currently translated at 0.3% (3 of 1087 strings)
author | Hüseyin Tunç <huseyin.tunc@bulutfon.com> |
---|---|
date | Mon, 04 Nov 2019 08:00:01 +0100 |
parents | a8e6bb9ee9ea |
children | aa6f17a53b49 |
rev | line source |
---|---|
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python2 |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
2 """ |
7390
451b3f9d814e
docs: update i18n doc after TG migration changed lang to i18n.lang and test.ini is generated
Mads Kiilerich <mads@kiilerich.com>
parents:
7260
diff
changeset
|
3 Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
4 """ |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
5 |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7811
diff
changeset
|
6 from __future__ import print_function |
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7811
diff
changeset
|
7 |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
8 import re |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
9 |
6884
e3cce237d77c
ini: extract .ini handling from scripts/generate-ini.py to kallithea/lib/inifile.py
Mads Kiilerich <mads@kiilerich.com>
parents:
6883
diff
changeset
|
10 from kallithea.lib import inifile |
e3cce237d77c
ini: extract .ini handling from scripts/generate-ini.py to kallithea/lib/inifile.py
Mads Kiilerich <mads@kiilerich.com>
parents:
6883
diff
changeset
|
11 |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
7768
diff
changeset
|
12 |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
13 # files to be generated from the mako template |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
14 ini_files = [ |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
15 ('development.ini', |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
16 { |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
17 '[server:main]': { |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
18 'host': '0.0.0.0', |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
19 }, |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
20 '[app:main]': { |
6573
fc6b1b0e1096
ini: set 'debug' only in one place
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
6555
diff
changeset
|
21 'debug': 'true', |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
22 'app_instance_uuid': 'development-not-secret', |
7738
bbf7be28a11e
config: rename .ini settings to avoid beaker-session deprecation warnings
Mads Kiilerich <mads@kiilerich.com>
parents:
7390
diff
changeset
|
23 'session.secret': 'development-not-secret', |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
24 }, |
7768
609d52bbf917
ini: create separate log handlers for color and null, and add comments hinting how they can be used
Mads Kiilerich <mads@kiilerich.com>
parents:
7738
diff
changeset
|
25 '[logger_root]': { |
609d52bbf917
ini: create separate log handlers for color and null, and add comments hinting how they can be used
Mads Kiilerich <mads@kiilerich.com>
parents:
7738
diff
changeset
|
26 'handlers': 'console_color', |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
27 }, |
7193
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
28 '[logger_routes]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
29 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
30 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
31 '[logger_beaker]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
32 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
33 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
34 '[logger_templates]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
35 'level': 'INFO', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
36 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
37 '[logger_kallithea]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
38 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
39 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
40 '[logger_tg]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
41 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
42 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
43 '[logger_gearbox]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
44 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
45 }, |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
46 '[logger_whoosh_indexer]': { |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
47 'level': 'DEBUG', |
150173a027ee
ini: set default log level to WARN
domruf <dominikruf@gmail.com>
parents:
6895
diff
changeset
|
48 }, |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
49 }, |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
50 ), |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
51 ] |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
52 |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
53 |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
54 def main(): |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
55 # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text> |
6894
94f6b23e52d0
ini: move high level functionality and defaults to inifiles library
Mads Kiilerich <mads@kiilerich.com>
parents:
6893
diff
changeset
|
56 makofile = inifile.template_file |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7811
diff
changeset
|
57 print('reading:', makofile) |
6860
665dfa112f2c
py3: replace "file" with "open"
Lars Kruse <devel@sumpfralle.de>
parents:
6857
diff
changeset
|
58 mako_org = open(makofile).read() |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
59 mako_no_text_markup = re.sub(r'</?%text>', '', mako_org) |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
60 mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE) |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
61 if mako_marked_up != mako_org: |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7811
diff
changeset
|
62 print('writing:', makofile) |
6860
665dfa112f2c
py3: replace "file" with "open"
Lars Kruse <devel@sumpfralle.de>
parents:
6857
diff
changeset
|
63 open(makofile, 'w').write(mako_marked_up) |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
64 |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
65 # create ini files |
6893
d06039dc4ca2
ini: drop insertion of header comments in generated ini files
Mads Kiilerich <mads@kiilerich.com>
parents:
6891
diff
changeset
|
66 for fn, settings in ini_files: |
7844
a8e6bb9ee9ea
future: use Python print function
Mads Kiilerich <mads@kiilerich.com>
parents:
7811
diff
changeset
|
67 print('updating:', fn) |
6894
94f6b23e52d0
ini: move high level functionality and defaults to inifiles library
Mads Kiilerich <mads@kiilerich.com>
parents:
6893
diff
changeset
|
68 inifile.create(fn, None, settings) |
94f6b23e52d0
ini: move high level functionality and defaults to inifiles library
Mads Kiilerich <mads@kiilerich.com>
parents:
6893
diff
changeset
|
69 |
5536
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
70 |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
71 if __name__ == '__main__': |
06d5c043e989
ini: add scripts/generate-ini.py for generating all .ini files from template.ini.mako
Mads Kiilerich <madski@unity3d.com>
parents:
diff
changeset
|
72 main() |