#204: Abstract for match in regex: pattern in s_e_q_p
----------------------------+-----------------------------------------------
 Reporter:  jblayloc        |       Owner:     
     Type:  enhancement     |      Status:  new
 Priority:  minor           |   Milestone:     
Component:  WebSearch       |     Version:     
 Keywords:  INSPIRE Syntax  |  
----------------------------+-----------------------------------------------
 search_engine_query_parser uses this coding pattern many times:

 {{{#!python
 results = ''
 position = 0
 for match in regexp(query):
   results += query[position:match.start()]
   # do stuff with match
   position = match.end()
 results += query[position:]
 return results
 }}}

 Since this is done n >= 3 times, this pattern should be captured into a
 function which accepts a regexp to match with, a function to apply and a
 string to do it with.

 This will make seqp easier to read and very probably kill as-yet-
 unsuspected bugs.

-- 
Ticket URL: <http://invenio-software.org/ticket/204>
Invenio <http://invenio-software.org>

Reply via email to