hydra-eval-jobs: Support meta.license being a list

TODO: PostgreSQL has an array column type, we should use it for the
license and maintainers columns.
This commit is contained in:
Eelco Dolstra 2013-11-04 22:50:32 +01:00
parent 484bcd10e2
commit 32b6ddf772

View file

@ -109,6 +109,22 @@ static int queryMetaFieldInt(MetaInfo & meta, const string & name, int def)
}
static string queryMetaField(MetaInfo & meta, const string & name)
{
string res;
MetaValue value = meta[name];
if (value.type == MetaValue::tpString)
res = value.stringValue;
else if (value.type == MetaValue::tpStrings) {
foreach (Strings::const_iterator, i, value.stringValues) {
if (res.size() != 0) res += ", ";
res += *i;
}
}
return res;
}
static void findJobsWrapped(EvalState & state, XMLWriter & doc,
const ArgsUsed & argsUsed, const AutoArgs & argsLeft,
Value & v, const string & attrPath)
@ -136,8 +152,9 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
MetaInfo meta = drv.queryMetaInfo(state);
xmlAttrs["description"] = queryMetaFieldString(meta, "description");
xmlAttrs["longDescription"] = queryMetaFieldString(meta, "longDescription");
xmlAttrs["license"] = queryMetaFieldString(meta, "license");
xmlAttrs["license"] = queryMetaField(meta, "license");
xmlAttrs["homepage"] = queryMetaFieldString(meta, "homepage");
xmlAttrs["maintainers"] = queryMetaField(meta, "maintainers");
int prio = queryMetaFieldInt(meta, "schedulingPriority", 100);
xmlAttrs["schedulingPriority"] = int2String(prio);
@ -148,18 +165,6 @@ static void findJobsWrapped(EvalState & state, XMLWriter & doc,
int maxsilent = queryMetaFieldInt(meta, "maxSilent", 3600);
xmlAttrs["maxSilent"] = int2String(maxsilent);
string maintainers;
MetaValue value = meta["maintainers"];
if (value.type == MetaValue::tpString)
maintainers = value.stringValue;
else if (value.type == MetaValue::tpStrings) {
foreach (Strings::const_iterator, i, value.stringValues) {
if (maintainers.size() != 0) maintainers += ", ";
maintainers += *i;
}
}
xmlAttrs["maintainers"] = maintainers;
/* If this is an aggregate, then get its constituents. */
Bindings::iterator a = v.attrs->find(state.symbols.create("_hydraAggregate"));
if (a != v.attrs->end() && state.forceBool(*a->value)) {