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
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../")
|
2021-05-14 13:38:14 +02:00
|
|
|
# The current priorities data set is based on StackOverflow's 2020 survey.
|
2021-02-12 08:20:45 +01:00
|
|
|
DATA_PATH = os.path.join(ZULIP_PATH, "tools", "setup", "lang.json")
|
|
|
|
OUT_PATH = os.path.join(ZULIP_PATH, "static", "generated", "pygments_data.json")
|
2017-04-26 09:32:46 +02:00
|
|
|
|
2020-12-12 02:51:10 +01:00
|
|
|
with open(DATA_PATH) as f:
|
2021-05-14 13:38:14 +02:00
|
|
|
pygments_data = json.load(f)
|
|
|
|
priorities = dict(
|
|
|
|
**pygments_data["default"], **pygments_data["custom"], **pygments_data["aliases"]
|
|
|
|
)
|
2017-04-26 09:32:46 +02:00
|
|
|
|
|
|
|
lexers = get_all_lexers()
|
2020-11-17 03:09:13 +01:00
|
|
|
langs = {
|
|
|
|
alias: {
|
2021-02-12 08:20:45 +01:00
|
|
|
"priority": priorities.get(alias, 0),
|
|
|
|
"pretty_name": longname,
|
2020-11-17 03:09:13 +01:00
|
|
|
}
|
|
|
|
for longname, aliases, filename_patterns, mimetypes in lexers
|
|
|
|
for alias in aliases
|
|
|
|
}
|
2017-04-26 09:32:46 +02:00
|
|
|
|
2020-12-12 02:51:10 +01:00
|
|
|
for name in priorities:
|
|
|
|
if langs.get(name) is None:
|
|
|
|
langs[name] = {
|
2021-02-12 08:20:45 +01:00
|
|
|
"priority": priorities[name],
|
|
|
|
"pretty_name": name,
|
2020-12-12 02:51:10 +01:00
|
|
|
}
|
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
with open(OUT_PATH, "w") as f:
|
2020-02-06 07:44:36 +01:00
|
|
|
json.dump({"langs": langs}, f)
|