Example #1
0
    def loadMultifilePrcFiles(self, mf, root):
        """ Loads any prc files in the root of the indicated
        Multifile, which is presumed to have been mounted already
        under root. """

        # We have to load these prc files explicitly, since the
        # ConfigPageManager can't directly look inside the vfs.  Use
        # the Multifile interface to find the prc files, rather than
        # vfs.scanDirectory(), so we only pick up the files in this
        # particular multifile.
        cpMgr = ConfigPageManager.getGlobalPtr()
        for f in mf.getSubfileNames():
            fn = Filename(f)
            if fn.getDirname() == '' and fn.getExtension() == 'prc':
                pathname = '%s/%s' % (root, f)

                alreadyLoaded = False
                for cpi in range(cpMgr.getNumImplicitPages()):
                    if cpMgr.getImplicitPage(cpi).getName() == pathname:
                        # No need to load this file twice.
                        alreadyLoaded = True
                        break

                if not alreadyLoaded:
                    data = file.open(Filename(pathname), 'r').read()
                    cp = loadPrcFileData(pathname, data)
                    # Set it to sort value 20, behind the implicit pages.
                    cp.setSort(20)
Example #2
0
 def findNewsDir(self):
     if self.NewsOverHttp:
         return self.NewsStageDir
     else:
         searchPath = DSearchPath()
         if AppRunnerGlobal.appRunner:
             searchPath.appendDirectory(
                 Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news'))
         else:
             basePath = os.path.expandvars('$TTMODELS') or './ttmodels'
             searchPath.appendDirectory(
                 Filename.fromOsSpecific(basePath + '/built/' +
                                         self.NewsBaseDir))
             searchPath.appendDirectory(Filename(self.NewsBaseDir))
         pfile = Filename(self.NewsIndexFilename)
         found = vfs.resolveFilename(pfile, searchPath)
         if not found:
             self.notify.warning('findNewsDir - no path: %s' %
                                 self.NewsIndexFilename)
             self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile %
                                  self.NewsIndexFilename)
             return None
         self.notify.debug('found index file %s' % pfile)
         realDir = pfile.getDirname()
         return realDir
Example #3
0
    def loadMultifilePrcFiles(self, mf, root):
        """ Loads any prc files in the root of the indicated
        Multifile, which is presumed to have been mounted already
        under root. """

        # We have to load these prc files explicitly, since the
        # ConfigPageManager can't directly look inside the vfs.  Use
        # the Multifile interface to find the prc files, rather than
        # vfs.scanDirectory(), so we only pick up the files in this
        # particular multifile.
        cpMgr = ConfigPageManager.getGlobalPtr()
        for f in mf.getSubfileNames():
            fn = Filename(f)
            if fn.getDirname() == '' and fn.getExtension() == 'prc':
                pathname = '%s/%s' % (root, f)

                alreadyLoaded = False
                for cpi in range(cpMgr.getNumImplicitPages()):
                    if cpMgr.getImplicitPage(cpi).getName() == pathname:
                        # No need to load this file twice.
                        alreadyLoaded = True
                        break

                if not alreadyLoaded:
                    data = file.open(Filename(pathname), 'r').read()
                    cp = loadPrcFileData(pathname, data)
                    # Set it to sort value 20, behind the implicit pages.
                    cp.setSort(20)
Example #4
0
 def findNewsDir(self):
     if self.NewsOverHttp:
         return self.NewsStageDir
     searchPath = DSearchPath()
     if AppRunnerGlobal.appRunner:
         searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news'))
     else:
         basePath = os.path.expandvars('$TTMODELS') or './ttmodels'
         searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir))
         searchPath.appendDirectory(Filename(self.NewsBaseDir))
     pfile = Filename(self.NewsIndexFilename)
     found = vfs.resolveFilename(pfile, searchPath)
     if not found:
         self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename)
         self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename)
         return None
     self.notify.debug('found index file %s' % pfile)
     realDir = pfile.getDirname()
     return realDir