Add function to get the data directories Cantera searches

This commit is contained in:
Bryan W. Weber 2016-10-26 00:50:17 -04:00 committed by Ray Speth
parent b01f9cd1e7
commit d1c2ec48e7
6 changed files with 31 additions and 0 deletions

View file

@ -47,3 +47,4 @@ Utility Functions
-----------------
.. autofunction:: add_directory
.. autofunction:: get_data_directories

View file

@ -114,6 +114,9 @@ std::string findInputFile(const std::string& name);
//! @copydoc Application::addDataDirectory
void addDirectory(const std::string& dir);
//! @copydoc Application::getDataDirectories
std::string getDataDirectories(const std::string& sep);
//@}
//! Delete and free all memory associated with the application

View file

@ -47,6 +47,7 @@ cdef extern from "cantera/base/stringUtils.h" namespace "Cantera":
cdef extern from "cantera/base/global.h" namespace "Cantera":
cdef void CxxAddDirectory "Cantera::addDirectory" (string)
cdef string CxxGetDataDirectories "Cantera::getDataDirectories" (string)
cdef size_t CxxNpos "Cantera::npos"
cdef void CxxAppdelete "Cantera::appdelete" ()
cdef XML_Node* CxxGetXmlFile "Cantera::get_XML_File" (string) except +translate_exception

View file

@ -2,6 +2,7 @@
# at http://www.cantera.org/license.txt for license and copyright information.
import sys
import os
from cpython.ref cimport PyObject
cdef int _pythonMajorVersion = sys.version_info[0]
@ -31,6 +32,10 @@ def add_directory(directory):
""" Add a directory to search for Cantera data files. """
CxxAddDirectory(stringify(directory))
def get_data_directories():
""" Get a list of the directories Cantera searches for data files. """
return pystr(CxxGetDataDirectories(stringify(os.pathsep))).split(os.pathsep)
__sundials_version__ = '.'.join(str(get_sundials_version()))
__version__ = pystr(get_cantera_version())

View file

@ -9,6 +9,8 @@
#include "cantera/base/config.h"
#include "cantera/base/logger.h"
#include <boost/algorithm/string/join.hpp>
#include <set>
#include <thread>
@ -265,6 +267,20 @@ public:
*/
std::string findInputFile(const std::string& name);
//! Get the Cantera data directories
/*!
* This routine returns a string including the names of all the
* directories searched by Cantera for data files.
*
* @param sep Separator to use between directories in the string
* @return A string of directories separated by the input sep
*
* @ingroup inputfiles
*/
std::string getDataDirectories(const std::string& sep) {
return boost::algorithm::join(inputDirs, sep);
}
//! Return a pointer to the XML tree for a Cantera input file.
/*!
* This routine will find the file and read the XML file into an XML tree

View file

@ -137,6 +137,11 @@ void addDirectory(const std::string& dir)
app()->addDataDirectory(dir);
}
std::string getDataDirectories(const std::string& sep)
{
return app()->getDataDirectories(sep);
}
std::string findInputFile(const std::string& name)
{
return app()->findInputFile(name);