Skip to content

Commit 7cc9d3b

Browse files
Merge pull request #55 from Geode-solutions/feat/is_loadable
Feat/is loadable
2 parents b05e1e1 + d224d8f commit 7cc9d3b

File tree

3 files changed

+116
-66
lines changed

3 files changed

+116
-66
lines changed

src/opengeodeweb_back/geode_functions.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def missing_files(geode_object: str, file_absolute_path: str):
3434
return geode_object_value(geode_object)["missing_files"](file_absolute_path)
3535

3636

37+
def is_loadable(geode_object: str, file_absolute_path: str):
38+
return geode_object_value(geode_object)["is_loadable"](file_absolute_path)
39+
40+
3741
def load(geode_object: str, file_absolute_path: str):
3842
return geode_object_value(geode_object)["load"](file_absolute_path)
3943

@@ -109,18 +113,26 @@ def geode_object_output_extensions(geode_object: str):
109113
return geode_object_output_list_creators
110114

111115

112-
def list_input_extensions(key: str = None):
113-
extensions_list = []
116+
def filter_geode_objects(key: str = None):
117+
geode_objects_filtered_list = []
114118
for geode_object, value in geode_objects_dict().items():
115-
if key != None:
119+
if key != None and key != "":
116120
if key in value:
117121
if type(value[key]) == bool:
118-
if value[key] == True:
119-
extensions_list += geode_object_input_extensions(geode_object)
122+
geode_objects_filtered_list.append(geode_object)
120123
else:
121-
extensions_list += geode_object_input_extensions(geode_object)
124+
geode_objects_filtered_list.append(geode_object)
122125
else:
123-
extensions_list += geode_object_input_extensions(geode_object)
126+
geode_objects_filtered_list.append(geode_object)
127+
geode_objects_filtered_list.sort()
128+
return geode_objects_filtered_list
129+
130+
131+
def list_input_extensions(key: str = None):
132+
extensions_list = []
133+
geode_objects_filtered_list = filter_geode_objects(key)
134+
for geode_object in geode_objects_filtered_list:
135+
extensions_list += geode_object_input_extensions(geode_object)
124136

125137
extensions_list = list(set(extensions_list))
126138
extensions_list.sort()
@@ -131,23 +143,19 @@ def has_creator(geode_object: str, extension: str):
131143
return input_factory(geode_object).has_creator(extension)
132144

133145

134-
def list_geode_objects(extension: str, key: str = None):
135-
geode_objects_list = []
136-
for geode_object, value in geode_objects_dict().items():
137-
if key != None:
138-
if key in value:
139-
if type(value[key]) == bool:
140-
if value[key] == True:
141-
if has_creator(geode_object, extension):
142-
geode_objects_list.append(geode_object)
143-
elif has_creator(geode_object, extension):
144-
geode_objects_list.append(geode_object)
145-
else:
146-
if has_creator(geode_object, extension):
147-
geode_objects_list.append(geode_object)
148-
149-
geode_objects_list.sort()
150-
return geode_objects_list
146+
def list_geode_objects(
147+
file_absolute_path: str,
148+
key: str = None,
149+
):
150+
return_dict = {}
151+
file_extension = extension_from_filename(os.path.basename(file_absolute_path))
152+
geode_objects_filtered_list = filter_geode_objects(key)
153+
154+
for geode_object in geode_objects_filtered_list:
155+
if has_creator(geode_object, file_extension):
156+
file_is_loadable = is_loadable(geode_object, file_absolute_path)
157+
return_dict[geode_object] = {"is_loadable": file_is_loadable}
158+
return return_dict
151159

152160

153161
def geode_objects_output_extensions(geode_object: str, data):

src/opengeodeweb_back/geode_objects.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def geode_objects_dict():
1212
"input_factory": og.BRepInputFactory,
1313
"output_factory": og.BRepOutputFactory,
1414
"missing_files": og.check_brep_missing_files,
15+
"is_loadable": og.is_brep_loadable,
1516
"load": og.load_brep,
1617
"is_saveable": og.is_brep_saveable,
1718
"save": og.save_brep,
@@ -32,6 +33,7 @@ def geode_objects_dict():
3233
"input_factory": og_gs.CrossSectionInputFactory,
3334
"output_factory": og_gs.CrossSectionOutputFactory,
3435
"missing_files": og_gs.check_cross_section_missing_files,
36+
"is_loadable": og_gs.is_cross_section_loadable,
3537
"load": og_gs.load_cross_section,
3638
"is_saveable": og_gs.is_cross_section_saveable,
3739
"save": og_gs.save_cross_section,
@@ -51,6 +53,7 @@ def geode_objects_dict():
5153
"input_factory": og.EdgedCurveInputFactory2D,
5254
"output_factory": og.EdgedCurveOutputFactory2D,
5355
"missing_files": og.check_edged_curve_missing_files2D,
56+
"is_loadable": og.is_edged_curve_loadable2D,
5457
"load": og.load_edged_curve2D,
5558
"is_saveable": og.is_edged_curve_saveable2D,
5659
"save": og.save_edged_curve2D,
@@ -70,6 +73,7 @@ def geode_objects_dict():
7073
"input_factory": og.EdgedCurveInputFactory3D,
7174
"output_factory": og.EdgedCurveOutputFactory3D,
7275
"missing_files": og.check_edged_curve_missing_files3D,
76+
"is_loadable": og.is_edged_curve_loadable3D,
7377
"load": og.load_edged_curve3D,
7478
"is_saveable": og.is_edged_curve_saveable3D,
7579
"save": og.save_edged_curve3D,
@@ -89,6 +93,7 @@ def geode_objects_dict():
8993
"input_factory": og.GraphInputFactory,
9094
"output_factory": og.GraphOutputFactory,
9195
"missing_files": og.check_graph_missing_files,
96+
"is_loadable": og.is_graph_loadable,
9297
"load": og.load_graph,
9398
"is_saveable": og.is_graph_saveable,
9499
"save": og.save_graph,
@@ -101,6 +106,7 @@ def geode_objects_dict():
101106
"input_factory": og.HybridSolidInputFactory3D,
102107
"output_factory": og.HybridSolidOutputFactory3D,
103108
"missing_files": og.check_hybrid_solid_missing_files3D,
109+
"is_loadable": og.is_hybrid_solid_loadable3D,
104110
"load": og.load_hybrid_solid3D,
105111
"is_saveable": og.is_hybrid_solid_saveable3D,
106112
"save": og.save_hybrid_solid3D,
@@ -120,6 +126,7 @@ def geode_objects_dict():
120126
"input_factory": og.PointSetInputFactory2D,
121127
"output_factory": og.PointSetOutputFactory2D,
122128
"missing_files": og.check_point_set_missing_files2D,
129+
"is_loadable": og.is_point_set_loadable2D,
123130
"load": og.load_point_set2D,
124131
"is_saveable": og.is_point_set_saveable2D,
125132
"save": og.save_point_set2D,
@@ -139,6 +146,7 @@ def geode_objects_dict():
139146
"input_factory": og.PointSetInputFactory3D,
140147
"output_factory": og.PointSetOutputFactory3D,
141148
"missing_files": og.check_point_set_missing_files3D,
149+
"is_loadable": og.is_point_set_loadable3D,
142150
"load": og.load_point_set3D,
143151
"is_saveable": og.is_point_set_saveable3D,
144152
"save": og.save_point_set3D,
@@ -158,6 +166,7 @@ def geode_objects_dict():
158166
"input_factory": og.PolygonalSurfaceInputFactory2D,
159167
"output_factory": og.PolygonalSurfaceOutputFactory2D,
160168
"missing_files": og.check_polygonal_surface_missing_files2D,
169+
"is_loadable": og.is_polygonal_surface_loadable2D,
161170
"load": og.load_polygonal_surface2D,
162171
"is_saveable": og.is_polygonal_surface_saveable2D,
163172
"save": og.save_polygonal_surface2D,
@@ -177,6 +186,7 @@ def geode_objects_dict():
177186
"input_factory": og.PolygonalSurfaceInputFactory3D,
178187
"output_factory": og.PolygonalSurfaceOutputFactory3D,
179188
"missing_files": og.check_polygonal_surface_missing_files3D,
189+
"is_loadable": og.is_polygonal_surface_loadable3D,
180190
"load": og.load_polygonal_surface3D,
181191
"is_saveable": og.is_polygonal_surface_saveable3D,
182192
"save": og.save_polygonal_surface3D,
@@ -196,6 +206,7 @@ def geode_objects_dict():
196206
"input_factory": og.PolyhedralSolidInputFactory3D,
197207
"output_factory": og.PolyhedralSolidOutputFactory3D,
198208
"missing_files": og.check_polyhedral_solid_missing_files3D,
209+
"is_loadable": og.is_polyhedral_solid_loadable3D,
199210
"load": og.load_polyhedral_solid3D,
200211
"is_saveable": og.is_polyhedral_solid_saveable3D,
201212
"save": og.save_polyhedral_solid3D,
@@ -215,6 +226,7 @@ def geode_objects_dict():
215226
"input_factory": og.RasterImageInputFactory2D,
216227
"output_factory": og.RasterImageOutputFactory2D,
217228
"missing_files": og.check_raster_image_missing_files2D,
229+
"is_loadable": og.is_raster_image_loadable2D,
218230
"load": og.load_raster_image2D,
219231
"is_saveable": og.is_raster_image_saveable2D,
220232
"save": og.save_raster_image2D,
@@ -227,6 +239,7 @@ def geode_objects_dict():
227239
"input_factory": og.RasterImageInputFactory3D,
228240
"output_factory": og.RasterImageOutputFactory3D,
229241
"missing_files": og.check_raster_image_missing_files3D,
242+
"is_loadable": og.is_raster_image_loadable3D,
230243
"load": og.load_raster_image3D,
231244
"is_saveable": og.is_raster_image_saveable3D,
232245
"save": og.save_raster_image3D,
@@ -239,6 +252,7 @@ def geode_objects_dict():
239252
"input_factory": og.RegularGridInputFactory2D,
240253
"output_factory": og.RegularGridOutputFactory2D,
241254
"missing_files": og.check_regular_grid_missing_files2D,
255+
"is_loadable": og.is_regular_grid_loadable2D,
242256
"load": og.load_regular_grid2D,
243257
"is_saveable": og.is_regular_grid_saveable2D,
244258
"save": og.save_regular_grid2D,
@@ -257,6 +271,7 @@ def geode_objects_dict():
257271
"input_factory": og.RegularGridInputFactory3D,
258272
"output_factory": og.RegularGridOutputFactory3D,
259273
"missing_files": og.check_regular_grid_missing_files3D,
274+
"is_loadable": og.is_regular_grid_loadable3D,
260275
"load": og.load_regular_grid3D,
261276
"is_saveable": og.is_regular_grid_saveable3D,
262277
"save": og.save_regular_grid3D,
@@ -275,6 +290,7 @@ def geode_objects_dict():
275290
"input_factory": og.SectionInputFactory,
276291
"output_factory": og.SectionOutputFactory,
277292
"missing_files": og.check_section_missing_files,
293+
"is_loadable": og.is_section_loadable,
278294
"load": og.load_section,
279295
"is_saveable": og.is_section_saveable,
280296
"save": og.save_section,
@@ -295,6 +311,7 @@ def geode_objects_dict():
295311
"input_factory": og_gs.StructuralModelInputFactory,
296312
"output_factory": og_gs.StructuralModelOutputFactory,
297313
"missing_files": og_gs.check_structural_model_missing_files,
314+
"is_loadable": og_gs.is_structural_model_loadable,
298315
"load": og_gs.load_structural_model,
299316
"is_saveable": og_gs.is_structural_model_saveable,
300317
"save": og_gs.save_structural_model,
@@ -314,6 +331,7 @@ def geode_objects_dict():
314331
"input_factory": og.TetrahedralSolidInputFactory3D,
315332
"output_factory": og.TetrahedralSolidOutputFactory3D,
316333
"missing_files": og.check_tetrahedral_solid_missing_files3D,
334+
"is_loadable": og.is_tetrahedral_solid_loadable3D,
317335
"load": og.load_tetrahedral_solid3D,
318336
"is_saveable": og.is_tetrahedral_solid_saveable3D,
319337
"save": og.save_tetrahedral_solid3D,
@@ -333,6 +351,7 @@ def geode_objects_dict():
333351
"input_factory": og.TriangulatedSurfaceInputFactory2D,
334352
"output_factory": og.TriangulatedSurfaceOutputFactory2D,
335353
"missing_files": og.check_triangulated_surface_missing_files2D,
354+
"is_loadable": og.is_triangulated_surface_loadable2D,
336355
"load": og.load_triangulated_surface2D,
337356
"is_saveable": og.is_triangulated_surface_saveable2D,
338357
"save": og.save_triangulated_surface2D,
@@ -352,6 +371,7 @@ def geode_objects_dict():
352371
"input_factory": og.TriangulatedSurfaceInputFactory3D,
353372
"output_factory": og.TriangulatedSurfaceOutputFactory3D,
354373
"missing_files": og.check_triangulated_surface_missing_files3D,
374+
"is_loadable": og.is_triangulated_surface_loadable3D,
355375
"load": og.load_triangulated_surface3D,
356376
"is_saveable": og.is_triangulated_surface_saveable3D,
357377
"save": og.save_triangulated_surface3D,
@@ -371,6 +391,7 @@ def geode_objects_dict():
371391
"input_factory": og.VertexSetInputFactory,
372392
"output_factory": og.VertexSetOutputFactory,
373393
"missing_files": og.check_vertex_set_missing_files,
394+
"is_loadable": og.is_vertex_set_loadable,
374395
"load": og.load_vertex_set,
375396
"is_saveable": og.is_vertex_set_saveable,
376397
"save": og.save_vertex_set,

0 commit comments

Comments
 (0)