def _string_to_dictsql(self, part):
        """ Do magic matching of single words or quoted string
        """
        self._logger.debug("parsing string: " + unicode(part[0]) + " of type: " + part.getName())

        if part.getName() == 'tag':
            self._logger.debug("Query part '" + part[0] + "' interpreted as tag")
            dictsql = {
                    'interpretation': {
                        'string': part[0],
                        'interpretation': 'tag',
                        'attribute': 'tag',
                        'operator': 'equals_any',
                        'error': False
                        },
                    'operator': 'equals_any',
                    'val1': 'tags',
                    'val2': part[0][1:]
                    }

        elif part.getName() == 'vrf_rt':
            self._logger.debug("Query part '" + part.vrf_rt + "' interpreted as VRF RT")
            # TODO: enable this, our fancy new interpretation
            dictsql = {
                    'interpretation': {
                        'attribute': 'VRF RT',
                        'interpretation': 'vrf_rt',
                        'operator': 'equals',
                        'string': part.vrf_rt,
                        'error': False
                        },
                    'operator': 'equals',
                    'val1': 'vrf_rt',
                    'val2': part.vrf_rt
                    }
            # using old interpretation for the time being to make sure we align
            # with old smart search interpreter
            dictsql = {
                    'interpretation': {
                        'attribute': 'name or description',
                        'interpretation': 'text',
                        'operator': 'regex',
                        'string': part.vrf_rt,
                        'error': False
                        },
                    'operator': 'or',
                    'val1': {
                        'operator': 'regex_match',
                        'val1': 'name',
                        'val2': part.vrf_rt
                        },
                    'val2': {
                        'operator': 'regex_match',
                        'val1': 'description',
                        'val2': part.vrf_rt
                        }
                    }

        else:
            self._logger.debug("Query part '" + part[0] + "' interpreted as text")
            dictsql = {
                    'interpretation': {
                        'attribute': 'name or description',
                        'interpretation': 'text',
                        'operator': 'regex',
                        'string': part[0],
                        'error': False
                        },
                    'operator': 'or',
                    'val1': {
                        'operator': 'regex_match',
                        'val1': 'name',
                        'val2': part[0]
                        },
                    'val2': {
                        'operator': 'regex_match',
                        'val1': 'description',
                        'val2': part[0]
                        }
                    }

        return dictsql
def _string_to_dictsql ( self , part ) : self . _logger . debug ( "parsing string: " + unicode ( part [ 0 ] ) + " of type: " + part . getName ( ) ) if part . getName ( ) == 'tag' : self . _logger . debug ( "Query part '" + part [ 0 ] + "' interpreted as tag" ) dictsql = { 'interpretation' : { 'string' : part [ 0 ] , 'interpretation' : 'tag' , 'attribute' : 'tag' , 'operator' : 'equals_any' , 'error' : False } , 'operator' : 'equals_any' , 'val1' : 'tags' , 'val2' : part [ 0 ] [ 1 : ] } elif part . getName ( ) == 'vrf_rt' : self . _logger . debug ( "Query part '" + part . vrf_rt + "' interpreted as VRF RT" ) dictsql = { 'interpretation' : { 'attribute' : 'VRF RT' , 'interpretation' : 'vrf_rt' , 'operator' : 'equals' , 'string' : part . vrf_rt , 'error' : False } , 'operator' : 'equals' , 'val1' : 'vrf_rt' , 'val2' : part . vrf_rt } dictsql = { 'interpretation' : { 'attribute' : 'name or description' , 'interpretation' : 'text' , 'operator' : 'regex' , 'string' : part . vrf_rt , 'error' : False } , 'operator' : 'or' , 'val1' : { 'operator' : 'regex_match' , 'val1' : 'name' , 'val2' : part . vrf_rt } , 'val2' : { 'operator' : 'regex_match' , 'val1' : 'description' , 'val2' : part . vrf_rt } } else : self . _logger . debug ( "Query part '" + part [ 0 ] + "' interpreted as text" ) dictsql = { 'interpretation' : { 'attribute' : 'name or description' , 'interpretation' : 'text' , 'operator' : 'regex' , 'string' : part [ 0 ] , 'error' : False } , 'operator' : 'or' , 'val1' : { 'operator' : 'regex_match' , 'val1' : 'name' , 'val2' : part [ 0 ] } , 'val2' : { 'operator' : 'regex_match' , 'val1' : 'description' , 'val2' : part [ 0 ] } } return dictsql
Do magic matching of single words or quoted string