Commit 9b30271e authored by David Fairbrother's avatar David Fairbrother
Browse files

Rename FileFinderUtils -> FileFinderHelpers

Renames the class and associated files, as utils is more generic when
these are really a collection of helpers for users. As under the hood
it's using FileFinder but not supplimenting the functionality
parent 5a1b0c25
......@@ -39,7 +39,7 @@ set(SRC_FILES
src/Expression.cpp
src/FileBackedExperimentInfo.cpp
src/FileFinder.cpp
src/FileFinderUtils.cpp
src/FileFinderHelpers.cpp
src/FileLoaderRegistry.cpp
src/FileProperty.cpp
src/FrameworkManager.cpp
......@@ -211,7 +211,7 @@ set(INC_FILES
inc/MantidAPI/Expression.h
inc/MantidAPI/FileBackedExperimentInfo.h
inc/MantidAPI/FileFinder.h
inc/MantidAPI/FileFinderUtils.h
inc/MantidAPI/FileFinderHelpers.h
inc/MantidAPI/FileLoaderRegistry.h
inc/MantidAPI/FileProperty.h
inc/MantidAPI/FrameworkManager.h
......@@ -407,7 +407,7 @@ set(TEST_FILES
ExpressionTest.h
FileBackedExperimentInfoTest.h
FileFinderTest.h
FileFinderUtilsTest.h
FileFinderHelpersTest.h
FilePropertyTest.h
FrameworkManagerTest.h
FuncMinimizerFactoryTest.h
......
......@@ -13,7 +13,7 @@
namespace Mantid::API {
class MANTID_API_DLL FileFinderUtils {
class MANTID_API_DLL FileFinderHelpers {
public:
/// Search instrument directories for Parameter file,
/// return full path name if found, else "".
......
......@@ -5,7 +5,7 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/ExperimentInfo.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/InstrumentDataService.h"
#include "MantidAPI/ResizeRectangularDetectorHelper.h"
#include "MantidAPI/Run.h"
......@@ -1099,7 +1099,7 @@ void ExperimentInfo::setInstumentFromXML(const std::string &nxFilename,
} else {
// XML was not included or was empty
// Use the instrument name to find the file
instrumentFilename = FileFinderUtils::getInstrumentFilename(
instrumentFilename = FileFinderHelpers::getInstrumentFilename(
instrumentName, getWorkspaceStartDate());
// And now load the contents
instrumentXml = loadInstrumentXML(instrumentFilename);
......
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/DateAndTime.h"
......@@ -23,7 +23,7 @@ using namespace Poco::XML;
namespace {
/// static logger object
Mantid::Kernel::Logger g_log("FileFinderUtils");
Mantid::Kernel::Logger g_log("FileFinderHelpers");
// used to terminate SAX process
class DummyException {
......@@ -87,8 +87,8 @@ namespace Mantid::API {
*is found
*/
std::string
FileFinderUtils::getInstrumentFilename(const std::string &instrumentName,
const std::string &date) {
FileFinderHelpers::getInstrumentFilename(const std::string &instrumentName,
const std::string &date) {
const std::vector<std::string> validFormats = {"xml", "nxs", "hdf5"};
g_log.debug() << "Looking for instrument file for " << instrumentName
<< " that is valid on '" << date << "'\n";
......@@ -116,8 +116,8 @@ FileFinderUtils::getInstrumentFilename(const std::string &instrumentName,
/// Search the directory for the Parameter IDF file and return full path name if
/// found, else return "".
// directoryName must include a final '/'.
std::string FileFinderUtils::getFullPathParamIDF(std::string instName,
const std::string &dirHint) {
std::string FileFinderHelpers::getFullPathParamIDF(std::string instName,
const std::string &dirHint) {
constexpr auto lookupFile = [](const std::string &dir,
const std::string &filename) {
......@@ -208,7 +208,7 @@ std::string FileFinderUtils::getFullPathParamIDF(std::string instName,
* this date
* @return list of absolute paths for each valid file
*/
std::vector<std::string> FileFinderUtils::getResourceFilenames(
std::vector<std::string> FileFinderHelpers::getResourceFilenames(
const std::string &prefix, const std::vector<std::string> &fileFormats,
const std::vector<std::string> &directoryNames, const std::string &date) {
......@@ -218,8 +218,8 @@ std::vector<std::string> FileFinderUtils::getResourceFilenames(
const std::string now =
Types::Core::DateAndTime::getCurrentTime().toISO8601String();
// Recursively call this method, but with all parameters.
return FileFinderUtils::getResourceFilenames(prefix, fileFormats,
directoryNames, now);
return FileFinderHelpers::getResourceFilenames(prefix, fileFormats,
directoryNames, now);
}
// Join all the file formats into a single string
......@@ -314,9 +314,9 @@ std::vector<std::string> FileFinderUtils::getResourceFilenames(
* @param[out] outValidFrom :: Used to return valid-from date
* @param[out] outValidTo :: Used to return valid-to date
*/
void FileFinderUtils::getValidFromTo(const std::string &IDFfilename,
std::string &outValidFrom,
std::string &outValidTo) {
void FileFinderHelpers::getValidFromTo(const std::string &IDFfilename,
std::string &outValidFrom,
std::string &outValidTo) {
SAXParser pParser;
// Create on stack to ensure deletion. Relies on pParser also being local
// variable.
......
......@@ -6,7 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/DateAndTime.h"
......@@ -25,7 +25,7 @@ using namespace Mantid::Kernel;
using namespace Mantid::API;
using Mantid::Types::Core::DateAndTime;
class FileFinderUtilsTest : public CxxTest::TestSuite {
class FileFinderHelpersTest : public CxxTest::TestSuite {
public:
struct fromToEntry {
std::string path;
......@@ -54,7 +54,7 @@ public:
if (boost::regex_match(l_filenamePart, regex)) {
std::string validFrom, validTo;
FileFinderUtils::getValidFromTo(dir_itr->path(), validFrom, validTo);
FileFinderHelpers::getValidFromTo(dir_itr->path(), validFrom, validTo);
size_t found;
found = l_filenamePart.find("_Definition");
......@@ -102,16 +102,16 @@ public:
// Check that instrument dirs are searched correctly
const std::string expectedFileName = "GEM_parameters.xml";
const auto result = FileFinderUtils::getFullPathParamIDF("GEM");
const auto result = FileFinderHelpers::getFullPathParamIDF("GEM");
TS_ASSERT(boost::icontains(result, expectedFileName));
// Should be case insensitive
const auto mixedResult = FileFinderUtils::getFullPathParamIDF("GeM");
const auto mixedResult = FileFinderHelpers::getFullPathParamIDF("GeM");
TS_ASSERT_EQUALS(result, mixedResult);
}
void testFindIPFNonExistant() {
const auto result = FileFinderUtils::getFullPathParamIDF("NotThere");
const auto result = FileFinderHelpers::getFullPathParamIDF("NotThere");
TS_ASSERT_EQUALS("", result);
}
......@@ -124,7 +124,7 @@ public:
Poco::File fileHandle(expectedPath);
fileHandle.createFile();
const auto result = FileFinderUtils::getFullPathParamIDF("test", tmpDir);
const auto result = FileFinderHelpers::getFullPathParamIDF("test", tmpDir);
// Ensure file was found and it's in the tmp dir
TS_ASSERT(result.find(filename) != std::string::npos);
TS_ASSERT(result.find(tmpDir) != std::string::npos);
......@@ -133,14 +133,14 @@ public:
void testNonExistantIPFWithHint() {
const auto tmpDir = Poco::Path::temp();
const auto result =
FileFinderUtils::getFullPathParamIDF("notThere", tmpDir);
FileFinderHelpers::getFullPathParamIDF("notThere", tmpDir);
TS_ASSERT(result.empty());
}
//
void testHelperFunctions() {
ConfigService::Instance().updateFacilities();
FileFinderUtils helper;
FileFinderHelpers helper;
std::string boevs =
helper.getInstrumentFilename("BIOSANS", "2100-01-31 22:59:59");
TS_ASSERT(!boevs.empty());
......@@ -148,7 +148,7 @@ public:
//
void testHelper_TOPAZ_No_To_Date() {
FileFinderUtils helper;
FileFinderHelpers helper;
std::string boevs =
helper.getInstrumentFilename("TOPAZ", "2011-01-31 22:59:59");
TS_ASSERT(!boevs.empty());
......@@ -160,7 +160,7 @@ public:
const std::string testDir = instDir + "unit_testing";
ConfigService::Instance().setString("instrumentDefinition.directory",
testDir);
FileFinderUtils helper;
FileFinderHelpers helper;
std::string boevs =
helper.getInstrumentFilename("ARGUS", "1909-01-31 22:59:59");
TS_ASSERT_DIFFERS(boevs.find("TEST1_ValidDateOverlap"), std::string::npos);
......@@ -194,7 +194,7 @@ public:
void test_nexus_geometry_getInstrumentFilename() {
const std::string instrumentName = "LOKI";
FileFinderUtils info;
FileFinderHelpers info;
const auto path = info.getInstrumentFilename(instrumentName, "");
TS_ASSERT(!path.empty());
TS_ASSERT(
......
......@@ -7,7 +7,7 @@
#include "MantidAlgorithms/VesuvioL1ThetaResolution.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/SpectrumInfo.h"
......@@ -269,7 +269,7 @@ void VesuvioL1ThetaResolution::loadInstrument() {
MatrixWorkspace_sptr tempWS =
WorkspaceFactory::Instance().create("Workspace2D", 1, 1, 1);
const std::string vesuvioIPF =
FileFinderUtils::getInstrumentFilename("VESUVIO");
FileFinderHelpers::getInstrumentFilename("VESUVIO");
// Load an empty VESUVIO instrument workspace
IAlgorithm_sptr loadInst =
......
......@@ -5,7 +5,7 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/AppendGeometryToSNSNexus.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataObjects/Workspace2D.h"
......@@ -145,7 +145,7 @@ void AppendGeometryToSNSNexus::exec() {
// Now what is the instrument definition filename ?
// TODO: Modify to use /entry/instrument/instrument_xml/data after
// establishing a way to maintain ADARA Geometry Packet
m_idf_filename = FileFinderUtils::getInstrumentFilename(m_instrument);
m_idf_filename = FileFinderHelpers::getInstrumentFilename(m_instrument);
g_log.debug() << "Loading instrument definition from " << m_idf_filename
<< ".\n";
......
......@@ -6,7 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include <sstream>
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/SpectraAxis.h"
......@@ -105,7 +105,7 @@ void LoadDetectorsGroupingFile::exec() {
// empty -
// the most recent will be used.
const std::string instrumentFilename =
FileFinderUtils::getInstrumentFilename(instrumentName, date);
FileFinderHelpers::getInstrumentFilename(instrumentName, date);
// Load an instrument
Algorithm_sptr childAlg = this->createChildAlgorithm("LoadInstrument");
......
......@@ -5,7 +5,7 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/InstrumentDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
......@@ -139,7 +139,7 @@ void LoadInstrument::exec() {
"must be specified to load an instrument",
filename);
} else {
filename = FileFinderUtils::getInstrumentFilename(
filename = FileFinderHelpers::getInstrumentFilename(
instname, ws->getWorkspaceStartDate());
setPropertyValue("Filename", filename);
}
......@@ -265,7 +265,7 @@ void LoadInstrument::runLoadParameterFile(
std::string directoryName =
filename.substr(0, dir_end + 1); // include final '/'.
std::string fullPathParamIDF =
FileFinderUtils::getFullPathParamIDF(filename, directoryName);
FileFinderHelpers::getFullPathParamIDF(filename, directoryName);
if (!fullPathParamIDF.empty()) {
......
......@@ -6,7 +6,7 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadNXSPE.h"
#include "MantidAPI/ExperimentInfo.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/RegisterFileLoader.h"
......@@ -331,7 +331,7 @@ void LoadNXSPE::exec() {
// NB. LoadParameterFile must be used on a workspace with an instrument
if (!instrument_name.empty() && instrument_name != "NXSPE") {
std::string IDF_filename =
FileFinderUtils::getInstrumentFilename(instrument_name);
FileFinderHelpers::getInstrumentFilename(instrument_name);
std::string instrument_parfile =
IDF_filename.substr(0, IDF_filename.find("_Definition")) +
"_Parameters.xml";
......
......@@ -8,7 +8,7 @@
#include "MantidAPI/Axis.h"
#include "MantidAPI/CommonBinsValidator.h"
#include "MantidAPI/ExperimentInfo.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/Run.h"
......@@ -212,7 +212,7 @@ getInstrumentName(const Mantid::API::MatrixWorkspace_sptr &workspace) {
std::string getIDF(const Mantid::API::MatrixWorkspace_sptr &workspace) {
auto date = workspace->getWorkspaceStartDate();
auto instrumentName = getInstrumentName(workspace);
return FileFinderUtils::getInstrumentFilename(instrumentName, date);
return FileFinderHelpers::getInstrumentFilename(instrumentName, date);
}
void addDetectors(H5::Group &group,
......
......@@ -13,7 +13,7 @@
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/SpectrumInfo.h"
#include "MantidDataHandling/LoadMask.h"
#include "MantidDataObjects/MaskWorkspace.h"
......@@ -364,7 +364,7 @@ public:
TS_ASSERT(source);
std::string IDF_name =
API::FileFinderUtils::getInstrumentFilename("MARI", "");
API::FileFinderHelpers::getInstrumentFilename("MARI", "");
/*Fake export mask algorithm: */
std::string mask_contents("4 10-12 100 110 120 130 140 200 300");
......
......@@ -7,7 +7,7 @@
#include "NXcanSASTestHelper.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/Axis.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidDataHandling/NXcanSASDefinitions.h"
......@@ -35,7 +35,7 @@ getIDFfromWorkspace(const Mantid::API::MatrixWorkspace_sptr &workspace) {
auto instrument = workspace->getInstrument();
auto name = instrument->getFullName();
auto date = workspace->getWorkspaceStartDate();
return Mantid::API::FileFinderUtils::getInstrumentFilename(name, date);
return Mantid::API::FileFinderHelpers::getInstrumentFilename(name, date);
}
void setXValuesOn1DWorkspaceWithPointData(
......
......@@ -19,7 +19,7 @@ set(EXPORT_FILES
src/Exports/AlgorithmManager.cpp
src/Exports/AnalysisDataService.cpp
src/Exports/FileProperty.cpp
src/Exports/FileFinderUtils.cpp
src/Exports/FileFinderHelpers.cpp
src/Exports/MultipleFileProperty.cpp
src/Exports/FrameworkManager.cpp
src/Exports/ISpectrum.cpp
......
......@@ -5,7 +5,7 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/ExperimentInfo.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/SpectrumInfo.h"
......@@ -24,7 +24,7 @@
#include <boost/python/register_ptr_to_python.hpp>
using Mantid::API::ExperimentInfo;
using Mantid::API::FileFinderUtils;
using Mantid::API::FileFinderHelpers;
using Mantid::PythonInterface::Policies::RemoveConstSharedPtr;
using namespace Mantid::PythonInterface;
using namespace boost::python;
......@@ -34,11 +34,11 @@ GET_POINTER_SPECIALIZATION(ExperimentInfo)
/// Converter from C++ signature to python signature
// As we can't have two converters in the global namespace we will
// keep the converter with ExperimentInfo despite the C++ impl moving to
// FileFinderUtils for backwards compatibility and as there is a single user
// FileFinderHelpers for backwards compatibility and as there is a single user
list getResourceFilenames(const std::string &prefix, const list &fileFormats,
const list &directoryNames, const std::string &date) {
return Converters::ToPyList<std::string>()(
FileFinderUtils::getResourceFilenames(
FileFinderHelpers::getResourceFilenames(
prefix, Converters::PySequenceToVector<std::string>(fileFormats)(),
Converters::PySequenceToVector<std::string>(directoryNames)(), date));
}
......@@ -49,7 +49,7 @@ GNU_DIAG_OFF("unused-local-typedef")
GNU_DIAG_OFF("conversion")
/// Overload generator for getInstrumentFilename
BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrumentFilename_Overload,
FileFinderUtils::getInstrumentFilename, 1, 2)
FileFinderHelpers::getInstrumentFilename, 1, 2)
GNU_DIAG_ON("conversion")
GNU_DIAG_ON("unused-local-typedef")
......@@ -86,7 +86,7 @@ void export_ExperimentInfo() {
"file will encapsulate this date (e.g '1900-01-31 23:59:00')\n"
"\nreturns : list of absolute paths for each valid file\n")
.staticmethod("getResourceFilenames")
.def("getInstrumentFilename", &FileFinderUtils::getInstrumentFilename,
.def("getInstrumentFilename", &FileFinderHelpers::getInstrumentFilename,
getInstrumentFilename_Overload(
"Returns IDF filename", (arg("instrument"), arg("date") = "")))
.staticmethod("getInstrumentFilename")
......
......@@ -5,7 +5,7 @@
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidKernel/WarningSuppressions.h"
......@@ -22,11 +22,11 @@
#include <string>
using Mantid::API::FileFinderUtils;
using Mantid::API::FileFinderHelpers;
using namespace Mantid::PythonInterface;
using namespace boost::python;
GET_POINTER_SPECIALIZATION(FileFinderUtils)
GET_POINTER_SPECIALIZATION(FileFinderHelpers)
GNU_DIAG_OFF("unused-local-typedef")
// Ignore -Wconversion warnings coming from boost::python
......@@ -34,23 +34,23 @@ GNU_DIAG_OFF("unused-local-typedef")
GNU_DIAG_OFF("conversion")
/// Overload generator for getInstrumentFilename
BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrumentFilename_Overload,
FileFinderUtils::getInstrumentFilename, 1, 2)
FileFinderHelpers::getInstrumentFilename, 1, 2)
BOOST_PYTHON_FUNCTION_OVERLOADS(getIPFPath_Overload,
FileFinderUtils::getFullPathParamIDF, 1, 2)
FileFinderHelpers::getFullPathParamIDF, 1, 2)
GNU_DIAG_ON("conversion")
GNU_DIAG_ON("unused-local-typedef")
void exportFileFinderUtils() {
register_ptr_to_python<std::shared_ptr<FileFinderUtils>>();
void exportFileFinderHelpers() {
register_ptr_to_python<std::shared_ptr<FileFinderHelpers>>();
class_<FileFinderUtils>("FileFinderUtils", no_init)
class_<FileFinderHelpers>("FileFinderHelpers", no_init)
// -
.def("getInstrumentFilename", &FileFinderUtils::getInstrumentFilename,
.def("getInstrumentFilename", &FileFinderHelpers::getInstrumentFilename,
getInstrumentFilename_Overload(
"Returns IDF filename", (arg("instrument"), arg("date") = "")))
.staticmethod("getInstrumentFilename")
// -
.def("getIPFPath", &FileFinderUtils::getFullPathParamIDF,
.def("getIPFPath", &FileFinderHelpers::getFullPathParamIDF,
getIPFPath_Overload(
"Returns the full path to the given instrument parameter file "
"for the named instrument if it exists in the instrument search "
......
......@@ -7,7 +7,7 @@
#include "MantidQtWidgets/Common/SlitCalculator.h"
#include "MantidAPI/AlgorithmManager.h"
#include "MantidAPI/ExperimentInfo.h"
#include "MantidAPI/FileFinderUtils.h"
#include "MantidAPI/FileFinderHelpers.h"
#include "MantidAPI/Progress.h"
#include "MantidGeometry/Instrument/InstrumentDefinitionParser.h"
#include "MantidKernel/Strings.h"
......@@ -39,8 +39,8 @@ void SlitCalculator::setInstrument(const std::string &instrumentName) {
auto date =
Mantid::Types::Core::DateAndTime::getCurrentTime().toISO8601String();
// find the full path to the definition file
auto filename =
Mantid::API::FileFinderUtils::getInstrumentFilename(instrumentName, date);
auto filename = Mantid::API::FileFinderHelpers::getInstrumentFilename(
instrumentName, date);
// parse the XML that we have found for the definition
Mantid::Geometry::InstrumentDefinitionParser parser =
Mantid::Geometry::InstrumentDefinitionParser(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment