Пример #1
0
def exclude(_context, file=None, package=None, files=None):
    """Exclude a zcml file
    
    This directive should be used before any ZML that includes
    configuration you want to exclude.
    """

    if files:
        if file:
            raise ValueError("Must specify only one of file or files")
    elif not file:
        file = 'configure.zcml'


    context = GroupingContextDecorator(_context)
    if package is not None:
        context.package = package
        context.basepath = None

    if files:
        paths = glob(context.path(files))
        paths = sorted(zip([path.lower() for path in paths], paths))
        paths = [path for (l, path) in paths]
    else:
        paths = [context.path(file)]

    for path in paths:
        # processFile returns a boolean indicating if the file has been
        # processed or not, it *also* marks the file as having been processed,
        # here the side effect is used to keep the given file from being
        # processed in the future
        context.processFile(path)
Пример #2
0
def exclude(_context, file=None, package=None, files=None):
    """Exclude a zcml file
    
    This directive should be used before any ZML that includes
    configuration you want to exclude.
    """

    if files:
        if file:
            raise ValueError("Must specify only one of file or files")
    elif not file:
        file = 'configure.zcml'

    context = GroupingContextDecorator(_context)
    if package is not None:
        context.package = package
        context.basepath = None

    if files:
        paths = glob(context.path(files))
        paths = sorted(zip([path.lower() for path in paths], paths))
        paths = [path for (l, path) in paths]
    else:
        paths = [context.path(file)]

    for path in paths:
        # processFile returns a boolean indicating if the file has been
        # processed or not, it *also* marks the file as having been processed,
        # here the side effect is used to keep the given file from being
        # processed in the future
        context.processFile(path)
Пример #3
0
def include(_context, file=None, package=None, files=None):
    """Include a zcml file

    See examples in tests/text_xmlconfig.py
    """

    if files:
        if file:
            raise ValueError("Must specify only one of file or files")
    elif not file:
        file = 'configure.zcml'

    # This is a tad tricky. We want to behave as a grouping directive.

    context = GroupingContextDecorator(_context)
    if package is not None:
        context.package = package
        context.basepath = None

    if files:
        paths = glob(context.path(files))
        paths = sorted(zip([path.lower() for path in paths], paths))
        paths = [path for (l, path) in paths]
    else:
        paths = [context.path(file)]

    for path in paths:
        if context.processFile(path):
            with openInOrPlain(path) as f:
                logger.debug("include %s" % f.name)

                context.basepath = os.path.dirname(path)
                context.includepath = _context.includepath + (f.name, )
                _context.stack.append(GroupingStackItem(context))

                processxmlfile(f, context)
            assert _context.stack[-1].context is context
            _context.stack.pop()
Пример #4
0
def include(_context, file=None, package=None, files=None):
    """Include a zcml file

    See examples in tests/text_xmlconfig.py
    """

    if files:
        if file:
            raise ValueError("Must specify only one of file or files")
    elif not file:
        file = 'configure.zcml'

    # This is a tad tricky. We want to behave as a grouping directive.

    context = GroupingContextDecorator(_context)
    if package is not None:
        context.package = package
        context.basepath = None

    if files:
        paths = glob(context.path(files))
        paths = sorted(zip([path.lower() for path in paths], paths))
        paths = [path for (l, path) in paths]
    else:
        paths = [context.path(file)]

    for path in paths:
        if context.processFile(path):
            with openInOrPlain(path) as f:
                logger.debug("include %s" % f.name)

                context.basepath = os.path.dirname(path)
                context.includepath = _context.includepath + (f.name, )
                _context.stack.append(GroupingStackItem(context))

                processxmlfile(f, context)
            assert _context.stack[-1].context is context
            _context.stack.pop()