Skip to content

Commit 4c19434

Browse files
committed
Merge branch 'feat/folder_path' of https://github.com/Geode-solutions/OpenGeodeWeb-Back into feat/folder_path
2 parents 5ebb91d + b312038 commit 4c19434

File tree

6 files changed

+19
-18
lines changed

6 files changed

+19
-18
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,23 @@ def is_loadable(geode_object: str, file_absolute_path: str):
3939
def load(geode_object: str, file_absolute_path: str):
4040
return geode_object_value(geode_object)["load"](file_absolute_path)
4141

42-
def load_data(geode_object: str, request_json: dict):
43-
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"]
42+
def load_from_request(geode_object: str, data_folder_path: str, request_json: dict):
4443
file_absolute_path = os.path.join(
4544
data_folder_path,
4645
request_json["id"],
4746
werkzeug.utils.secure_filename(request_json["filename"]),
4847
)
4948
return load(geode_object, file_absolute_path)
5049

51-
def data_file_path(request_json, filename):
52-
data_folder_path = flask.current_app.config["DATA_FOLDER_PATH"] # Use the load_data function to get the data folder path
50+
def build_data_path(data_folder_path, request_json, filename):
5351
return os.path.join(
5452
data_folder_path,
5553
request_json["id"],
5654
werkzeug.utils.secure_filename(filename),
5755
)
5856

59-
def upload_file_path(upload_folder, filename):
60-
secure_filename = werkzeug.utils.secure_filename(filename) # filename must be grabbed from the data_file_path function
57+
def build_upload_file_path(upload_folder, filename):
58+
secure_filename = werkzeug.utils.secure_filename(filename)
6159
return os.path.abspath(os.path.join(upload_folder, secure_filename)
6260
)
6361

src/opengeodeweb_back/routes/blueprint_routes.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def allowed_objects():
9999

100100
UPLOAD_FOLDER = flask.current_app.config["UPLOAD_FOLDER"]
101101
utils_functions.validate_request(flask.request, allowed_objects_json)
102-
file_absolute_path = geode_functions.upload_file_path(
102+
file_absolute_path = geode_functions.build_upload_file_path(
103103
UPLOAD_FOLDER, flask.request.json["filename"])
104104
allowed_objects = geode_functions.list_geode_objects(
105105
file_absolute_path, flask.request.json["supported_feature"]
@@ -124,7 +124,7 @@ def missing_files():
124124

125125
missing_files = geode_functions.missing_files(
126126
flask.request.json["input_geode_object"],
127-
geode_functions.upload_file_path(
127+
geode_functions.build_upload_file_path(
128128
UPLOAD_FOLDER, flask.request.json["filename"]),
129129
)
130130
has_missing_files = missing_files.has_missing_files()
@@ -217,7 +217,7 @@ def geode_objects_and_output_extensions():
217217
)
218218
data = geode_functions.load(
219219
flask.request.json["input_geode_object"],
220-
geode_functions.upload_file_path(
220+
geode_functions.build_upload_file_path(
221221
UPLOAD_FOLDER, flask.request.json["filename"]),
222222
)
223223
geode_objects_and_output_extensions = (
@@ -290,8 +290,9 @@ def create_point():
290290
)
291291
def texture_coordinates():
292292
utils_functions.validate_request(flask.request, texture_coordinates_json)
293-
data = geode_functions.load_data(
293+
data = geode_functions.load_from_request(
294294
flask.request.json["input_geode_object"],
295+
DATA_FOLDER_PATH,
295296
flask.request.json,
296297
)
297298

@@ -313,8 +314,9 @@ def texture_coordinates():
313314
)
314315
def vertex_attribute_names():
315316
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
316-
data = geode_functions.load_data(
317+
data = geode_functions.load_from_request(
317318
flask.request.json["input_geode_object"],
319+
DATA_FOLDER_PATH,
318320
flask.request.json,
319321
)
320322

@@ -341,8 +343,9 @@ def vertex_attribute_names():
341343
)
342344
def polygon_attribute_names():
343345
utils_functions.validate_request(flask.request, polygon_attribute_names_json)
344-
data = geode_functions.load_data(
346+
data = geode_functions.load_from_request(
345347
flask.request.json["input_geode_object"],
348+
DATA_FOLDER_PATH,
346349
flask.request.json,
347350
)
348351

@@ -369,8 +372,9 @@ def polygon_attribute_names():
369372
)
370373
def polyhedron_attribute_names():
371374
utils_functions.validate_request(flask.request, vertex_attribute_names_json)
372-
data = geode_functions.load_data(
375+
data = geode_functions.load_from_request(
373376
flask.request.json["input_geode_object"],
377+
DATA_FOLDER_PATH,
374378
flask.request.json,
375379
)
376380

src/opengeodeweb_back/routes/models/blueprint_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def uuid_to_flat_index():
2121
try:
2222
vtm_file_path = geode_functions.data_file_path(
2323
flask.request.json,
24-
"viewable.vtm"
24+
"viewable.vtm",
2525
)
2626
tree = ET.parse(vtm_file_path)
2727
except FileNotFoundError:

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def app_context():
3333
with app.app_context():
3434
yield
3535

36+
3637
@pytest.fixture
3738
def test_id():
38-
return "1"
39+
return "1"

tests/test_models_routes.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import os
22
import shutil
3-
4-
from src.opengeodeweb_back import geode_functions
5-
63
def test_model_mesh_components(client, test_id):
74
route = "/models/vtm_component_indices"
85

tests/test_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Standard library imports
22
import os
3+
34
# Third party imports
45
from werkzeug.datastructures import FileStorage
56

0 commit comments

Comments
 (0)