From d555ed611a69cc052bd90f4a2e17455ecf6f790c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 15:14:28 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- macros/REST_ListMacros.C | 112 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/macros/REST_ListMacros.C b/macros/REST_ListMacros.C index 55accbda5..4333dead8 100644 --- a/macros/REST_ListMacros.C +++ b/macros/REST_ListMacros.C @@ -13,40 +13,36 @@ using namespace std; //*** Lists all the official macros together with its documentation //*** //******************************************************************************************************* -Int_t REST_ListMacros( int details = 0, std::string onlyThisMacro = "") { +Int_t REST_ListMacros(int details = 0, std::string onlyThisMacro = "") { string macrosPath = (string)getenv("REST_PATH") + "/macros"; vector directories = TRestTools::GetSubdirectories(macrosPath); cout << endl; cout << "Entering directory : " << macrosPath << endl; vector main_files = TRestTools::GetFilesMatchingPattern(macrosPath + "/REST_*.C"); - if( details ) - { - for (int m = 0; m < main_files.size(); m++) { - std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second; - if( !onlyThisMacro.empty() && onlyThisMacro != macro ) - continue; - cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; - cout << " ++ " - << " Macro : " << macro << endl; - std::ifstream t(main_files[m]); - std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); + if (details) { + for (int m = 0; m < main_files.size(); m++) { + std::string macro = TRestTools::SeparatePathAndName(main_files[m]).second; + if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue; + cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; + cout << " ++ " + << " Macro : " << macro << endl; + std::ifstream t(main_files[m]); + std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); - std::vector lines = REST_StringHelper::Split(str, "\n"); + std::vector lines = REST_StringHelper::Split(str, "\n"); - cout << " ++ " << endl; - for (int l = 0; l < lines.size(); l++) - if (lines[l].find("//*** ") != string::npos) - cout << " ++ " << lines[l].substr(6, -1) << endl; - cout << " ++ " << endl; - } - cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; - } - else - { - for (int m = 0; m < main_files.size(); m++) { - cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl; - } + cout << " ++ " << endl; + for (int l = 0; l < lines.size(); l++) + if (lines[l].find("//*** ") != string::npos) + cout << " ++ " << lines[l].substr(6, -1) << endl; + cout << " ++ " << endl; + } + cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; + } else { + for (int m = 0; m < main_files.size(); m++) { + cout << " + " << TRestTools::SeparatePathAndName(main_files[m]).second << endl; + } } for (int n = 0; n < directories.size(); n++) { @@ -56,40 +52,40 @@ Int_t REST_ListMacros( int details = 0, std::string onlyThisMacro = "") { if (directories[n].find("/macros/mac/") != string::npos) continue; vector files = TRestTools::GetFilesMatchingPattern(directories[n] + "/REST_*.C"); - if( details ) - { - for (int m = 0; m < files.size(); m++) { - std::string macro = TRestTools::SeparatePathAndName(files[m]).second; - if( !onlyThisMacro.empty() && onlyThisMacro != macro ) - continue; - cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; - cout << " ++ Macro : " << macro << endl; - std::ifstream t(files[m]); - std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); + if (details) { + for (int m = 0; m < files.size(); m++) { + std::string macro = TRestTools::SeparatePathAndName(files[m]).second; + if (!onlyThisMacro.empty() && onlyThisMacro != macro) continue; + cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + << endl; + cout << " ++ Macro : " << macro << endl; + std::ifstream t(files[m]); + std::string str((std::istreambuf_iterator(t)), std::istreambuf_iterator()); - std::vector lines = REST_StringHelper::Split(str, "\n"); + std::vector lines = REST_StringHelper::Split(str, "\n"); - cout << " ++ " << endl; - for (int l = 0; l < lines.size(); l++) - if (lines[l].find("//*** ") != string::npos) - cout << " ++ " << lines[l].substr(6, -1) << endl; - cout << " ++ " << endl; - } - cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; - } - else - { - for (int m = 0; m < files.size(); m++) { - cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl; - } - std::cout << std::endl; - std::cout << " ------- " << std::endl; - std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:" << std::endl; - std::cout << "Execute: restListMacros 1" << std::endl; - std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C filename as argument" << std::endl; - std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl; - std::cout << " ------- " << std::endl; - } + cout << " ++ " << endl; + for (int l = 0; l < lines.size(); l++) + if (lines[l].find("//*** ") != string::npos) + cout << " ++ " << lines[l].substr(6, -1) << endl; + cout << " ++ " << endl; + } + cout << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl; + } else { + for (int m = 0; m < files.size(); m++) { + cout << " + " << TRestTools::SeparatePathAndName(files[m]).second << endl; + } + std::cout << std::endl; + std::cout << " ------- " << std::endl; + std::cout << "IMPORTANT. To get a more detailed macro documentation enable the details argument:" + << std::endl; + std::cout << "Execute: restListMacros 1" << std::endl; + std::cout << "OR if you want to show only the documentation of a given macro, add the macro.C " + "filename as argument" + << std::endl; + std::cout << "Execute: restListMacros 1 REST_CheckValidRuns.C" << std::endl; + std::cout << " ------- " << std::endl; + } } return 0; }