Changeset 2875


Ignore:
Timestamp:
12/06/13 13:21:08 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-5858

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: sel = sd.selector()

sel.set_msselection_field()
print sel._gettaql()

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Fixed behavior when empty string is passed as an argument.
Also, documentation is added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/selector.py

    r2874 r2875  
    204204    def set_msselection_field(self, selection):
    205205        """
     206        Set a field selection in msselection syntax. The msselection
     207        suppports the following syntax:
     208
     209        pattern match:
     210            - UNIX style pattern match for source name using '*'
     211              (compatible with set_name)
     212
     213        field id selection:
     214            - simple number in string ('0', '1', etc.)
     215            - range specification using '~' ('0~1', etc.)
     216            - range specification using '>' or '<' in combination
     217              with '=' ('>=1', '<3', etc.)
     218
     219        comma separated multiple selection:
     220            - selections can be combined by using ',' ('0,>1',
     221              'mysource*,2~4', etc.)
    206222        """
    207223        selection_list =  map(string.strip, selection.split(','))
    208224        query_list = list(self.generate_query(selection_list))
    209         query = 'SELECT FROM $1 WHERE ' + ' || '.join(query_list)
    210         self._settaql(query)
     225        if len(query_list) > 0:
     226            query = 'SELECT FROM $1 WHERE ' + ' || '.join(query_list)
     227            self._settaql(query)
    211228
    212229    def generate_query(self, selection_list):
     
    217234                a = FieldIdRegexGenerator(s)
    218235                yield '(%s)'%(a.get_regex())
    219             else:
     236            elif len(s) > 0:
    220237                #print '"%s" is UNIX style pattern match'%(s)
    221238                yield '(SRCNAME == pattern(\'%s\'))'%(s)
Note: See TracChangeset for help on using the changeset viewer.