///////////////////////////////////////////////////////////////////////////
| 944 | |
| 945 | //////////////////////////////////////////////////////////////////////////////// |
| 946 | std::string Context::getTaskContext(const std::string& kind, std::string name, |
| 947 | bool fallback /* = true */) { |
| 948 | // Consider currently selected context, if none specified |
| 949 | if (name.empty()) name = config.get("context"); |
| 950 | |
| 951 | // Detect if any context is set, and bail out if not |
| 952 | if (!name.empty()) |
| 953 | debug(format("Applying context '{1}'", name)); |
| 954 | else { |
| 955 | debug("No context set"); |
| 956 | return ""; |
| 957 | } |
| 958 | |
| 959 | // Figure out the context string for this kind (read/write) |
| 960 | std::string contextString = ""; |
| 961 | |
| 962 | if (!config.has("context." + name + "." + kind) && kind == "read") { |
| 963 | debug("Specific " + kind + " context for '" + name + "' not defined. "); |
| 964 | if (fallback) { |
| 965 | debug("Trying to interpret old-style context definition as read context."); |
| 966 | contextString = config.get("context." + name); |
| 967 | } |
| 968 | } else |
| 969 | contextString = config.get("context." + name + "." + kind); |
| 970 | |
| 971 | debug(format("Detected context string: {1}", contextString.empty() ? "(empty)" : contextString)); |
| 972 | return contextString; |
| 973 | } |
| 974 | |
| 975 | //////////////////////////////////////////////////////////////////////////////// |
| 976 | bool Context::color() { |
no test coverage detected