[Erp5-report] r19275 - /erp5/trunk/products/ZSQLCatalog/SearchKey/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Feb 12 16:44:50 CET 2008
Author: yo
Date: Tue Feb 12 16:44:49 2008
New Revision: 19275
URL: http://svn.erp5.org?rev=19275&view=rev
Log:
Clean up the regular expressions.
Modified:
erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/FloatKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/KeyWordKey.py
erp5/trunk/products/ZSQLCatalog/SearchKey/ScriptableKey.py
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/DateTimeKey.py Tue Feb 12 16:44:49 2008
@@ -69,19 +69,19 @@
'LESSTHAN', 'LESSTHANEQUAL', 'NOT', 'EQUAL',)
def t_OR(self, t):
- r'(\s+OR\s+|\s+or\s+)'
+ r'\s+(OR|or)\s+'
# operator has leading and trailing ONLY one white space character
t.value = 'OR'
return t
def t_AND(self, t):
- r'(\s+AND\s+|\s+and\s+)'
+ r'\s+(AND|and)\s+'
# operator has leading and trailing ONLY one white space character
t.value = 'AND'
return t
def t_NOT(self, t):
- r'(\s+NOT\s+|\s+not\s+|!=)'
+ r'(\s+(NOT|not)\s+|!=)'
# operator has leading and trailing ONLY one white space character
t.value = t.value.upper().strip()
return t
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/DefaultKey.py Tue Feb 12 16:44:49 2008
@@ -57,21 +57,21 @@
# Note: Order of placing rules (t_WORD for example) is very important
def t_OR(self, t):
- r'(\s+OR\s+|\s+or\s+)'
+ r'\s+(OR|or)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'OR'
return t
def t_AND(self, t):
- r'(\s+AND\s+|\s+and\s+)'
+ r'\s+(AND|and)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'AND'
return t
def t_NOT(self, t):
- r'(\s+NOT\s+|\s+not\s+|!=)'
+ r'(\s+(NOT|not)\s+|!=)'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = '!='
@@ -83,21 +83,23 @@
t_LESSTHAN = r'<'
def t_WORD(self, t):
- r'[\x7F-\xFF\w\d\/\.\-~!@#$%^&*()_+\n][\x7F-\xFF\w\d\/\.\-~!@#$%^&*()_+\n]*'
- #r'[\x7F-\xFF\w\d\/%][\x7F-\xFF\w\d\/%]*'
+ r'([^"\s<>!][\S\n]*|!([^=\s][\S\n]*)?)'
+ # newlines are allowed, because variations are delimited by newlines.
# WORD may contain arbitrary letters and numbers without white space
# WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD)
value = t.value.strip()
- t.value = "%s" %value
+ if value[0] == '=':
+ value = value[1:]
+ t.value = value
return t
def t_WORDSET(self, t):
- r'"[\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+]*"'
+ r'"[^"]*"'
#r'"[\x7F-\xFF\w\d\s/%][\x7F-\xFF\w\d\s/%]*"'
# WORDSET is a combination of WORDs separated by white space
# and starting/ending with "
value = t.value.replace('"', '').strip()
- t.value = "%s" %value
+ t.value = value
return t
def quoteSQLString(self, value, format):
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/FloatKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/FloatKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/FloatKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/FloatKey.py Tue Feb 12 16:44:49 2008
@@ -45,21 +45,21 @@
# Note: Order of placing rules (t_WORD for example) is very important
def t_OR(self, t):
- r'(\s+OR\s+|\s+or\s+)'
+ r'\s+(OR|or)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'OR'
return t
def t_AND(self, t):
- r'(\s+AND\s+|\s+and\s+)'
+ r'\s+(AND|and)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'AND'
return t
def t_NOT(self, t):
- r'(\s+NOT\s+|\s+not\s+|!=)'
+ r'(\s+(NOT|not)\s+|!=)'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = '!='
@@ -74,7 +74,7 @@
r'[\d.][\d.]*'
# FLOAT is a float number
value = t.value.replace('"', '').strip()
- t.value = "%s" %value
+ t.value = value
return t
def quoteSQLString(self, value, format):
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/FullTextKey.py Tue Feb 12 16:44:49 2008
@@ -58,11 +58,11 @@
t_DOUBLEQUOTE = r'(\")'
def t_WORD(self, t):
- r'[\x7F-\xFF\w\d\/\.!@#$%^&_][\x7F-\xFF\w\d\/\.!@#$%^&_]*'
+ r'[^\+\-<>\(\)\~\*\"\s]\S*'
#r'[\x7F-\xFF\w\d][\x7F-\xFF\w\d]*'
# WORD may contain arbitrary letters and numbers without white space
word_value = t.value
- t.value = "'%s'" %word_value
+ t.value = "'%s'" % word_value
return t
def buildSQLExpression(self, key, value,
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/KeyWordKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/KeyWordKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/KeyWordKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/KeyWordKey.py Tue Feb 12 16:44:49 2008
@@ -66,25 +66,25 @@
# Note: Order of placing rules (t_WORD for example) is very important
def t_OR(self, t):
- r'(\s+OR\s+|\s+or\s+)'
+ r'\s+(OR|or)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'OR'
return t
def t_AND(self, t):
- r'(\s+AND\s+|\s+and\s+)'
+ r'\s+(AND|and)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'AND'
return t
def t_NOT(self, t):
- r'(\s+NOT\s+|\s+not\s+|!=)'
+ r'(\s+(NOT|not)\s+|!=)'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = t.value.upper().strip()
- return t
+ return t
t_GREATERTHANEQUAL = r'>='
t_LESSTHANEQUAL = r'<='
@@ -92,7 +92,7 @@
t_LESSTHAN = r'<'
def t_EXPLICITEQUALLITYWORD(self, t):
- r'=[\x7F-\xFF\w\d\/\.~!@#$^&*()_+][\x7F-\xFF\w\d\/\.~!@#$^&*()_+]*'
+ r'=\S*'
# EXPLICITEQUALLITYWORD may contain arbitrary letters and numbers without white space
# EXPLICITEQUALLITYWORD must contain '=' at the beginning
value = t.value.strip()
@@ -101,30 +101,30 @@
return t
def t_KEYWORD(self, t):
- r'%?[\x7F-\xFF\w\d/\.~!@#$%^&*()_+][\x7F-\xFF\w\d/\.~!@#$%^&*()_+]*%?'
- # KEYWORD may starts(1) and may ends (2) with '%' but always must either #1 or #2
- # be true. It may contains arbitrary letters, numbers and white space
+ r'(%\S*|([^!<>=\s%]\S*|!([^=\s]\S*)?)%)'
+ # KEYWORD must start and/or end with '%'.
+ # It may contain arbitrary letters and numbers without white space
value = t.value.strip()
- if not value.startswith('%') and not value.endswith('%'):
- t.type = 'WORD'
t.value = value
return t
def t_WORD(self, t):
- r'[\x7F-\xFF\w\d\/\.~!@#$^&*()_+][\x7F-\xFF\w\d\/\.~!@#$^&*()_+]*'
+ r'([^"\s<>!=%]([^ \t\r\f\v]*[^ \t\r\f\v%])?|!([^= \t\r\f\v%]|[^= \t\r\f\v][\S\n]*[^ \t\r\f\v%])?)'
# WORD may contain arbitrary letters and numbers without white space
# WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD)
value = t.value.strip()
t.value = value
- return t
+ return t
def t_WORDSET(self, t):
- r'=?"[\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+][\x7F-\xFF\w\d\s\/\.~!@#$%^&*()_+]*"'
+ r'=?"[^"]*"'
# WORDSET is a combination of WORDs separated by white space
# and starting/ending with " (optionally with '=')
value = t.value.replace('"', '')
- t.value = "%s" %value
- return t
+ if value[0] == '=':
+ value = value[1:]
+ t.value = value
+ return t
def quoteSQLString(self, value, format):
""" Return a quoted string of the value. """
Modified: erp5/trunk/products/ZSQLCatalog/SearchKey/ScriptableKey.py
URL: http://svn.erp5.org/erp5/trunk/products/ZSQLCatalog/SearchKey/ScriptableKey.py?rev=19275&r1=19274&r2=19275&view=diff
==============================================================================
--- erp5/trunk/products/ZSQLCatalog/SearchKey/ScriptableKey.py (original)
+++ erp5/trunk/products/ZSQLCatalog/SearchKey/ScriptableKey.py Tue Feb 12 16:44:49 2008
@@ -91,21 +91,21 @@
# Note: Order of placing rules (t_WORD for example) is very important
def t_OR(self, t):
- r'(\s+OR\s+|\s+or\s+)'
+ r'\s+(OR|or)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'OR'
return t
def t_AND(self, t):
- r'(\s+AND\s+|\s+and\s+)'
+ r'\s+(AND|and)\s+'
# operator must have leading and trailing ONLY one white space character
# otherwise it's treated as a WORD
t.value = 'AND'
return t
def t_KEYMAPPING(self, t):
- r'[\x7F-\xFF\w\d\/~!@#$^&*()_+-][\x7F-\xFF\w\d\/~!@#$^&*()_+-]*\s*(>|<|<=|>=|:)\s*[\x7F-\xFF\w\d\/~!@#$^&*()_+-][\x7F-\xFF\w\d\/~!@#$^&*()_+-]*'
+ r'[^<>=:\s]+\s*(>|<|<=|>=|:)\s*\S+'
# KEYMAPPING has following format: KEY OPERATOR VALUE
# where OPERATOR in ['<', '>', '<=', '>=', ':']
# example: 'creation_date < 2007-12-12'
@@ -114,7 +114,7 @@
return t
def t_WORD(self, t):
- r'[\x7F-\xFF\w\d\/~!@#$^&*()_+][\x7F-\xFF\w\d\/~!@#$^&*()_+]*'
+ r'[^<>=\s:]+'
# WORD may contain arbitrary letters and numbers without white space
# WORD may contain '%' but not at the beginning or end (otherwise it's KEYWORD)
value = t.value.strip()
More information about the Erp5-report
mailing list