From 5049382bf1a655d4ecd7e872fdc971c690491f7a Mon Sep 17 00:00:00 2001 From: Midgard Date: Mon, 27 Jan 2020 19:32:03 +0100 Subject: [PATCH] Add proxy script: python modules are annoying --- parse_hlds.py => app/parse_hlds.py | 4 ++-- parse_hlds.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) rename parse_hlds.py => app/parse_hlds.py (85%) create mode 100755 parse_hlds.sh diff --git a/parse_hlds.py b/app/parse_hlds.py similarity index 85% rename from parse_hlds.py rename to app/parse_hlds.py index 6a6961f..8fb08ee 100755 --- a/parse_hlds.py +++ b/app/parse_hlds.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 from tatsu.util import asjson -from app.hlds.parser import parse_files +from hlds.parser import parse_files USAGE = """{0} [filename]... @@ -17,7 +17,7 @@ def main(filenames): if filenames: location_definitions = parse_files(filenames) else: - from app.hlds.definitions import location_definitions + from hlds.definitions import location_definitions print("\n\n".join(map(str, location_definitions))) diff --git a/parse_hlds.sh b/parse_hlds.sh new file mode 100755 index 0000000..b0c3188 --- /dev/null +++ b/parse_hlds.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +# args = map(lambda arg: arg if x[0] in "/-" else pwd+arg, sys.argv[1:]) +args=() +for i in "$@"; do + # If argument is not an option and not an absolute path, it's a relative path: prepend current + # working directory + case "$i" in + /*|-*) args[${#args[@]}]="$i"; ;; + *) args[${#args[@]}]="$PWD/$i"; ;; + esac +done + +cd "$(dirname "$0")/app" +exec ../venv/bin/python parse_hlds.py "${args[@]}"