Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete call of searchInterface from interfaceToName #33

Merged
merged 1 commit into from
Sep 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Changes
4.4.1 (unreleased)
------------------

- Nothing changed yet.

- Remove obsolete call of searchInterface from interfaceToName

4.4.0 (2017-07-25)
------------------
Expand Down
22 changes: 5 additions & 17 deletions src/zope/component/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from zope.component._api import queryUtility
from zope.component._compat import CLASS_TYPES


def provideInterface(id, interface, iface_type=None, info=''):
""" Mark 'interface' as a named utilty providing 'iface_type'.
"""
Expand Down Expand Up @@ -79,7 +80,7 @@ def searchInterfaceUtilities(context, search_string=None, base=None):
if search_string:
search_string = search_string.lower()
iface_utilities = [iface_util for iface_util in iface_utilities
if (getInterfaceAllDocs(iface_util[1]).\
if (getInterfaceAllDocs(iface_util[1]).
find(search_string) >= 0)]
if base:
res = [iface_util for iface_util in iface_utilities
Expand All @@ -90,7 +91,7 @@ def searchInterfaceUtilities(context, search_string=None, base=None):


def getInterfaceAllDocs(interface):
iface_id = '%s.%s' %(interface.__module__, interface.__name__)
iface_id = '%s.%s' % (interface.__module__, interface.__name__)
docs = [str(iface_id).lower(),
str(interface.__doc__).lower()]

Expand All @@ -108,21 +109,8 @@ def nameToInterface(context, id):
iface = getInterface(context, id)
return iface


def interfaceToName(context, interface):
if interface is None:
return 'None'
# XXX this search is pointless: we are always going to return the
# same value whether or not we find anything.
items = searchInterface(context, base=interface)
ids = [('%s.%s' %(iface.__module__, iface.__name__))
for iface in items
if iface == interface]

if not ids:
# Do not fail badly, instead resort to the standard
# way of getting the interface name, cause not all interfaces
# may be registered as utilities.
return interface.__module__ + '.' + interface.__name__

assert len(ids) == 1, "Ambiguous interface names: %s" % ids
return ids[0]
return '%s.%s' % (interface.__module__, interface.__name__)