summaryrefslogtreecommitdiff
path: root/opendc
diff options
context:
space:
mode:
authorGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-25 13:27:25 +0200
committerGeorgios Andreadis <g.andreadis@student.tudelft.nl>2017-09-25 13:27:25 +0200
commit1f34466d41ba01a3dd36b0866696367d397daf7e (patch)
treea86406d35606fa5c068ac6ec3a8ac66dbf29b399 /opendc
parent7056ad696ad5397ba763a70808b379e213e529f9 (diff)
Fix path parsing
Diffstat (limited to 'opendc')
-rw-r--r--opendc/util/path_parser.py8
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: