mirror of https://github.com/scrapy/scrapy.git
added __nonzero__ method to XPathSelector
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40298
This commit is contained in:
parent
ac4688dabb
commit
acebe63d0a
|
|
@ -84,6 +84,9 @@ class XPathSelector(object):
|
|||
"""Register namespace so that it can be used in XPath queries"""
|
||||
self.doc.xpathContext.xpathRegisterNs(prefix, uri)
|
||||
|
||||
def __nonzero__(self):
|
||||
return bool(self.extract())
|
||||
|
||||
def __str__(self):
|
||||
return "<%s (%s) xpath=%s>" % (type(self).__name__, getattr(self.xmlNode, 'name', type(self.xmlNode).__name__), self.expr)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue