mirror of
https://github.com/quatalog/quatalog.git
synced 2024-09-28 20:48:57 +00:00
Fix issue where attributes were not removed properly
This commit is contained in:
parent
3a8ba42ac4
commit
e2c84869b4
|
@ -38,7 +38,7 @@ void handle_multiple_instructors(const std::string&,std::unordered_set<std::stri
|
||||||
void handle_attributes(const Json::Value&,const std::string&,Json::Value&,Json::Value&);
|
void handle_attributes(const Json::Value&,const std::string&,Json::Value&,Json::Value&);
|
||||||
void handle_term_attribute(const std::string&,Json::Value&);
|
void handle_term_attribute(const std::string&,Json::Value&);
|
||||||
void handle_attribute(const std::string&,Json::Value&,Json::Value&);
|
void handle_attribute(const std::string&,Json::Value&,Json::Value&);
|
||||||
template<typename Functor> void iterateOnDelimitedString(const std::string&,const std::regex&,const Functor&);
|
template<typename Functor> void iterate_on_delimited_string(const std::string&,const std::regex&,const Functor&);
|
||||||
void handle_prereqs(const Json::Value&,const std::string&,Json::Value&,const Json::Value&);
|
void handle_prereqs(const Json::Value&,const std::string&,Json::Value&,const Json::Value&);
|
||||||
|
|
||||||
int main(const int argc,
|
int main(const int argc,
|
||||||
|
@ -287,7 +287,7 @@ void handle_instructors(const Json::Value& section,
|
||||||
|
|
||||||
void handle_multiple_instructors(const std::string& instructor_str,
|
void handle_multiple_instructors(const std::string& instructor_str,
|
||||||
std::unordered_set<std::string>& instructors) {
|
std::unordered_set<std::string>& instructors) {
|
||||||
iterateOnDelimitedString(instructor_str,
|
iterate_on_delimited_string(instructor_str,
|
||||||
std::regex(", ?"),
|
std::regex(", ?"),
|
||||||
[&](const std::string& inst_str) {
|
[&](const std::string& inst_str) {
|
||||||
if(inst_str == "TBA") return;
|
if(inst_str == "TBA") return;
|
||||||
|
@ -304,7 +304,7 @@ void handle_attributes(const Json::Value& section,
|
||||||
Json::Value attributes = Json::arrayValue;
|
Json::Value attributes = Json::arrayValue;
|
||||||
term_attributes = Json::arrayValue;
|
term_attributes = Json::arrayValue;
|
||||||
|
|
||||||
iterateOnDelimitedString(section["attribute"].asString(),
|
iterate_on_delimited_string(section["attribute"].asString(),
|
||||||
std::regex(" and |, "),
|
std::regex(" and |, "),
|
||||||
[&](const std::string& attr_str) {
|
[&](const std::string& attr_str) {
|
||||||
handle_attribute(attr_str,
|
handle_attribute(attr_str,
|
||||||
|
@ -312,7 +312,6 @@ void handle_attributes(const Json::Value& section,
|
||||||
term_attributes);
|
term_attributes);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!attributes.empty())
|
|
||||||
out_prereqs[course_id]["attributes"] = attributes;
|
out_prereqs[course_id]["attributes"] = attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +336,7 @@ void handle_term_attribute(const std::string& attribute,
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
void iterateOnDelimitedString(const std::string& str,
|
void iterate_on_delimited_string(const std::string& str,
|
||||||
const std::regex& delim,
|
const std::regex& delim,
|
||||||
const Functor& callback) {
|
const Functor& callback) {
|
||||||
// This mess is basically C++'s string split but not using
|
// This mess is basically C++'s string split but not using
|
||||||
|
|
Loading…
Reference in a new issue