forked from DjangoGirls/tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_languages
More file actions
executable file
·35 lines (26 loc) · 1.07 KB
/
Copy pathlist_languages
File metadata and controls
executable file
·35 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import argparse
import json
import os
from pathlib import Path
def parse_langs(langs, include_beta):
for line in langs.readlines():
description = line[3:-7]
code = line[-5:-3]
if include_beta or 'beta' not in description:
yield code, description
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--include-beta', help='Include beta languages', default='false',
choices=('true', 'false'))
parser.add_argument('--langs-file', help='LANGS.md to use',
type=argparse.FileType('r', encoding='UTF-8'),
default=(Path(__file__).absolute().parent.parent / 'LANGS.md').as_posix())
args = parser.parse_args()
languages = dict(parse_langs(args.langs_file, args.include_beta == 'true'))
if 'GITHUB_ACTION' in os.environ:
print(f'::set-output name=languages::{json.dumps(list(languages.keys()))}')
for code, language in languages.items():
print(f'{language} ({code})')
if __name__ == '__main__':
main()