getprotocol now takes the options as named arguments, which make it easier to use from outside

This commit is contained in:
Christophe de Vienne 2011-10-13 17:04:10 +02:00
parent 3de7a3a1e7
commit 4f97494c6a

View File

@ -126,12 +126,11 @@ def register_protocol(protocol):
registered_protocols[protocol.name] = protocol registered_protocols[protocol.name] = protocol
def getprotocol(name, options={}): def getprotocol(name, **options):
protocol_class = registered_protocols.get(name) protocol_class = registered_protocols.get(name)
if protocol_class is None: if protocol_class is None:
for entry_point in pkg_resources.iter_entry_points( for entry_point in pkg_resources.iter_entry_points(
'wsme.protocols'): 'wsme.protocols', name):
print entry_point
if entry_point.name == name: if entry_point.name == name:
protocol_class = entry_point.load() protocol_class = entry_point.load()
if protocol_class is None: if protocol_class is None:
@ -384,7 +383,6 @@ class WSRoot(object):
lexer = None lexer = None
for ct in content_types: for ct in content_types:
try: try:
print ct
lexer = get_lexer_for_mimetype(ct) lexer = get_lexer_for_mimetype(ct)
break break
except: except: