• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / zope.configuration / 16248876899

06 Dec 2024 07:34AM UTC coverage: 99.857%. Remained the same
16248876899

push

github

icemac
Back to development: 6.1

350 of 356 branches covered (98.31%)

Branch coverage included in aggregate %.

3850 of 3850 relevant lines covered (100.0%)

1.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/zope/configuration/interfaces.py
1
##############################################################################
2
#
3
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
4
# All Rights Reserved.
5
#
6
# This software is subject to the provisions of the Zope Public License,
7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
11
# FOR A PARTICULAR PURPOSE.
12
#
13
##############################################################################
14
"""Zope Configuration (ZCML) interfaces
15
"""
16
from zope.interface import Interface
1✔
17
from zope.schema import BytesLine
1✔
18
from zope.schema.interfaces import ValidationError
1✔
19

20

21
__all__ = [
1✔
22
    'InvalidToken',
23
    'IConfigurationContext',
24
    'IGroupingContext',
25
]
26

27

28
class InvalidToken(ValidationError):
1✔
29
    """Invalid token in list."""
30

31

32
class IConfigurationContext(Interface):
1✔
33
    """Configuration Context
34

35
    The configuration context manages information about the state of
36
    the configuration system, such as the package containing the
37
    configuration file. More importantly, it provides methods for
38
    importing objects and opening files relative to the package.
39
    """
40

41
    package = BytesLine(
1✔
42
        title=("The current package name"),
43
        description=("""\
44
          This is the name of the package containing the configuration
45
          file being executed. If the configuration file was not
46
          included by package, then this is None.
47
          """),
48
        required=False,
49
    )
50

51
    def resolve(dottedname):
1✔
52
        """Resolve a dotted name to an object
53

54
        A dotted name is constructed by concatenating a dotted module
55
        name with a global name within the module using a dot.  For
56
        example, the object named "spam" in the foo.bar module has a
57
        dotted name of foo.bar.spam.  If the current package is a
58
        prefix of a dotted name, then the package name can be relaced
59
        with a leading dot, So, for example, if the configuration file
60
        is in the foo package, then the dotted name foo.bar.spam can
61
        be shortened to .bar.spam.
62

63
        If the current package is multiple levels deep, multiple
64
        leading dots can be used to refer to higher-level modules.
65
        For example, if the current package is x.y.z, the dotted
66
        object name ..foo refers to x.y.foo.
67
        """
68

69
    def path(filename):
1✔
70
        """Compute a full file name for the given file
71

72
        If the filename is relative to the package, then the returned
73
        name will include the package path, otherwise, the original
74
        file name is returned.
75

76
        Environment variables in the path are expanded, and if the path
77
        begins with the username marker (~), that is expanded as well.
78

79
        .. versionchanged:: 4.2.0
80
            Start expanding home directories and environment variables.
81
        """
82

83
    def checkDuplicate(filename):
1✔
84
        """Check for duplicate imports of the same file.
85

86
        Raises an exception if this file had been processed before.  This
87
        is better than an unlimited number of conflict errors.
88
        """
89

90
    def processFile(filename):
1✔
91
        """Check whether a file needs to be processed.
92

93
        Return True if processing is needed and False otherwise.  If
94
        the file needs to be processed, it will be marked as
95
        processed, assuming that the caller will procces the file if
96
        it needs to be procssed.
97
        """
98

99
    def action(discriminator, callable, args=(), kw={}, order=0,
1✔
100
               includepath=None, info=None):
101
        """Record a configuration action
102

103
        The job of most directives is to compute actions for later
104
        processing. The action method is used to record those actions.
105

106
        :param callable: The object to call to implement the action.
107
        :param tuple args: Arguments to pass to *callable*
108
        :param dict kw: Keyword arguments to pass to *callable*
109

110
        :param object discriminator: Used to to find actions that conflict.
111
            Actions conflict if they have equal discriminators. The
112
            exception to this is the special case of the discriminator
113
            with the value `None`. An action with a discriminator of `None`
114
            never conflicts with other actions.
115

116
        :keyword int order: This is possible to add an order argument to
117
            crudely control the order of execution.
118

119
        :keyword str info: Optional source line information
120

121
        :keyword includepath: is None (the default) or a tuple of
122
            include paths for this action.
123
        """
124

125
    def provideFeature(name):
1✔
126
        """Record that a named feature is available in this context."""
127

128
    def hasFeature(name):
1✔
129
        """Check whether a named feature is available in this context."""
130

131

132
class IGroupingContext(Interface):
1✔
133

134
    def before():
1✔
135
        """Do something before processing nested directives
136
        """
137

138
    def after():
1✔
139
        """Do something after processing nested directives
140
        """
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc