Exemple #1
0
 def _addNodeSet(self, rule):
     form = rule[1].get('form')
     prop = rule[1].get('prop')
     if not form:
         raise s_exc.BadRuleValu(key='form',
                                 valu=form,
                                 mesg='node:set:prop requires "form"')
     if not prop:
         raise s_exc.BadRuleValu(key='valu',
                                 valu=prop,
                                 mesg='node:set:prop requires "prop"')
     self._node_set[(form, prop)] = True
Exemple #2
0
 def _addTagDel(self, rule):
     tag = rule[1].get('tag')
     if not tag:
         raise s_exc.BadRuleValu(key='tag',
                                 valu=tag,
                                 mesg='node:tag:del requires "tag"')
     self._tag_del.add(tag)
Exemple #3
0
 def _addNodeDel(self, rule):
     form = rule[1].get('form')
     if not form:
         raise s_exc.BadRuleValu(key='form',
                                 valu=form,
                                 mesg='node:del requires "form"')
     self._node_del[form] = True
Exemple #4
0
    def add(self, tag):
        '''
        Add a tag to the tree.

        Args:
            tag (str): The tag (with no #)
        '''
        if len(tag) > 1 and '*' in tag:
            raise s_exc.BadRuleValu(
                key='tag',
                valu=tag,
                mesg='Tags >1 character cannot contain "*".')

        node = self.root
        for name in tag.split('.'):

            step = node[1].get(name)
            if step is None:
                step = node[1][name] = [False, {}]

            node = step

        node[0] = True
        self.cache.clear()