Commit 641b8d7f authored by Bartek Górny's avatar Bartek Górny

fixed parsing of parenthesised sequences

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11052 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1e8bf3ae
...@@ -10,7 +10,7 @@ Single arguments: ...@@ -10,7 +10,7 @@ Single arguments:
Multiple arguments: Multiple arguments:
- arg:xxx works the same way - arg:xxx works the same way
- arg:(xxx,yyy) ORs both (do not put space after comma) - arg:(xxx,yyy) ORs both
- arg:all translates into empty tuple, which implies all available values - arg:all translates into empty tuple, which implies all available values
- state (simulation_state), type (portal_type) - state (simulation_state), type (portal_type)
...@@ -22,7 +22,7 @@ import re ...@@ -22,7 +22,7 @@ import re
# parsing defined here # parsing defined here
simulation_states=() simulation_states=()
r=re.compile('(\w+:"[^"]+"|\w+:[\(\),\w/\-.]+)') r=re.compile('(\w+:"[^"]+"|\w+:\([^)]+\)|\w+:[\(\),\w/\-.]+)')
filetyper=lambda s:('source_reference','%%.%s' % s) filetyper=lambda s:('source_reference','%%.%s' % s)
filestripper=lambda s: ('source_reference',s.replace('"','')) filestripper=lambda s: ('source_reference',s.replace('"',''))
#addarchived=lambda s: ('simulation_state',simulation_states+('archived',)) #addarchived=lambda s: ('simulation_state',simulation_states+('archived',))
...@@ -32,10 +32,11 @@ paramsmap=dict(file=filestripper,type=type,reference='reference',filetype=filety ...@@ -32,10 +32,11 @@ paramsmap=dict(file=filestripper,type=type,reference='reference',filetype=filety
language='language',version='version') language='language',version='version')
def parsestates(s): def parsestates(s):
print s
if s=='all': if s=='all':
return () return ()
if s[0]=='(' and s[-1]==')': if s[0]=='(' and s[-1]==')':
return [i for i in s[1:-1].split(',') if i!=''] return [i.replace('"','').replace("'","") for i in s[1:-1].split(',') if i!='']
return s.replace('"','').replace("'","") return s.replace('"','').replace("'","")
def analyze(params): def analyze(params):
...@@ -66,5 +67,5 @@ def parseSearchString(searchstring): ...@@ -66,5 +67,5 @@ def parseSearchString(searchstring):
if __name__=='__main__': if __name__=='__main__':
#searchstring='byle cisnie zego file:"ble ble.doc" filetype:doc type:Text poza tym reference:abc-def' #searchstring='byle cisnie zego file:"ble ble.doc" filetype:doc type:Text poza tym reference:abc-def'
searchstring='byle "cisnie zego" state:draft file:"ble ble.doc" type:"Web Site" poza tym reference:abc-def dupa:kwas/zbita' searchstring='byle "cisnie zego" state:draft file:"ble ble.doc" type:("Site","Text") poza tym reference:abc-def dupa:kwas/zbita'
print parseSearchString(searchstring) print parseSearchString(searchstring)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment