diff options
Diffstat (limited to 'opendc/util')
| -rw-r--r-- | opendc/util/path_parser.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/opendc/util/path_parser.py b/opendc/util/path_parser.py index 2f9528b1..292b747b 100644 --- a/opendc/util/path_parser.py +++ b/opendc/util/path_parser.py @@ -1,17 +1,17 @@ import json -import sys +import sys, os import re def parse(version, endpoint_path): """Map an HTTP endpoint path to an API path""" # Get possible paths - with open('opendc/api/{}/paths.json'.format(version)) as paths_file: + with open(os.path.join(os.path.dirname(__file__), '..', 'api', '{}', 'paths.json').format(version)) as paths_file: paths = json.load(paths_file) - + # Find API path that matches endpoint_path endpoint_path_parts = endpoint_path.strip('/').split('/') - paths_parts = [x.split('/') for x in paths if len(x.split('/')) == len(endpoint_path_parts)] + paths_parts = [x.strip('/').split('/') for x in paths if len(x.strip('/').split('/')) == len(endpoint_path_parts)] path = None for path_parts in paths_parts: |
