mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
The previous loop generated broken entries for duplicated language
aliases:
"juttle": {"priority": {"priority": 0, "pretty_name": "Juttle"}, "pretty_name": "Juttle"}
Signed-off-by: Anders Kaseorg <anders@zulip.com>
26 lines
684 B
Python
Executable File
26 lines
684 B
Python
Executable File
#!/usr/bin/env python3
|
|
import json
|
|
import os
|
|
|
|
from pygments.lexers import get_all_lexers
|
|
|
|
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')
|
|
PRIORITIES_PATH = os.path.join(ZULIP_PATH, 'tools', 'setup', 'lang.json')
|
|
OUT_PATH = os.path.join(ZULIP_PATH, 'static', 'generated', 'pygments_data.json')
|
|
|
|
with open(PRIORITIES_PATH) as f:
|
|
priorities = json.load(f)
|
|
|
|
lexers = get_all_lexers()
|
|
langs = {
|
|
alias: {
|
|
'priority': priorities.get(alias, 0),
|
|
'pretty_name': longname,
|
|
}
|
|
for longname, aliases, filename_patterns, mimetypes in lexers
|
|
for alias in aliases
|
|
}
|
|
|
|
with open(OUT_PATH, 'w') as f:
|
|
json.dump({"langs": langs}, f)
|