From 5c94fa31162c79b0c4422d09b5e00837b444664e Mon Sep 17 00:00:00 2001 From: Ahmad Alobaid Date: Thu, 23 Apr 2020 15:21:57 +0300 Subject: [PATCH] fix data_dir in util --- app.py | 4 ++-- generate_lookup.py | 2 +- util.py | 12 ++++-------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app.py b/app.py index f188e3b..1abe107 100644 --- a/app.py +++ b/app.py @@ -177,7 +177,7 @@ def editor(): if headers == []: error_msg = "Can't parse the source file " return render_template('msg.html', msg=error_msg, msg_title="Error") - labels = util.get_classes_as_txt(ontologies) + labels = util.get_classes_as_txt(ontologies, data_dir=DATA_DIR) # f = open(os.path.join(DATA_DIR, "labels.txt")) return render_template('editor.html', labels_txt=labels, ontologies_txt=",".join(ontologies), headers=headers, callback=callback_url, file_name=fname, error_msg=error_msg, warning_msg=warning_msg) @@ -187,7 +187,7 @@ def editor(): def get_properties(): ontologies_txt = request.args.get('ontologies') ontologies = ontologies_txt.split(',') - return jsonify({'properties': util.get_properties_as_list(ontologies)}) + return jsonify({'properties': util.get_properties_as_list(ontologies, data_dir=DATA_DIR)}) @app.route("/get_properties_autocomplete") diff --git a/generate_lookup.py b/generate_lookup.py index de90e95..7145e3f 100644 --- a/generate_lookup.py +++ b/generate_lookup.py @@ -92,7 +92,7 @@ def build_property_lookup(dataset_name,properties_fdir, data_dir): :return: """ print("build_property_lookup> dataset_name: "+dataset_name) - properties = util.get_properties_as_list([dataset_name]) + properties = util.get_properties_as_list([dataset_name], data_dir=data_dir) # start_idx = predict_base_URL(properties) lookup_name = 'lookup' lookup_folder_dir = os.path.join(data_dir,dataset_name,lookup_name) diff --git a/util.py b/util.py index 4915019..08deec0 100644 --- a/util.py +++ b/util.py @@ -3,10 +3,6 @@ import os -#DATA_DIR = os.path.join(BASE_DIR, 'data') -DATA_DIR = 'data' - - def get_random_string(length=4): return ''.join(random.choice(string.lowercase) for i in range(length)) @@ -218,26 +214,26 @@ def get_classes_from_file(odir): return classes -def get_properties_as_list(ontologies): +def get_properties_as_list(ontologies, data_dir): """ :param ontologies: :return: """ properties = [] for o in ontologies: - odir = os.path.join(DATA_DIR, o, 'properties.txt') + odir = os.path.join(data_dir, o, 'properties.txt') properties += get_classes_from_file(odir) return properties -def get_classes_as_txt(ontologies): +def get_classes_as_txt(ontologies, data_dir): """ :param ontologies: :return: """ classes = [] for o in ontologies: - odir = os.path.join(DATA_DIR, o, 'classes.txt') + odir = os.path.join(data_dir, o, 'classes.txt') classes += get_classes_from_file(odir) # return classes txt = ""