From 916863f82ae304ff6f936701cbb058c5e7c2583a Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 7 Dec 2022 11:02:10 -0600 Subject: [PATCH] Renaming and docstring/comment updates --- include/openmc/file_utils.h | 8 +++++--- include/openmc/geometry_aux.h | 2 +- openmc/settings.py | 2 -- src/initialize.cpp | 6 ++++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/openmc/file_utils.h b/include/openmc/file_utils.h index 439af6ee08..cb52b33c89 100644 --- a/include/openmc/file_utils.h +++ b/include/openmc/file_utils.h @@ -11,7 +11,8 @@ namespace openmc { //! Determine if a path is a directory //! \param[in] path Path to check //! \return Whether the path is a directory -inline bool is_dir(const std::string& path) { +inline bool dir_exists(const std::string& path) +{ struct stat s; if (stat(path.c_str(), &s) != 0) return false; @@ -23,8 +24,9 @@ inline bool is_dir(const std::string& path) { //! \return Whether file exists inline bool file_exists(const std::string& filename) { - // rule out file being a directory path - if (is_dir(filename)) return false; + // rule out file being a path to a directory + if (dir_exists(filename)) + return false; std::ifstream s {filename}; return s.good(); diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index a4c506c31a..cf62debc04 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -24,7 +24,7 @@ extern std::unordered_map universe_level_counts; void read_geometry_xml(); //! Read geometry from XML node -//! \param[in] root node of geometry XML element +//! \param[in] root node of geometry XML element void read_geometry_xml(pugi::xml_node root); //============================================================================== diff --git a/openmc/settings.py b/openmc/settings.py index 3f56f729f3..294aea7a3b 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -1560,8 +1560,6 @@ class Settings: mesh_memo : set of ints A set of mesh IDs to keep track of whether a mesh has already been written. """ - # create a memo object if one isn't passed in already - mesh_memo = mesh_memo if mesh_memo else set() # Reset xml element tree element = ET.Element("settings") diff --git a/src/initialize.cpp b/src/initialize.cpp index 041712d5a2..3b332c3b27 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -283,7 +283,8 @@ int parse_command_line(int argc, char* argv[]) settings::path_input = std::string(argv[last_flag + 1]); // check that the path is either a valid directory or file - if (!is_dir(settings::path_input) && !file_exists(settings::path_input)) { + if (!dir_exists(settings::path_input) && + !file_exists(settings::path_input)) { fatal_error(fmt::format( "The path specified to the OpenMC executable '{}' does not exist.", settings::path_input)); @@ -309,7 +310,8 @@ bool read_model_xml() { model_filename.pop_back(); // if the current filename is a directory, append the default model filename - if (is_dir(model_filename)) model_filename += "/model.xml"; + if (dir_exists(model_filename)) + model_filename += "/model.xml"; // if this file doesn't exist, stop here if (!file_exists(model_filename)) return false;