mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Fix import of well paths and well log files from Python when the folder is not provided
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "WellLogCommands/RicWellLogsImportFileFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimWellLogFile.h"
|
||||
|
||||
#include <QDir>
|
||||
@@ -52,15 +53,24 @@ RicfCommandResponse RicfImportWellLogFiles::execute()
|
||||
QStringList errorMessages, warningMessages;
|
||||
QStringList wellLogFilePaths;
|
||||
|
||||
QDir wellPathFolder( m_wellLogFileFolder );
|
||||
if ( wellPathFolder.exists() )
|
||||
QDir wellLogDir;
|
||||
if ( m_wellLogFileFolder().isEmpty() )
|
||||
{
|
||||
wellLogDir = QDir( RiaApplication::instance()->startDir() );
|
||||
}
|
||||
else
|
||||
{
|
||||
wellLogDir = QDir( m_wellLogFileFolder );
|
||||
}
|
||||
|
||||
if ( !m_wellLogFileFolder().isEmpty() )
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << RicWellLogsImportFileFeature::wellLogFileNameFilters();
|
||||
QStringList relativePaths = wellPathFolder.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot );
|
||||
QStringList relativePaths = wellLogDir.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot );
|
||||
for ( QString relativePath : relativePaths )
|
||||
{
|
||||
wellLogFilePaths.push_back( wellPathFolder.absoluteFilePath( relativePath ) );
|
||||
wellLogFilePaths.push_back( wellLogDir.absoluteFilePath( relativePath ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -74,6 +84,10 @@ RicfCommandResponse RicfImportWellLogFiles::execute()
|
||||
{
|
||||
wellLogFilePaths.push_back( wellLogFilePath );
|
||||
}
|
||||
else if ( QFileInfo::exists( wellLogDir.absoluteFilePath( wellLogFilePath ) ) )
|
||||
{
|
||||
wellLogFilePaths.push_back( wellLogDir.absoluteFilePath( wellLogFilePath ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( wellLogFilePath + " doesn't exist" );
|
||||
|
||||
@@ -71,21 +71,32 @@ RicfCommandResponse RicImportWellPaths::execute()
|
||||
QStringList errorMessages, warningMessages;
|
||||
QStringList wellPathFiles;
|
||||
|
||||
QDir wellPathFolder( m_wellPathFolder );
|
||||
|
||||
if ( wellPathFolder.exists() )
|
||||
QDir wellPathDir;
|
||||
if ( m_wellPathFolder().isEmpty() )
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << RicImportWellPaths::wellPathNameFilters();
|
||||
QStringList relativePaths = wellPathFolder.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot );
|
||||
for ( QString relativePath : relativePaths )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathFolder.absoluteFilePath( relativePath ) );
|
||||
}
|
||||
wellPathDir = QDir( RiaApplication::instance()->startDir() );
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( m_wellPathFolder() + " does not exist" );
|
||||
wellPathDir = QDir( m_wellPathFolder );
|
||||
}
|
||||
|
||||
if ( !m_wellPathFolder().isEmpty() )
|
||||
{
|
||||
if ( wellPathDir.exists() )
|
||||
{
|
||||
QStringList nameFilters;
|
||||
nameFilters << RicImportWellPaths::wellPathNameFilters();
|
||||
QStringList relativePaths = wellPathDir.entryList( nameFilters, QDir::Files | QDir::NoDotAndDotDot );
|
||||
for ( QString relativePath : relativePaths )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathDir.absoluteFilePath( relativePath ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( wellPathDir.absolutePath() + " does not exist" );
|
||||
}
|
||||
}
|
||||
|
||||
for ( QString wellPathFile : m_wellPathFiles() )
|
||||
@@ -94,6 +105,10 @@ RicfCommandResponse RicImportWellPaths::execute()
|
||||
{
|
||||
wellPathFiles.push_back( wellPathFile );
|
||||
}
|
||||
else if ( QFileInfo::exists( wellPathDir.absoluteFilePath( wellPathFile ) ) )
|
||||
{
|
||||
wellPathFiles.push_back( wellPathDir.absoluteFilePath( wellPathFile ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessages << ( wellPathFile + " does not exist" );
|
||||
|
||||
Reference in New Issue
Block a user