Ejemplo n.º 1
0
    def finalize_options(self):
        self.set_undefined_options('build_docs', ('build_dir', 'build_dir'))
        self.set_undefined_options('install', ('install_docs', 'install_dir'),
                                   ('skip_build', 'skip_build'),
                                   ('force', 'force'))
        self.documents = self.get_documents()

        resourcebundle = GetConfigVar('RESOURCEBUNDLE')
        if resourcebundle is None:
            # building 4Suite itself; use different (hard-wired) directories
            base_uri = Uri.OsPathToUri(os.path.join('Ft', 'Data'))
        else:
            datadir = GetConfigVar('DATADIR')
            datadir = os.path.join(datadir, 'Data', 'Stylesheets')
            if resourcebundle:
                resource = ImportUtil.OsPathToResource(datadir)
                base_uri = Uri.ResourceToUri('Ft.Lib', resource)
            else:
                base_uri = Uri.OsPathToUri(datadir)

        defaults = self.get_default_stylesheets()
        for name in defaults:
            attr = name + '_xslt'
            value = getattr(self, attr)
            if value is None:
                value = base_uri + '/' + defaults[name]
            else:
                pathname = util.convert_path(value)
                value = Uri.OsPathToUri(pathname)
            setattr(self, attr, value)

        self._xslt_processor = None
        self._stylesheets = {}
        return
Ejemplo n.º 2
0
def GetDefaultCatalog(basename='default.cat'):
    """
    Load the default catalog file(s).
    """
    quiet = 'XML_DEBUG_CATALOG' not in os.environ

    uris = []
    # original 4Suite XML Catalog support
    if 'XML_CATALOGS' in os.environ:
        # os.pathsep seperated list of pathnames
        for path in os.environ['XML_CATALOGS'].split(os.pathsep):
            uris.append(Uri.OsPathToUri(path))

    # libxml2 XML Catalog support
    if 'XML_CATALOG_FILES' in os.environ:
        # whitespace-separated list of pathnames or URLs (ick!)
        for path in os.environ['XML_CATALOG_FILES'].split():
            # if its already not already an URL, make it one
            if not Uri.IsAbsolute(path):
                uris.append(Uri.OsPathToUri(path))
            else:
                uris.append(path)

    # add the default 4Suite catalog
    pathname = os.path.join(GetConfigVar('DATADIR'), basename)
    if GetConfigVar('RESOURCEBUNDLE'):
        resource = ImportUtil.OsPathToResource(pathname)
        uri = Uri.ResourceToUri('Ft.Xml', resource)
    else:
        uri = Uri.OsPathToUri(pathname)
    uris.append(uri)

    if not quiet:
        prefix = "Catalog URIs:"
        for uri in uris:
            sys.stderr.write('%s %s\n' % (prefix, uri))
            prefix = " "*len(prefix)

    catalog = None
    for uri in uris:
        if not quiet:
            sys.stderr.write('Reading %s\n' % uri)
            sys.stderr.flush()
        try:
            # FIXME: Use dict merging rather than this inefficient cascading
            if catalog is None:
                if not quiet:
                    sys.stderr.write('Creating catalog from %s\n' % uri)
                    sys.stderr.flush()
                catalog = Catalog(uri, quiet)
            else:
                if not quiet:
                    sys.stderr.write('Appending %s\n' % uri)
                    sys.stderr.flush()
                catalog.catalogs.append(Catalog(uri, quiet))
        except UriException, e:
            #warnings.warn("Catalog resource (%s) disabled: %s" % (uri,
            #                                                      e.message),
            #              FtWarning)
            pass