Beispiel #1
0
 def runsearch(self):
     self.updateCriteria()
     s = "n1=True\nn2=True\nn3=True\n"
     s += "t1=True\nt2=True\nt3=True\n"
     if self.criteria[0].name:
         if self.criteria[0].rgx_name:
             s += "n1=(CGU.stringNameMatches(PARENT,'%s'))\n" % \
                  self.criteria[0].name
         else:
             s += "n1=(PARENT[0]=='%s')\n" % self.criteria[0].name
         if self.criteria[0].not_name:
             s += "n1=not n1\n"
     if self.criteria[1].name:
         if self.criteria[1].rgx_name:
             s += "n2=(CGU.stringMatches(NAME,'%s'))\n" % self.criteria[
                 1].name
         else:
             s += "n2=(NAME=='%s')\n" % self.criteria[1].name
         if self.criteria[1].not_name:
             s += "n2=not n2\n"
     if self.criteria[2].name:
         if self.criteria[1].rgx_name:
             s += "for cn in CGU.childrenNames(NODE):\n  n3=n3 or ('%s'==cn[0])\n" % self.criteria[
                 2].name
         else:
             s += "n3=('%s' in CGU.childrenNames(NODE))\n" % self.criteria[
                 2].name
     s += "rn=n1 and n2 and n3\n"
     if self.criteria[0].sidstype:
         if self.criteria[0].rgx_sids:
             s += "t1=(CGU.stringTypeMatches(PARENT,'%s'))\n" % \
                  self.criteria[0].sidstype
         else:
             s += "t1=(PARENT[3]=='%s')\n" % self.criteria[0].sidstype
         if self.criteria[0].not_sids:
             s += "t1=not t1\n"
     if self.criteria[1].sidstype:
         if self.criteria[1].rgx_sids:
             s += "t2=(CGU.stringTypeMatches(NAME,'%s'))\n" % \
                  self.criteria[1].sidstype
         else:
             s += "t2=(SIDSTYPE=='%s')\n" % self.criteria[1].sidstype
         if self.criteria[1].not_sids:
             s += "t2=not t2\n"
     if self.criteria[2].sidstype:
         if self.criteria[1].rgx_sids:
             s += "t3=False\nfor cn in CHILDREN:\n  t3=t3 or (CGU.stringTypeMatches('%s,cn))\n" % self.criteria[
                 2].sidstype
         else:
             s += "t3=False\nfor cn in CHILDREN:\n  t3=t3 or ('%s'==cn[3])\n" % self.criteria[
                 2].sidstype
     s += "rt=t1 and t2 and t3\n"
     s += "RESULT=rn and rt\n"
     q = Q7QueryEntry('TMP', script=s)
     skp = list(self._fgprint.lazy)
     sl = q.run(self._fgprint.tree, self._fgprint.links, skp, False, '',
                self._model.getSelected())
     self._model.markExtendToList(sl)
     self._model.updateSelected()
     self._treeview.refreshView()
Beispiel #2
0
 def queryAdd(self):
     self.bAdd.setEnabled(False)
     qname = self.cQueryName.currentText().strip()
     if qname in Q7Query._allQueries:
         return
     q = Q7QueryEntry(qname)
     Q7Query._allQueries[qname] = q
     self.queryCommit()
     self.cQueryName.addItem(qname)
Beispiel #3
0
 def fillQueries(cls):
     allqueriestext = Q7Query._userQueriesText + OCTXT._UsualQueries
     Q7Query._defaultQueriesNames = [n[0] for n in OCTXT._UsualQueries]
     for qe in allqueriestext:
         try:
             q = Q7QueryEntry(qe[0], qe[1], qe[2], qe[3],
                              hasargs=qe[5], update=qe[4])
             Q7Query._allQueries[qe[0]] = q
         except IndexError:
             pass
Beispiel #4
0
    def runCurrent(self):
        com = self.eText.toPlainText()
        v = self.eUserVariable.text()
        q = Q7QueryEntry('__tmp__query__')
        q.setScript(com)
        skp = list(self.FG.lazy)
        r = q.run(self.FG.tree, self.FG.links, skp, False, v,
                  self.FG.model.getSelected())
        self.eResult.initText(str(r))
        self.FG.model.markExtendToList(r)
        self.FG.model.updateSelected()
        if q.requireTreeUpdate():
            self.FG.model.modelReset()

        self._master.treeview.refreshView()