示例#1
0
    def PrepareEnvironment(self):

        if not bool(
                appconfig.get('paths.p7tpl_tablan')
                and appconfig.get('paths.rdl_tablan')
                and appconfig.get('tablan.proj_ns')):
            log('Import error: TabLan dependencies not set!\n')
            return False

        self.target_doc.UpdateProps(
            {'basens': appconfig.get('tablan.proj_ns')})

        self.p7tpl_doc = GraphDocument.FindDocumentByPaths(
            [appconfig.get('paths.p7tpl_tablan')])
        if not self.p7tpl_doc:
            self.p7tpl_doc = GraphDocument()
            param = dict(name="Template set (TabLan)",
                         chosen_part2=kb.ns_dm_part8,
                         module_name="p7tpl")
            self.p7tpl_doc.OpenFiles([appconfig.get('paths.p7tpl_tablan')],
                                     **param)
            appdata.project.AddDocument(self.p7tpl_doc)

        self.pcardl_doc = GraphDocument.FindDocumentByPaths(
            [appconfig.get('paths.rdl_tablan')])
        if not self.pcardl_doc:
            self.pcardl_doc = GraphDocument()
            param = dict(name='RDL (TabLan)',
                         chosen_part2=kb.ns_dm_part2,
                         namespaces=kb.namespaces_std,
                         annotations=kb.annotations_pcardl_rdf)
            self.pcardl_doc.OpenFiles([appconfig.get('paths.rdl_tablan')],
                                      **param)
            appdata.project.AddDocument(self.pcardl_doc)

        ready = True

        if not self.p7tpl_doc.CanView():
            wizard.Subscribe(self.p7tpl_doc, self)
            ready = False

        if not self.pcardl_doc.CanView():
            wizard.Subscribe(self.pcardl_doc, self)
            ready = False

        return ready
示例#2
0
    def PrepareEnvironment(self):
        """Prepeares environment for import.
        
        Here opened all files needed by import.
        To check file is already opened here used FindDocumentByPaths document method.
        """

        if not bool(appconfig.get('paths.p7tpl_catalog') and appconfig.get('paths.rdl_catalog') and appconfig.get('catalog.proj_ns')):
            log('Import error: Catalog dependencies not set!\n')            
            return False

        self.target_doc.UpdateProps({'basens': appconfig.get('catalog.proj_ns')})

        self.p7tpl_doc = GraphDocument.FindDocumentByPaths([appconfig.get('paths.p7tpl_catalog')])
        if not self.p7tpl_doc:
            self.p7tpl_doc = GraphDocument()
            param = dict(name="Template set (Catalog)", chosen_part2=kb.ns_dm_part8, module_name="p7tpl")
            self.p7tpl_doc.OpenFiles([appconfig.get('paths.p7tpl_catalog')], **param)
            appdata.project.AddDocument(self.p7tpl_doc)

        self.pcardl_doc = GraphDocument.FindDocumentByPaths([appconfig.get('paths.rdl_catalog')])
        if not self.pcardl_doc:
            self.pcardl_doc = GraphDocument()
            param = dict(name='RDL (Catalog)', chosen_part2=kb.ns_dm_part2, namespaces=kb.namespaces_std, annotations=kb.annotations_pcardl_rdf)
            self.pcardl_doc.OpenFiles([appconfig.get('paths.rdl_catalog')], **param)
            appdata.project.AddDocument(self.pcardl_doc)

        ready = True

        """If file needed to be loaded, subscribe on it's events."""

        if not self.p7tpl_doc.CanView():
            wizard.Subscribe(self.p7tpl_doc, self)
            ready = False

        if not self.pcardl_doc.CanView():
            wizard.Subscribe(self.pcardl_doc, self)
            ready = False

        return ready