#6962 Python: case.replace use simulationName

In Python, the folder name is added to simulation name to a combined name like 'folderName--simulationName' for the imported Grid Model. Only the simulationName should be used.
This commit is contained in:
Magne Sjaastad 2020-11-11 14:26:49 +01:00
parent a0bc915b18
commit 1f2b1f208c
2 changed files with 4 additions and 9 deletions

View File

@ -279,14 +279,9 @@ QString RiaProjectModifier::makeFilePathAbsolute( const QString& relOrAbsolutePa
//--------------------------------------------------------------------------------------------------
QString RiaProjectModifier::caseNameFromGridFileName( const QString& fullGridFilePathName )
{
QString fn = QDir::fromNativeSeparators( fullGridFilePathName );
QFileInfo fi( fullGridFilePathName );
// Extract file name plus the 'deepest' directory
QString deepestDirPlusFileName = fn.section( '/', -2, -1 );
deepestDirPlusFileName.replace( "/", "--" );
return deepestDirPlusFileName;
return fi.baseName();
}
//--------------------------------------------------------------------------------------------------

View File

@ -163,14 +163,14 @@ def test_replaceCase(rips_instance, initialize_test):
case.replace(new_grid_file=case_path)
# Check that the case object has been changed
assert(case.name == "Real0--BRUGGE_0000.EGRID")
assert(case.name == "BRUGGE_0000")
assert(case.id == 0)
cases = rips_instance.project.cases()
assert(len(cases) is 1)
# Check that retrieving the case object again will yield the changed object
case = project.case(case_id=0)
assert(case.name == "Real0--BRUGGE_0000.EGRID")
assert(case.name == "BRUGGE_0000")
assert(case.id == 0)