Source code for febio_python.feb.feb_version_handler
from._feb_25importFeb25from._feb_30importFeb30from._feb_40importFeb40from.basesimportFebBaseObjectfromtypingimportUnionfromxml.etreeimportElementTreeasETfrompathlibimportPath# Create a type for the different versions of FEBFebType=Union[Feb25,Feb30,Feb40]
[docs]defFeb(filepath:Union[str,Path]=None,tree:Union[ET.ElementTree,None]=None,root:Union[ET.Element,None]=None,version:float=None)->FebType:"""Create a FEB object based on the version of the FEB. """# version = determine_version(filepath)ifversionisNone:version=FebBaseObject(tree=tree,root=root,filepath=filepath).versionifisinstance(version,(str)):try:version=float(str)exceptExceptionase:raiseRuntimeError(f"Version should be a float, not {type(version)}")fromeifversion==2.5:returnFeb25(tree=tree,root=root,filepath=filepath)elifversion==3.0:returnFeb30(tree=tree,root=root,filepath=filepath)elifversion==4.0:returnFeb40(tree=tree,root=root,filepath=filepath)else:raiseValueError(f"Unsupported version: {version}. Supported versions are 2.5, 3.0 and 4.0.")