9#include <boost/python/class.hpp>
10#include <boost/python/list.hpp>
11#include <boost/python/reference_existing_object.hpp>
28 const bool useExtsOnly) {
30 std::vector<std::string> exts;
31 for (
int i = 0; i < len(exts_list); ++i)
32 exts.emplace_back(extract<std::string>(exts_list[i]));
39 auto paths = self.
findRuns(hintstr, exts, useExtsOnly);
40 std::vector<std::string> results;
41 results.reserve(paths.size());
42 std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](
const auto &p) { return p.string(); });
48 const bool ignoreDirs =
false) {
53 class_<FileFinderImpl, boost::noncopyable>(
"FileFinderImpl", no_init)
54 .def(
"getFullPath", &
getFullPathProxy, (arg(
"self"), arg(
"path"), arg(
"ignoreDirs") =
false),
55 "Return a full path to the given file if it can be found within "
56 "datasearch.directories paths. Directories can be ignored with "
57 "ignoreDirs=True. An empty string is returned otherwise.")
59 (arg(
"self"), arg(
"hintstr"), arg(
"exts_list") = list(), arg(
"useExtsOnly") =
false),
60 "Find a list of files file given a hint. "
61 "The hint can be a comma separated list of run numbers and can also "
62 "include ranges of runs, e.g. 123-135 or equivalently 123-35"
63 "If no instrument prefix is given then the current default is used."
64 "exts_list is an optional list containing strings of file "
65 "extensions to search."
66 "useExtsOnly is an optional bool. If it's true then don't use "
69 "Option to get if file finder should be case sensitive.")
71 "Option to set if file finder should be case sensitive.")
72 .def(
"Instance", &FileFinder::Instance, return_value_policy<reference_existing_object>(),
73 "Returns a reference to the FileFinder singleton instance")
74 .staticmethod(
"Instance");
std::vector< std::string > runFinderProxy(const FileFinderImpl &self, const std::string &hintstr, list exts_list, const bool useExtsOnly)
Runs FileFinder.findRuns after releasing the python GIL.
static std::string getFullPathProxy(const FileFinderImpl &self, const std::string &path, const bool ignoreDirs=false)
This class finds data files given an instrument name (optionally) and a run number.
bool getCaseSensitive() const
Option to get if file finder should be case sensitive.
std::filesystem::path getFullPath(const std::string &filename, const bool ignoreDirs=false) const
Return the full path to the file given its name.
void setCaseSensitive(const bool cs)
Option to set if file finder should be case sensitive.
std::vector< std::filesystem::path > findRuns(const std::string &hintstr, const std::vector< std::string > &exts={}, const bool useExtsOnly=false) const
Find a list of files file given a hint.
Defines a structure for releasing the Python GIL using the RAII pattern.
Mantid::Kernel::SingletonHolder< FileFinderImpl > FileFinder