SCRIPT: wpiformat

This commit is contained in:
PJ Reiniger
2025-11-07 20:01:58 -05:00
committed by Peter Johnson
parent ae6bdc9d25
commit 2109161534
749 changed files with 5504 additions and 3936 deletions

View File

@@ -71,8 +71,9 @@ bool ReadCameraConfig(const wpi::util::json& config) {
try {
c.name = config.at("name").get<std::string>();
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read camera name: {}\n",
configFile, e.what());
wpi::util::print(stderr,
"config error in '{}': could not read camera name: {}\n",
configFile, e.what());
return false;
}
@@ -80,9 +81,9 @@ bool ReadCameraConfig(const wpi::util::json& config) {
try {
c.path = config.at("path").get<std::string>();
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr,
"config error in '{}': camera '{}': could not read path: {}\n",
configFile, c.name, e.what());
wpi::util::print(
stderr, "config error in '{}': camera '{}': could not read path: {}\n",
configFile, c.name, e.what());
return false;
}
@@ -97,7 +98,7 @@ bool ReadConfig() {
auto fileBuffer = wpi::util::MemoryBuffer::GetFile(configFile);
if (!fileBuffer) {
wpi::util::print(stderr, "could not open '{}': {}\n", configFile,
fileBuffer.error().message());
fileBuffer.error().message());
return false;
}
@@ -107,14 +108,14 @@ bool ReadConfig() {
j = wpi::util::json::parse(fileBuffer.value()->GetCharBuffer());
} catch (const wpi::util::json::parse_error& e) {
wpi::util::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
e.byte, e.what());
e.byte, e.what());
return false;
}
// top level must be an object
if (!j.is_object()) {
wpi::util::print(stderr, "config error in '{}': must be JSON object\n",
configFile);
configFile);
return false;
}
@@ -122,8 +123,9 @@ bool ReadConfig() {
try {
team = j.at("team").get<unsigned int>();
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read team number: {}\n",
configFile, e.what());
wpi::util::print(stderr,
"config error in '{}': could not read team number: {}\n",
configFile, e.what());
return false;
}
@@ -142,8 +144,9 @@ bool ReadConfig() {
configFile, str);
}
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read ntmode: {}\n",
configFile, e.what());
wpi::util::print(stderr,
"config error in '{}': could not read ntmode: {}\n",
configFile, e.what());
}
}
@@ -155,8 +158,9 @@ bool ReadConfig() {
}
}
} catch (const wpi::util::json::exception& e) {
wpi::util::print(stderr, "config error in '{}': could not read cameras: {}\n",
configFile, e.what());
wpi::util::print(stderr,
"config error in '{}': could not read cameras: {}\n",
configFile, e.what());
return false;
}