Skip to content

Commit

Permalink
param expansion - multiple aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
danovaro committed Jul 30, 2024
1 parent d007315 commit 9007862
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.18
1.11.19
12 changes: 6 additions & 6 deletions src/metkit/mars/TypeParam.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ std::string Rule::lookup(const MarsExpandContext& ctx, const std::string & s, bo
if (!paramid.empty()) {
return paramid;
}

return metkit::mars::MarsLanguage::bestMatch(c, s, defaultValues_, fail, false, defaultMapping_);
}

Expand Down Expand Up @@ -436,7 +437,7 @@ static void init() {

std::set<std::string> shortnames;
std::set<std::string> associatedIDs;

const eckit::Value pc = eckit::YAMLParser::decodeFile(LibMetkit::shortnameContextYamlFile());
ASSERT(pc.isList());

Expand All @@ -446,11 +447,10 @@ static void init() {

for (size_t i=0; i < keys.size(); i++) {
auto el = ids.element(keys[i]);
ASSERT(el.size() > 0);
auto val = el[0];

if (shortnames.find(val) != shortnames.end()) {
associatedIDs.emplace(keys[i]);
for (size_t j=0; j < el.size(); j++) {
if (shortnames.find(el[j]) != shortnames.end()) {
associatedIDs.emplace(keys[i]);
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions tests/test_expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,23 @@ CASE( "test_metkit_expand_param" ) {
EXPECT_EQUAL(params[4], "164");
EXPECT_EQUAL(params[5], "228");
}
{
const char* text = "retrieve,class=od,expver=1,stream=msmm,date=-1,time=0000,type=em,levtype=sfc,step=24,param=e";
MarsRequest r = MarsRequest::parse(text);
auto params = r.values("param");
EXPECT_EQUAL(params.size(), 1);

EXPECT_EQUAL(params[0], "172182");
}
{
const char* text = "retrieve,class=od,expver=1,stream=msmm,date=-1,time=0000,type=em,levtype=sfc,step=24,param=e/erate";
MarsRequest r = MarsRequest::parse(text);
auto params = r.values("param");
EXPECT_EQUAL(params.size(), 2);

EXPECT_EQUAL(params[0], "172182");
EXPECT_EQUAL(params[1], "172182");
}
}

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit 9007862

Please sign in to comment.