def search(cls, **type):
"""Search through all of the imports within the database and return the first result.
Please review the help for imports.list for the definition of ``type``.
"""
query_s = ', '.join("{:s}={!r}".format(k,v) for k,v in type.iteritems())
res = __builtin__.list(cls.iterate(**type))
if len(res) > 1:
__builtin__.map(logging.info, ("{:x} {:s}<{:d}> {:s}".format(ea, module, ordinal, name) for ea,(module,name,ordinal) in res))
f = utils.compose(utils.second, cls.__formatl__)
logging.warn("{:s}.search({:s}) : Found {:d} matching results, returning the first one. : {!r}".format('.'.join((__name__,cls.__name__)), query_s, len(res), f(res[0])))
res = __builtin__.next(iter(res), None)
if res is None:
raise LookupError("{:s}.search({:s}) : Found 0 matching results.".format('.'.join((__name__,cls.__name__)), query_s))
return res[0]
评论列表
文章目录