haldis/parse_hlds.py
Midgard 22aa5a0fb0
Fix issues reported by pylint
And silence the self-use warning: Tatsu requires it this way
2020-01-26 01:50:30 +01:00

31 lines
726 B
Python
Executable file

#!/usr/bin/env python3
from tatsu.util import asjson
from app.hlds.parser import parse_files
USAGE = """{0} [filename]...
Parse HLDS files, print as JSON
Without arguments, parse the default definitions.
With filenames as arguments, parse those files as HLDS.
{} --help Print this help text"""
def main(filenames):
if filenames:
location_definitions = parse_files(filenames)
else:
from app.hlds.definitions import location_definitions
print("\n\n".join(map(str, location_definitions)))
if __name__ == "__main__":
import sys
args = sys.argv[1:]
if "-h" in args or "--help" in args:
print(USAGE.format(sys.argv[0]), file=sys.stderr)
else:
main(args)