mercurial/thirdparty/zope/interface/__init__.py
author Martin von Zweigbergk <martinvonz@google.com>
Thu, 10 Jun 2021 14:47:14 -0700
changeset 47436 3ee036c6f834
parent 37180 68ee61822182
permissions -rw-r--r--
commit: keep opts dict str-keyed a bit longer Differential Revision: https://phab.mercurial-scm.org/D10861
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
##############################################################################
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
# All Rights Reserved.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
#
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# This software is subject to the provisions of the Zope Public License,
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     9
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    10
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    11
# FOR A PARTICULAR PURPOSE.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    12
#
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    13
##############################################################################
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    14
"""Interfaces
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    15
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    16
This package implements the Python "scarecrow" proposal.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    17
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    18
The package exports two objects, `Interface` and `Attribute` directly. It also
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    19
exports several helper methods. Interface is used to create an interface with
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    20
a class statement, as in:
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    21
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    22
  class IMyInterface(Interface):
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    23
    '''Interface documentation
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    24
    '''
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    25
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    26
    def meth(arg1, arg2):
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    27
        '''Documentation for meth
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    28
        '''
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    29
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    30
    # Note that there is no self argument
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    31
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    32
To find out what you can do with interfaces, see the interface
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    33
interface, `IInterface` in the `interfaces` module.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    34
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    35
The package has several public modules:
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    36
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    37
  o `declarations` provides utilities to declare interfaces on objects. It
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    38
    also provides a wide range of helpful utilities that aid in managing
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    39
    declared interfaces. Most of its public names are however imported here.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    40
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    41
  o `document` has a utility for documenting an interface as structured text.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    42
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    43
  o `exceptions` has the interface-defined exceptions
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    44
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    45
  o `interfaces` contains a list of all public interfaces for this package.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    46
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    47
  o `verify` has utilities for verifying implementations of interfaces.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    48
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    49
See the module doc strings for more information.
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    50
"""
37180
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    51
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    52
from __future__ import absolute_import
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    53
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    54
__docformat__ = 'restructuredtext'
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    55
37180
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    56
from .interface import Interface
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    57
from .interface import _wire
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    58
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    59
# Need to actually get the interface elements to implement the right interfaces
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    60
_wire()
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    61
del _wire
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    62
37180
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    63
from .declarations import Declaration
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    64
from .declarations import alsoProvides
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    65
from .declarations import classImplements
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    66
from .declarations import classImplementsOnly
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    67
from .declarations import classProvides
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    68
from .declarations import directlyProvidedBy
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    69
from .declarations import directlyProvides
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    70
from .declarations import implementedBy
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    71
from .declarations import implementer
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    72
from .declarations import implementer_only
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    73
from .declarations import implements
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    74
from .declarations import implementsOnly
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    75
from .declarations import moduleProvides
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    76
from .declarations import named
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    77
from .declarations import noLongerProvides
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    78
from .declarations import providedBy
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    79
from .declarations import provider
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    80
from .exceptions import Invalid
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    81
from .interface import Attribute
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    82
from .interface import invariant
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    83
from .interface import taggedValue
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
# The following are to make spec pickles cleaner
37180
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    86
from .declarations import Provides
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
37180
68ee61822182 thirdparty: port zope.interface to relative imports
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37178
diff changeset
    89
from .interfaces import IInterfaceDeclaration
37178
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
moduleProvides(IInterfaceDeclaration)
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
943d77fc07a3 thirdparty: vendor zope.interface 4.4.3
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
__all__ = ('Interface', 'Attribute') + tuple(IInterfaceDeclaration)