py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2. In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.
One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2. See discussion on the respective previous
commits that made those explicit. There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-02 23:15:16 +02:00
|
|
|
#!/usr/bin/env python3
|
2017-04-26 09:32:46 +02:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
2020-11-16 21:48:44 +01:00
|
|
|
from pygments.lexers import get_all_lexers
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2017-04-26 09:32:46 +02:00
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')
|
2020-11-17 03:09:13 +01:00
|
|
|
PRIORITIES_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'lang.json')
|
2020-02-06 07:44:36 +01:00
|
|
|
OUT_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.json')
|
2017-04-26 09:32:46 +02:00
|
|
|
|
2020-11-17 03:09:13 +01:00
|
|
|
with open(PRIORITIES_PATH) as f:
|
|
|
|
priorities = json.load(f)
|
2017-04-26 09:32:46 +02:00
|
|
|
|
|
|
|
lexers = get_all_lexers()
|
2020-11-17 03:09:13 +01:00
|
|
|
langs = {
|
|
|
|
alias: {
|
|
|
|
'priority': priorities.get(alias, 0),
|
|
|
|
'pretty_name': longname,
|
|
|
|
}
|
|
|
|
for longname, aliases, filename_patterns, mimetypes in lexers
|
|
|
|
for alias in aliases
|
|
|
|
}
|
2017-04-26 09:32:46 +02:00
|
|
|
|
2020-02-06 07:44:36 +01:00
|
|
|
with open(OUT_PATH, 'w') as f:
|
|
|
|
json.dump({"langs": langs}, f)
|