Пример #1
0
    async def _getNodesByTag(self, name, valu=None, cmpr='='):
        name = s_chop.tag(name)
        pref = b'#' + name.encode('utf8') + b'\x00'
        cmpf = None

        if valu is None:
            iops = (('pref', b''), )
            lops = (
                ('indx', ('byuniv', pref, iops)),
            )
        elif valu is not None and cmpr == '@=':
            lops = self.tagtype.getLiftOps('univ', cmpr, (None, '#' + name, valu))
        else:
            iops = self.tagtype.getIndxOps(valu, cmpr)
            lops = (
                ('indx', ('byuniv', pref, iops)),
            )

        async for row, node in self.getLiftNodes(lops, '#' + name, cmpf=cmpf):
            yield node
Пример #2
0
    async def _getNodesByFormTag(self, name, tag, valu=None, cmpr='='):

        filt = None
        form = self.model.form(name)

        if valu is not None:
            ctor = self.model.type('ival').getCmprCtor(cmpr)
            if ctor is not None:
                filt = ctor(valu)

        if form is None:
            raise s_exc.NoSuchForm(form=name)

        tag = s_chop.tag(tag)

        # maybe use Encoder here?
        fenc = form.name.encode('utf8') + b'\x00'
        tenc = b'#' + tag.encode('utf8') + b'\x00'

        iops = (('pref', b''), )
        lops = (
            ('indx', ('byprop', fenc + tenc, iops)),
        )

        # a small speed optimization...
        rawprop = '#' + tag
        if filt is None:

            async for row, node in self.getLiftNodes(lops, rawprop):
                yield node

            return

        async for row, node in self.getLiftNodes(lops, rawprop):

            valu = node.getTag(tag)

            if filt(valu):
                yield node
Пример #3
0
 def test_chop_tag(self):
     self.eq('foo.bar.ba z', s_chop.tag('#foo  .bar.  BA Z'))
Пример #4
0
 def getTag(self, name, defval=None):
     name = s_chop.tag(name)
     return self.tags.get(name, defval)
Пример #5
0
 def hasTag(self, name):
     name = s_chop.tag(name)
     return name in self.tags
Пример #6
0
 def getTag(self, name, defval=None):
     name = s_chop.tag(name)
     return self.tags.get(name, defval)
Пример #7
0
 def hasTag(self, name):
     name = s_chop.tag(name)
     return name in self.tags
Пример #8
0
 def test_chop_tag(self):
     self.eq('foo.bar.ba z', s_chop.tag('#foo  .bar.  BA Z'))