Skip to content

Commit a512344

Browse files
feat: Add function to query all elements status returning a dictionary
1 parent e64fd9d commit a512344

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

LoopProjectFile/LoopProjectFile.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,59 @@ def Get(filename, element, **kwargs):
407407
root.close()
408408
return response
409409

410+
# Check which element are valid
411+
def CheckValidElements(filename, verbose=False):
412+
"""
413+
**CheckValidElements** - A function to check through a Loop Project File's
414+
elements to see whether there is information in each element
415+
416+
Parameters
417+
----------
418+
filename: string
419+
The name of the file to load data from
420+
verbose: bool
421+
A flag to indicate a higher level of console logging (more if True)
422+
423+
Returns
424+
-------
425+
dict or None
426+
A dictionary of all the elements with a boolean indicating if the
427+
element contains information
428+
429+
"""
430+
elements = {
431+
"version":False,
432+
"extents":False,
433+
"strModel":False,
434+
"faultObservations":False,
435+
"foldObservations":False,
436+
"foliationObservations":False,
437+
"discontinuityObservations":False,
438+
"stratigraphicObservations":False,
439+
"contacts":False,
440+
"drillholeObservations":False,
441+
"drillholeSurveys":False,
442+
"drillholeProperties":False,
443+
"stratigraphicLog":False,
444+
"faultLog":False,
445+
"foldLog":False,
446+
"foliationLog":False,
447+
"discontinuityLog":False,
448+
"drillholeLog":False,
449+
"dataCollectionConfig":False,
450+
"dataCollectionSources":False,
451+
"dataCollectionRawSourceData":False,
452+
"eventRelationships":False,
453+
"structuralModelsConfig":False,
454+
}
455+
if (not CheckFileIsLoopProjectFile(filename)):
456+
if (verbose):
457+
print(f"{filename} is not a valid loop project file")
458+
return None
459+
else:
460+
for element in elements:
461+
elements[element] = Get(filename, element)["errorFlag"]
462+
return elements
410463

411464
# Check full project structure
412465
def CheckFileValid(filename, verbose=False):

0 commit comments

Comments
 (0)