Changeset 2870 for trunk/python


Ignore:
Timestamp:
12/02/13 17:56:41 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-5858

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Added selector.set_msselection_field method

Test Programs: none

Put in Release Notes: No

Module(s): sd

Description: Describe your changes here...

Added selector.set_msselection_field to support multi-field selection
based on msselection syntax.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/selector.py

    r2340 r2870  
    11import re
     2import string
    23from asap._asap import selector as _selector, srctype
    34from asap.utils import unique, _to_list
     
    200201            raise TypeError('Unknown row number type. Use lists of integers.')
    201202
     203    def set_msselection_field(self, selection):
     204        """
     205        """
     206        selection_list =  map(string.strip, selection.split(','))
     207        query_list = list(self.generate_query(selection_list))
     208        query = 'SELECT FROM $1 WHERE ' + ' || '.join(query_list)
     209        self._settaql(query)
     210
     211    def generate_query(self, selection_list):
     212        for s in selection_list:
     213            if re.match('.*\*.*', s):
     214                #print '"%s" is pattern match using *'%(s)
     215                yield 'SRCNAME == pattern(\'%s\')'%(s)
     216            elif re.match('^<=?[0-9]*$', s):
     217                #print '"%s" is ID selection using < or <='%(s)
     218            elif re.match('^>=?[0-9]*$', s):
     219                #print '"%s" is ID selection using > or >='%(s)
     220            elif re.match('^[0-9]+~[0-9]+$', s):
     221                #print '"%s" is ID selection using ~'%(s)
     222            else:
     223                #print '"%s" is exact match'%(s)
     224                yield 'SRCNAME == pattern(\'%s\')'%(s)
     225       
    202226    def get_scans(self):
    203227        return list(self._getscans())
Note: See TracChangeset for help on using the changeset viewer.