Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 27, 2024
1 parent 09975d8 commit d0a8ac7
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/urdf-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,30 @@ void setShowVisuals(GroupNode* gn, bool visual) {

QStringList rosPackagePath() {
const QString rosPathVar(qgetenv("ROS_PACKAGE_PATH"));
if (rosPathVar.toStdString() != "")
return rosPathVar.split(':');
if (rosPathVar.toStdString() != "") return rosPathVar.split(':');
const QString amentPrefixPath(qgetenv("AMENT_PREFIX_PATH"));
if (amentPrefixPath.toStdString() != ""){
if (amentPrefixPath.toStdString() != "") {
QStringList paths(amentPrefixPath.split(':'));
QStringList res;
for (const auto &path : paths) {
for (const auto& path : paths) {
res.append(path + QString("/share"));
}
return res;
}
throw std::invalid_argument(
"neither ROS_PACKAGE_PATH nor AMENT_PREFIX_PATH environment variables is "
"defined.");
throw std::invalid_argument(
"neither ROS_PACKAGE_PATH nor AMENT_PREFIX_PATH environment variables is "
"defined.");
}

std::string getFilename(const QString& input) {
if (input.startsWith("package://")) {
QStringList rosPaths;
try{
try {
rosPaths = rosPackagePath();
} catch (const std::invalid_argument& exc){
throw std::invalid_argument(std::string("Input path: \"") +
input.toStdString() + std::string("\" starts with \"package://\", but ")
+ exc.what());
} catch (const std::invalid_argument& exc) {
throw std::invalid_argument(
std::string("Input path: \"") + input.toStdString() +
std::string("\" starts with \"package://\", but ") + exc.what());
}
for (int i = 0; i < rosPaths.size(); ++i) {
QFileInfo fileInfo(rosPaths[i] + '/' + input.right(input.size() - 10));
Expand Down

0 comments on commit d0a8ac7

Please sign in to comment.