better regex, avoid Python keyword name collisions: WHERE = type == "btrfs" or a_pass == "1"
other usage: WHERE = type == "btrfs" or a_pass == "1"; r[0] = "TROLL!!!"
--- a/src/PythonHandler.h Sat Dec 15 00:44:04 2018 +0100
+++ b/src/PythonHandler.h Sat Dec 15 01:02:49 2018 +0100
@@ -48,8 +48,8 @@
class PythonHandler : public RelationalReaderStringHadler {
private:
- const wregex ATTRIBUTE_NAMES_ALLOWED = wregex(L"[a-zA-Z0-9_]");
- const wregex ATTRIBUTE_NAMES_DISALLOWED = wregex(L"WHERE|and|or|[0-9_].*"); // TODO: more keywords
+ const wregex ATTRIBUTE_NAMES_ALLOWED = wregex(L"[a-zA-Z0-9_]+");
+ const wregex ATTRIBUTE_NAMES_DISALLOWED = wregex(L"WHERE|[0-9_].*|False|None|True|and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield"); // Python keywords from: import keyword; keyword.kwlist
shared_ptr<writer::RelationalWriter> relationalWriter;
@@ -128,7 +128,8 @@
PyObject* pyValue = PyUnicode_FromString(convertor.to_bytes(currentRecord[i]).c_str());
PyList_SetItem(pyRecord, i, pyValue);
string_t attributeName = currentWriterMetadata[i].attributeName;
- if (regex_match(attributeName, ATTRIBUTE_NAMES_ALLOWED) && !regex_match(attributeName, ATTRIBUTE_NAMES_DISALLOWED)) {
+ if (regex_match(attributeName, ATTRIBUTE_NAMES_ALLOWED)) {
+ if (regex_match(attributeName, ATTRIBUTE_NAMES_DISALLOWED)) attributeName = L"a_" + attributeName;
PyDict_SetItemString(pyDict, convertor.to_bytes(attributeName).c_str(), pyValue);
}
}