Skip to content

Commit 2460937

Browse files
committed
fix: add folder independence
1 parent 7f79530 commit 2460937

2 files changed

Lines changed: 19 additions & 12 deletions

File tree

‎knora/create_ontology.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import List, Set, Dict, Tuple, Optional
23
from pprint import pprint
34
import argparse
@@ -17,12 +18,14 @@ def main():
1718

1819
args = parser.parse_args()
1920

21+
current_dir = os.path.dirname(os.path.realpath(__file__))
22+
2023
# let's read the schema for the ontology definition
2124
if args.lists:
22-
with open('knora-schema-lists.json') as s:
25+
with open(os.path.join(current_dir, 'knora-schema-lists.json')) as s:
2326
schema = json.load(s)
2427
else:
25-
with open('knora-schema.json') as s:
28+
with open(os.path.join(current_dir, 'knora-schema.json')) as s:
2629
schema = json.load(s)
2730

2831
# read the ontology definition

‎knora/knora.py‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ class knora:
9292
def __init__(self, server: str, email: str, password: str, prefixes: Dict[str,str] = None):
9393
"""
9494
Constructor requiring the server address, the user and password of KNORA
95-
:param server: Adress of the server, e.g http://data.dasch.swiss
96-
:param user: Username for Knora e.g., root@example.com
97-
:param password: The password, e.g. test
95+
:param server: Address of the server, e.g http://data.dasch.swiss
96+
:param email: Email of user, e.g., root@example.com
97+
:param password: Password of the user, e.g. test
9898
"""
9999
self.server = server
100100
self.prefixes = prefixes
@@ -105,23 +105,27 @@ def __init__(self, server: str, email: str, password: str, prefixes: Dict[str,st
105105
}
106106
jsondata = json.dumps(credentials)
107107

108-
req = requests.post(self.server + '/v2/authentication',
109-
headers={'Content-Type': 'application/json; charset=UTF-8'},
110-
data=jsondata)
108+
req = requests.post(
109+
self.server + '/v2/authentication',
110+
headers={'Content-Type': 'application/json; charset=UTF-8'},
111+
data=jsondata
112+
)
113+
111114
self.on_api_error(req)
112115

113116
result = req.json()
114117
self.token = result["token"]
115118

116119
def __del__(self):
117-
req = requests.delete(self.server + '/v2/authentication',
118-
headers={'Authorization': 'Bearer ' + self.token})
119-
result = req.json()
120+
req = requests.delete(
121+
self.server + '/v2/authentication',
122+
headers={'Authorization': 'Bearer ' + self.token}
123+
)
120124

125+
result = req.json()
121126
pprint.pprint(result)
122127

123128

124-
125129
def on_api_error(self, res):
126130
"""
127131
Method to check for any API errors

0 commit comments

Comments
 (0)