예제 #1
0
        def f1():
            if not self.diff and self.other:
                self.diff = RdfDiff()
                try:
                    self.diff.CompareProc(self.document, self.other)
                except:
                    log.exception()

            other = GraphDocument()
            self.diff.MakeLocalDiff(other, self.document)
            other.UpdateNamespacesFromLoad()
            props_source = self.other if self.other else self.document
            props = {}
            for k in type(self.document).doc_params:
                v = getattr(props_source, k, None)
                if v != None:
                    props[k] = v
            other.UpdateProps(props)

            all_subj = self.diff.deletions.ks.viewkeys() | self.diff.insertions.ks.viewkeys()
            new_subj = self.diff.insertions.ks.viewkeys() - self.document.ks.viewkeys()
            del_subj = self.diff.deletions.ks.viewkeys() - other.ks.viewkeys()
            chn_subj = all_subj - new_subj - del_subj

            self.subjects = []
            if self.show_changed:
                self.subjects += list(chn_subj)
            if self.show_added:
                self.subjects += list(new_subj)
            if self.show_deleted:
                self.subjects += list(del_subj)

            if self.text:
                res_doc = self.document._grSearchLabel(self.text)
                res_other = other._grSearchLabel(self.text)

                self.subjects =  list((res_doc | res_other) & set([expand_uri(uri) for uri in self.subjects]))
                self.subjects = [compact_uri(uri) for uri in self.subjects]

            if self.filter_params:
                env = appdata.environment_manager.GetWorkEnvironment(self.document, include_scanner=True)
                res_doc = env['scanner']._find(**self.filter_params)
                env = appdata.environment_manager.GetWorkEnvironment(other, include_scanner=True)
                res_other = env['scanner']._find(**self.filter_params)

                self.subjects =  list((res_doc | res_other) & set([expand_uri(uri) for uri in self.subjects]))
                self.subjects = [compact_uri(uri) for uri in self.subjects]
                self.filter_params = None


            count_all = len(all_subj)
            count_filtered = len(self.subjects)

            @public.mth
            def f2():
                self.ShowEntities()
                self.pnode.treenode_loading = False
                self.pnode.UpdateLabel(' [{1}/{2}]'.format(self.document.GetLabel(), count_filtered, count_all))
                self.setEnabled(True)
                self.seeding = False
예제 #2
0
    def OnAcceptAll(self):
        if len(self.subjects) > 1000:
            if dialogs.Choice(tm.main.apply_diff_warning):
                self.pnode.DestroyChildren()
                for v in self.subjects:
                    for t in self.diff.deletions.grTriplesForSubj(expand_uri(v)):
                        t.deletefrom(self.document)
                    for t in self.diff.insertions.grTriplesForSubj(expand_uri(v)):
                        t.insertto(self.document)
                self.document.ChangeState(self.document.state_changed)
                self.Seed()
            return

        lst = []
        for v in self.subjects:
            for t in self.diff.deletions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.RemoveProperty(self.document, t))
            for t in self.diff.insertions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.AddProperty(self.document, t))

        self.document<<MultiAction(lst)
예제 #3
0
    def OnAcceptAll(self):
        if len(self.subjects) > 1000:
            if dialogs.Choice(tm.main.apply_diff_warning):
                self.pnode.DestroyChildren()
                for v in self.subjects:
                    for t in self.diff.deletions.grTriplesForSubj(
                            expand_uri(v)):
                        t.deletefrom(self.document)
                    for t in self.diff.insertions.grTriplesForSubj(
                            expand_uri(v)):
                        t.insertto(self.document)
                self.document.ChangeState(self.document.state_changed)
                self.Seed()
            return

        lst = []
        for v in self.subjects:
            for t in self.diff.deletions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.RemoveProperty(self.document, t))
            for t in self.diff.insertions.grTriplesForSubj(expand_uri(v)):
                lst.append(actions.AddProperty(self.document, t))

        self.document << MultiAction(lst)
예제 #4
0
    def ShowEntities(self):
        if self.morenode:
            self.morenode.Destroy()
            self.morenode = None

        idx = self.shown-1
        for idx in xrange(self.shown, min(len(self.subjects), self.shown+self.show_num)):
            uri = expand_uri(self.subjects[idx])
            node = EntityNode(self.pnode, uri)

        self.shown = idx + 1
        if self.shown < len(self.subjects):
            self.morenode = MoreNode(self.pnode, self.ShowEntities)

        self.pnode.Expand()
예제 #5
0
    def SaveFilteredDiff(self):
        path, wildcard = dialogs.SelectFiles(tm.main.save_filtered_diff_as_title, save = True)

        if not path:
            return

        new_diff = RdfDiff()
        for v in self.subjects:
            uri = expand_uri(v)
            for t in self.diff.deletions.grTriplesForSubj(uri):
                t.insertto(new_diff.deletions)
            for t in self.diff.insertions.grTriplesForSubj(uri):
                t.insertto(new_diff.insertions)

        new_diff.SaveToFileProc(path)
예제 #6
0
    def ShowEntities(self):
        if self.morenode:
            self.morenode.Destroy()
            self.morenode = None

        idx = self.shown - 1
        for idx in xrange(self.shown,
                          min(len(self.subjects), self.shown + self.show_num)):
            uri = expand_uri(self.subjects[idx])
            node = EntityNode(self.pnode, uri)

        self.shown = idx + 1
        if self.shown < len(self.subjects):
            self.morenode = MoreNode(self.pnode, self.ShowEntities)

        self.pnode.Expand()
예제 #7
0
    def SaveFilteredDiff(self):
        path, wildcard = dialogs.SelectFiles(
            tm.main.save_filtered_diff_as_title, save=True)

        if not path:
            return

        new_diff = RdfDiff()
        for v in self.subjects:
            uri = expand_uri(v)
            for t in self.diff.deletions.grTriplesForSubj(uri):
                t.insertto(new_diff.deletions)
            for t in self.diff.insertions.grTriplesForSubj(uri):
                t.insertto(new_diff.insertions)

        new_diff.SaveToFileProc(path)
예제 #8
0
        def f1():
            if not self.diff and self.other:
                self.diff = RdfDiff()
                try:
                    self.diff.CompareProc(self.document, self.other)
                except:
                    log.exception()

            other = GraphDocument()
            self.diff.MakeLocalDiff(other, self.document)
            other.UpdateNamespacesFromLoad()
            props_source = self.other if self.other else self.document
            props = {}
            for k in type(self.document).doc_params:
                v = getattr(props_source, k, None)
                if v != None:
                    props[k] = v
            other.UpdateProps(props)

            all_subj = self.diff.deletions.ks.viewkeys(
            ) | self.diff.insertions.ks.viewkeys()
            new_subj = self.diff.insertions.ks.viewkeys(
            ) - self.document.ks.viewkeys()
            del_subj = self.diff.deletions.ks.viewkeys() - other.ks.viewkeys()
            chn_subj = all_subj - new_subj - del_subj

            self.subjects = []
            if self.show_changed:
                self.subjects += list(chn_subj)
            if self.show_added:
                self.subjects += list(new_subj)
            if self.show_deleted:
                self.subjects += list(del_subj)

            if self.text:
                res_doc = self.document._grSearchLabel(self.text)
                res_other = other._grSearchLabel(self.text)

                self.subjects = list(
                    (res_doc | res_other)
                    & set([expand_uri(uri) for uri in self.subjects]))
                self.subjects = [compact_uri(uri) for uri in self.subjects]

            if self.filter_params:
                env = appdata.environment_manager.GetWorkEnvironment(
                    self.document, include_scanner=True)
                res_doc = env['scanner']._find(**self.filter_params)
                env = appdata.environment_manager.GetWorkEnvironment(
                    other, include_scanner=True)
                res_other = env['scanner']._find(**self.filter_params)

                self.subjects = list(
                    (res_doc | res_other)
                    & set([expand_uri(uri) for uri in self.subjects]))
                self.subjects = [compact_uri(uri) for uri in self.subjects]
                self.filter_params = None

            count_all = len(all_subj)
            count_filtered = len(self.subjects)

            @public.mth
            def f2():
                self.ShowEntities()
                self.pnode.treenode_loading = False
                self.pnode.UpdateLabel(' [{1}/{2}]'.format(
                    self.document.GetLabel(), count_filtered, count_all))
                self.setEnabled(True)
                self.seeding = False