CMS 3D CMS Logo

Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions

BeautifulSoup::PageElement Class Reference

Inheritance diagram for BeautifulSoup::PageElement:
BeautifulSoup::NavigableString BeautifulSoup::NavigableString BeautifulSoup::Tag BeautifulSoup::Tag BeautifulSoup::CData BeautifulSoup::CData BeautifulSoup::Comment BeautifulSoup::Comment BeautifulSoup::Declaration BeautifulSoup::Declaration BeautifulSoup::ProcessingInstruction BeautifulSoup::ProcessingInstruction BeautifulSoup::CData BeautifulSoup::CData BeautifulSoup::Comment BeautifulSoup::Comment BeautifulSoup::Declaration BeautifulSoup::Declaration BeautifulSoup::ProcessingInstruction BeautifulSoup::ProcessingInstruction BeautifulSoup::BeautifulStoneSoup BeautifulSoup::BeautifulStoneSoup BeautifulSoup::BeautifulStoneSoup BeautifulSoup::BeautifulStoneSoup

List of all members.

Public Member Functions

def append
def append
def extract
def extract
def findAllNext
def findAllNext
def findAllPrevious
def findAllPrevious
def findNext
def findNext
def findNextSibling
def findNextSibling
def findNextSiblings
def findNextSiblings
def findParent
def findParent
def findParents
def findParents
def findPrevious
def findPrevious
def findPreviousSibling
def findPreviousSibling
def findPreviousSiblings
def findPreviousSiblings
def insert
def insert
def nextGenerator
def nextGenerator
def nextSiblingGenerator
def nextSiblingGenerator
def parentGenerator
def parentGenerator
def previousGenerator
def previousGenerator
def previousSiblingGenerator
def previousSiblingGenerator
def replaceWith
def replaceWith
def setup
def setup
def substituteEncoding
def substituteEncoding
def toEncoding
def toEncoding

Public Attributes

 next
 nextSibling
 parent
 previous
 previousSibling

Static Public Attributes

 fetchNextSiblings = findNextSiblings
 fetchParents = findParents
 fetchPrevious = findAllPrevious
 fetchPreviousSiblings = findPreviousSiblings

Private Member Functions

def _findAll
def _findAll
def _findOne
def _findOne
def _lastRecursiveChild
def _lastRecursiveChild

Detailed Description

Contains the navigational information for some part of the page
(either a tag or a piece of text)

Definition at line 114 of file BeautifulSoup.py.


Member Function Documentation

def BeautifulSoup::PageElement::_findAll (   self,
  name,
  attrs,
  text,
  limit,
  generator,
  kwargs 
) [private]

Definition at line 325 of file BeautifulSoup.py.

00326                                                                      :
00327         "Iterates over a generator looking for things that match."
00328 
00329         if isinstance(name, SoupStrainer):
00330             strainer = name
00331         else:
00332             # Build a SoupStrainer
00333             strainer = SoupStrainer(name, attrs, text, **kwargs)
00334         results = ResultSet(strainer)
00335         g = generator()
00336         while True:
00337             try:
00338                 i = g.next()
00339             except StopIteration:
00340                 break
00341             if i:
00342                 found = strainer.search(i)
00343                 if found:
00344                     results.append(found)
00345                     if limit and len(results) >= limit:
00346                         break
00347         return results

def BeautifulSoup::PageElement::_findAll (   self,
  name,
  attrs,
  text,
  limit,
  generator,
  kwargs 
) [private]

Definition at line 325 of file BeautifulSoup.py.

00326                                                                      :
00327         "Iterates over a generator looking for things that match."
00328 
00329         if isinstance(name, SoupStrainer):
00330             strainer = name
00331         else:
00332             # Build a SoupStrainer
00333             strainer = SoupStrainer(name, attrs, text, **kwargs)
00334         results = ResultSet(strainer)
00335         g = generator()
00336         while True:
00337             try:
00338                 i = g.next()
00339             except StopIteration:
00340                 break
00341             if i:
00342                 found = strainer.search(i)
00343                 if found:
00344                     results.append(found)
00345                     if limit and len(results) >= limit:
00346                         break
00347         return results

def BeautifulSoup::PageElement::_findOne (   self,
  method,
  name,
  attrs,
  text,
  kwargs 
) [private]

Definition at line 318 of file BeautifulSoup.py.

00319                                                            :
00320         r = None
00321         l = method(name, attrs, text, 1, **kwargs)
00322         if l:
00323             r = l[0]
00324         return r

def BeautifulSoup::PageElement::_findOne (   self,
  method,
  name,
  attrs,
  text,
  kwargs 
) [private]

Definition at line 318 of file BeautifulSoup.py.

00319                                                            :
00320         r = None
00321         l = method(name, attrs, text, 1, **kwargs)
00322         if l:
00323             r = l[0]
00324         return r

def BeautifulSoup::PageElement::_lastRecursiveChild (   self) [private]

Definition at line 173 of file BeautifulSoup.py.

00174                                  :
00175         "Finds the last element beneath this object to be parsed."
00176         lastChild = self
00177         while hasattr(lastChild, 'contents') and lastChild.contents:
00178             lastChild = lastChild.contents[-1]
00179         return lastChild

def BeautifulSoup::PageElement::_lastRecursiveChild (   self) [private]

Definition at line 173 of file BeautifulSoup.py.

00174                                  :
00175         "Finds the last element beneath this object to be parsed."
00176         lastChild = self
00177         while hasattr(lastChild, 'contents') and lastChild.contents:
00178             lastChild = lastChild.contents[-1]
00179         return lastChild

def BeautifulSoup::PageElement::append (   self,
  tag 
)
Appends the given tag to the contents of this tag.

Definition at line 240 of file BeautifulSoup.py.

00241                          :
00242         """Appends the given tag to the contents of this tag."""
00243         self.insert(len(self.contents), tag)

def BeautifulSoup::PageElement::append (   self,
  tag 
)
Appends the given tag to the contents of this tag.

Definition at line 240 of file BeautifulSoup.py.

00241                          :
00242         """Appends the given tag to the contents of this tag."""
00243         self.insert(len(self.contents), tag)

def BeautifulSoup::PageElement::extract (   self)
Destructively rips this element out of the tree.

Definition at line 144 of file BeautifulSoup.py.

00145                      :
00146         """Destructively rips this element out of the tree."""
00147         if self.parent:
00148             try:
00149                 self.parent.contents.remove(self)
00150             except ValueError:
00151                 pass
00152 
00153         #Find the two elements that would be next to each other if
00154         #this element (and any children) hadn't been parsed. Connect
00155         #the two.
00156         lastChild = self._lastRecursiveChild()
00157         nextElement = lastChild.next
00158 
00159         if self.previous:
00160             self.previous.next = nextElement
00161         if nextElement:
00162             nextElement.previous = self.previous
00163         self.previous = None
00164         lastChild.next = None
00165 
00166         self.parent = None
00167         if self.previousSibling:
00168             self.previousSibling.nextSibling = self.nextSibling
00169         if self.nextSibling:
00170             self.nextSibling.previousSibling = self.previousSibling
00171         self.previousSibling = self.nextSibling = None
00172         return self

def BeautifulSoup::PageElement::extract (   self)
Destructively rips this element out of the tree.

Definition at line 144 of file BeautifulSoup.py.

00145                      :
00146         """Destructively rips this element out of the tree."""
00147         if self.parent:
00148             try:
00149                 self.parent.contents.remove(self)
00150             except ValueError:
00151                 pass
00152 
00153         #Find the two elements that would be next to each other if
00154         #this element (and any children) hadn't been parsed. Connect
00155         #the two.
00156         lastChild = self._lastRecursiveChild()
00157         nextElement = lastChild.next
00158 
00159         if self.previous:
00160             self.previous.next = nextElement
00161         if nextElement:
00162             nextElement.previous = self.previous
00163         self.previous = None
00164         lastChild.next = None
00165 
00166         self.parent = None
00167         if self.previousSibling:
00168             self.previousSibling.nextSibling = self.nextSibling
00169         if self.nextSibling:
00170             self.nextSibling.previousSibling = self.previousSibling
00171         self.previousSibling = self.nextSibling = None
00172         return self

def BeautifulSoup::PageElement::findAllNext (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns all items that match the given criteria and appear
after this Tag in the document.

Definition at line 249 of file BeautifulSoup.py.

00249                                            {}, text=None, limit=None,
00250                     **kwargs):
00251         """Returns all items that match the given criteria and appear
00252         after this Tag in the document."""
00253         return self._findAll(name, attrs, text, limit, self.nextGenerator,
00254                              **kwargs)
00255 
def BeautifulSoup::PageElement::findAllNext (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns all items that match the given criteria and appear
after this Tag in the document.

Definition at line 249 of file BeautifulSoup.py.

00249                                            {}, text=None, limit=None,
00250                     **kwargs):
00251         """Returns all items that match the given criteria and appear
00252         after this Tag in the document."""
00253         return self._findAll(name, attrs, text, limit, self.nextGenerator,
00254                              **kwargs)
00255 
def BeautifulSoup::PageElement::findAllPrevious (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns all items that match the given criteria and appear
before this Tag in the document.

Definition at line 275 of file BeautifulSoup.py.

00275                                                {}, text=None, limit=None,
00276                         **kwargs):
00277         """Returns all items that match the given criteria and appear
00278         before this Tag in the document."""
00279         return self._findAll(name, attrs, text, limit, self.previousGenerator,
00280                            **kwargs)
def BeautifulSoup::PageElement::findAllPrevious (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns all items that match the given criteria and appear
before this Tag in the document.

Definition at line 275 of file BeautifulSoup.py.

00275                                                {}, text=None, limit=None,
00276                         **kwargs):
00277         """Returns all items that match the given criteria and appear
00278         before this Tag in the document."""
00279         return self._findAll(name, attrs, text, limit, self.previousGenerator,
00280                            **kwargs)
def BeautifulSoup::PageElement::findNext (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the first item that matches the given criteria and
appears after this Tag in the document.

Definition at line 244 of file BeautifulSoup.py.

00244                                         {}, text=None, **kwargs):
00245         """Returns the first item that matches the given criteria and
00246         appears after this Tag in the document."""
00247         return self._findOne(self.findAllNext, name, attrs, text, **kwargs)
00248 
def BeautifulSoup::PageElement::findNext (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the first item that matches the given criteria and
appears after this Tag in the document.

Definition at line 244 of file BeautifulSoup.py.

00244                                         {}, text=None, **kwargs):
00245         """Returns the first item that matches the given criteria and
00246         appears after this Tag in the document."""
00247         return self._findOne(self.findAllNext, name, attrs, text, **kwargs)
00248 
def BeautifulSoup::PageElement::findNextSibling (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document.

Definition at line 256 of file BeautifulSoup.py.

00256                                                {}, text=None, **kwargs):
00257         """Returns the closest sibling to this Tag that matches the
00258         given criteria and appears after this Tag in the document."""
00259         return self._findOne(self.findNextSiblings, name, attrs, text,
00260                              **kwargs)
00261 
def BeautifulSoup::PageElement::findNextSibling (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the closest sibling to this Tag that matches the
given criteria and appears after this Tag in the document.

Definition at line 256 of file BeautifulSoup.py.

00256                                                {}, text=None, **kwargs):
00257         """Returns the closest sibling to this Tag that matches the
00258         given criteria and appears after this Tag in the document."""
00259         return self._findOne(self.findNextSiblings, name, attrs, text,
00260                              **kwargs)
00261 
def BeautifulSoup::PageElement::findNextSiblings (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns the siblings of this Tag that match the given
criteria and appear after this Tag in the document.

Definition at line 262 of file BeautifulSoup.py.

00262                                                 {}, text=None, limit=None,
00263                          **kwargs):
00264         """Returns the siblings of this Tag that match the given
00265         criteria and appear after this Tag in the document."""
00266         return self._findAll(name, attrs, text, limit,
00267                              self.nextSiblingGenerator, **kwargs)
def BeautifulSoup::PageElement::findNextSiblings (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns the siblings of this Tag that match the given
criteria and appear after this Tag in the document.

Definition at line 262 of file BeautifulSoup.py.

00262                                                 {}, text=None, limit=None,
00263                          **kwargs):
00264         """Returns the siblings of this Tag that match the given
00265         criteria and appear after this Tag in the document."""
00266         return self._findAll(name, attrs, text, limit,
00267                              self.nextSiblingGenerator, **kwargs)
def BeautifulSoup::PageElement::findParent (   self,
  name = None,
  attrs = {},
  kwargs 
)
Returns the closest parent of this Tag that matches the given
criteria.

Definition at line 297 of file BeautifulSoup.py.

00297                                           {}, **kwargs):
00298         """Returns the closest parent of this Tag that matches the given
00299         criteria."""
00300         # NOTE: We can't use _findOne because findParents takes a different
00301         # set of arguments.
00302         r = None
00303         l = self.findParents(name, attrs, 1)
00304         if l:
00305             r = l[0]
00306         return r
00307 
def BeautifulSoup::PageElement::findParent (   self,
  name = None,
  attrs = {},
  kwargs 
)
Returns the closest parent of this Tag that matches the given
criteria.

Definition at line 297 of file BeautifulSoup.py.

00297                                           {}, **kwargs):
00298         """Returns the closest parent of this Tag that matches the given
00299         criteria."""
00300         # NOTE: We can't use _findOne because findParents takes a different
00301         # set of arguments.
00302         r = None
00303         l = self.findParents(name, attrs, 1)
00304         if l:
00305             r = l[0]
00306         return r
00307 
def BeautifulSoup::PageElement::findParents (   self,
  name = None,
  attrs = {},
  limit = None,
  kwargs 
)
Returns the parents of this Tag that match the given
criteria.

Definition at line 308 of file BeautifulSoup.py.

00308                                            {}, limit=None, **kwargs):
00309         """Returns the parents of this Tag that match the given
00310         criteria."""
00311 
00312         return self._findAll(name, attrs, None, limit, self.parentGenerator,
00313                              **kwargs)
def BeautifulSoup::PageElement::findParents (   self,
  name = None,
  attrs = {},
  limit = None,
  kwargs 
)
Returns the parents of this Tag that match the given
criteria.

Definition at line 308 of file BeautifulSoup.py.

00308                                            {}, limit=None, **kwargs):
00309         """Returns the parents of this Tag that match the given
00310         criteria."""
00311 
00312         return self._findAll(name, attrs, None, limit, self.parentGenerator,
00313                              **kwargs)
def BeautifulSoup::PageElement::findPrevious (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the first item that matches the given criteria and
appears before this Tag in the document.

Definition at line 270 of file BeautifulSoup.py.

00270                                             {}, text=None, **kwargs):
00271         """Returns the first item that matches the given criteria and
00272         appears before this Tag in the document."""
00273         return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)
00274 
def BeautifulSoup::PageElement::findPrevious (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the first item that matches the given criteria and
appears before this Tag in the document.

Definition at line 270 of file BeautifulSoup.py.

00270                                             {}, text=None, **kwargs):
00271         """Returns the first item that matches the given criteria and
00272         appears before this Tag in the document."""
00273         return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs)
00274 
def BeautifulSoup::PageElement::findPreviousSibling (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document.

Definition at line 283 of file BeautifulSoup.py.

00283                                                    {}, text=None, **kwargs):
00284         """Returns the closest sibling to this Tag that matches the
00285         given criteria and appears before this Tag in the document."""
00286         return self._findOne(self.findPreviousSiblings, name, attrs, text,
00287                              **kwargs)
00288 
def BeautifulSoup::PageElement::findPreviousSibling (   self,
  name = None,
  attrs = {},
  text = None,
  kwargs 
)
Returns the closest sibling to this Tag that matches the
given criteria and appears before this Tag in the document.

Definition at line 283 of file BeautifulSoup.py.

00283                                                    {}, text=None, **kwargs):
00284         """Returns the closest sibling to this Tag that matches the
00285         given criteria and appears before this Tag in the document."""
00286         return self._findOne(self.findPreviousSiblings, name, attrs, text,
00287                              **kwargs)
00288 
def BeautifulSoup::PageElement::findPreviousSiblings (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns the siblings of this Tag that match the given
criteria and appear before this Tag in the document.

Definition at line 289 of file BeautifulSoup.py.

00289                                                     {}, text=None,
00290                              limit=None, **kwargs):
00291         """Returns the siblings of this Tag that match the given
00292         criteria and appear before this Tag in the document."""
00293         return self._findAll(name, attrs, text, limit,
00294                              self.previousSiblingGenerator, **kwargs)
def BeautifulSoup::PageElement::findPreviousSiblings (   self,
  name = None,
  attrs = {},
  text = None,
  limit = None,
  kwargs 
)
Returns the siblings of this Tag that match the given
criteria and appear before this Tag in the document.

Definition at line 289 of file BeautifulSoup.py.

00289                                                     {}, text=None,
00290                              limit=None, **kwargs):
00291         """Returns the siblings of this Tag that match the given
00292         criteria and appear before this Tag in the document."""
00293         return self._findAll(name, attrs, text, limit,
00294                              self.previousSiblingGenerator, **kwargs)
def BeautifulSoup::PageElement::insert (   self,
  position,
  newChild 
)

Definition at line 180 of file BeautifulSoup.py.

00181                                         :
00182         if (isinstance(newChild, basestring)
00183             or isinstance(newChild, unicode)) \
00184             and not isinstance(newChild, NavigableString):
00185             newChild = NavigableString(newChild)
00186 
00187         position =  min(position, len(self.contents))
00188         if hasattr(newChild, 'parent') and newChild.parent != None:
00189             # We're 'inserting' an element that's already one
00190             # of this object's children.
00191             if newChild.parent == self:
00192                 index = self.find(newChild)
00193                 if index and index < position:
00194                     # Furthermore we're moving it further down the
00195                     # list of this object's children. That means that
00196                     # when we extract this element, our target index
00197                     # will jump down one.
00198                     position = position - 1
00199             newChild.extract()
00200 
00201         newChild.parent = self
00202         previousChild = None
00203         if position == 0:
00204             newChild.previousSibling = None
00205             newChild.previous = self
00206         else:
00207             previousChild = self.contents[position-1]
00208             newChild.previousSibling = previousChild
00209             newChild.previousSibling.nextSibling = newChild
00210             newChild.previous = previousChild._lastRecursiveChild()
00211         if newChild.previous:
00212             newChild.previous.next = newChild
00213 
00214         newChildsLastElement = newChild._lastRecursiveChild()
00215 
00216         if position >= len(self.contents):
00217             newChild.nextSibling = None
00218 
00219             parent = self
00220             parentsNextSibling = None
00221             while not parentsNextSibling:
00222                 parentsNextSibling = parent.nextSibling
00223                 parent = parent.parent
00224                 if not parent: # This is the last element in the document.
00225                     break
00226             if parentsNextSibling:
00227                 newChildsLastElement.next = parentsNextSibling
00228             else:
00229                 newChildsLastElement.next = None
00230         else:
00231             nextChild = self.contents[position]
00232             newChild.nextSibling = nextChild
00233             if newChild.nextSibling:
00234                 newChild.nextSibling.previousSibling = newChild
00235             newChildsLastElement.next = nextChild
00236 
00237         if newChildsLastElement.next:
00238             newChildsLastElement.next.previous = newChildsLastElement
00239         self.contents.insert(position, newChild)

def BeautifulSoup::PageElement::insert (   self,
  position,
  newChild 
)

Definition at line 180 of file BeautifulSoup.py.

00181                                         :
00182         if (isinstance(newChild, basestring)
00183             or isinstance(newChild, unicode)) \
00184             and not isinstance(newChild, NavigableString):
00185             newChild = NavigableString(newChild)
00186 
00187         position =  min(position, len(self.contents))
00188         if hasattr(newChild, 'parent') and newChild.parent != None:
00189             # We're 'inserting' an element that's already one
00190             # of this object's children.
00191             if newChild.parent == self:
00192                 index = self.find(newChild)
00193                 if index and index < position:
00194                     # Furthermore we're moving it further down the
00195                     # list of this object's children. That means that
00196                     # when we extract this element, our target index
00197                     # will jump down one.
00198                     position = position - 1
00199             newChild.extract()
00200 
00201         newChild.parent = self
00202         previousChild = None
00203         if position == 0:
00204             newChild.previousSibling = None
00205             newChild.previous = self
00206         else:
00207             previousChild = self.contents[position-1]
00208             newChild.previousSibling = previousChild
00209             newChild.previousSibling.nextSibling = newChild
00210             newChild.previous = previousChild._lastRecursiveChild()
00211         if newChild.previous:
00212             newChild.previous.next = newChild
00213 
00214         newChildsLastElement = newChild._lastRecursiveChild()
00215 
00216         if position >= len(self.contents):
00217             newChild.nextSibling = None
00218 
00219             parent = self
00220             parentsNextSibling = None
00221             while not parentsNextSibling:
00222                 parentsNextSibling = parent.nextSibling
00223                 parent = parent.parent
00224                 if not parent: # This is the last element in the document.
00225                     break
00226             if parentsNextSibling:
00227                 newChildsLastElement.next = parentsNextSibling
00228             else:
00229                 newChildsLastElement.next = None
00230         else:
00231             nextChild = self.contents[position]
00232             newChild.nextSibling = nextChild
00233             if newChild.nextSibling:
00234                 newChild.nextSibling.previousSibling = newChild
00235             newChildsLastElement.next = nextChild
00236 
00237         if newChildsLastElement.next:
00238             newChildsLastElement.next.previous = newChildsLastElement
00239         self.contents.insert(position, newChild)

def BeautifulSoup::PageElement::nextGenerator (   self)

Definition at line 350 of file BeautifulSoup.py.

00351                            :
00352         i = self
00353         while i:
00354             i = i.next
00355             yield i

def BeautifulSoup::PageElement::nextGenerator (   self)

Definition at line 350 of file BeautifulSoup.py.

00351                            :
00352         i = self
00353         while i:
00354             i = i.next
00355             yield i

def BeautifulSoup::PageElement::nextSiblingGenerator (   self)

Definition at line 356 of file BeautifulSoup.py.

00357                                   :
00358         i = self
00359         while i:
00360             i = i.nextSibling
00361             yield i

def BeautifulSoup::PageElement::nextSiblingGenerator (   self)

Definition at line 356 of file BeautifulSoup.py.

00357                                   :
00358         i = self
00359         while i:
00360             i = i.nextSibling
00361             yield i

def BeautifulSoup::PageElement::parentGenerator (   self)

Definition at line 374 of file BeautifulSoup.py.

00375                              :
00376         i = self
00377         while i:
00378             i = i.parent
00379             yield i

def BeautifulSoup::PageElement::parentGenerator (   self)

Definition at line 374 of file BeautifulSoup.py.

00375                              :
00376         i = self
00377         while i:
00378             i = i.parent
00379             yield i

def BeautifulSoup::PageElement::previousGenerator (   self)

Definition at line 362 of file BeautifulSoup.py.

00363                                :
00364         i = self
00365         while i:
00366             i = i.previous
00367             yield i

def BeautifulSoup::PageElement::previousGenerator (   self)

Definition at line 362 of file BeautifulSoup.py.

00363                                :
00364         i = self
00365         while i:
00366             i = i.previous
00367             yield i

def BeautifulSoup::PageElement::previousSiblingGenerator (   self)

Definition at line 368 of file BeautifulSoup.py.

00369                                       :
00370         i = self
00371         while i:
00372             i = i.previousSibling
00373             yield i

def BeautifulSoup::PageElement::previousSiblingGenerator (   self)

Definition at line 368 of file BeautifulSoup.py.

00369                                       :
00370         i = self
00371         while i:
00372             i = i.previousSibling
00373             yield i

def BeautifulSoup::PageElement::replaceWith (   self,
  replaceWith 
)

Definition at line 130 of file BeautifulSoup.py.

00131                                       :
00132         oldParent = self.parent
00133         myIndex = self.parent.contents.index(self)
00134         if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent:
00135             # We're replacing this element with one of its siblings.
00136             index = self.parent.contents.index(replaceWith)
00137             if index and index < myIndex:
00138                 # Furthermore, it comes before this element. That
00139                 # means that when we extract it, the index of this
00140                 # element will change.
00141                 myIndex = myIndex - 1
00142         self.extract()
00143         oldParent.insert(myIndex, replaceWith)

def BeautifulSoup::PageElement::replaceWith (   self,
  replaceWith 
)

Definition at line 130 of file BeautifulSoup.py.

00131                                       :
00132         oldParent = self.parent
00133         myIndex = self.parent.contents.index(self)
00134         if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent:
00135             # We're replacing this element with one of its siblings.
00136             index = self.parent.contents.index(replaceWith)
00137             if index and index < myIndex:
00138                 # Furthermore, it comes before this element. That
00139                 # means that when we extract it, the index of this
00140                 # element will change.
00141                 myIndex = myIndex - 1
00142         self.extract()
00143         oldParent.insert(myIndex, replaceWith)

def BeautifulSoup::PageElement::setup (   self,
  parent = None,
  previous = None 
)
Sets up the initial relations between this element and
other elements.

Definition at line 118 of file BeautifulSoup.py.

00119                                                :
00120         """Sets up the initial relations between this element and
00121         other elements."""
00122         self.parent = parent
00123         self.previous = previous
00124         self.next = None
00125         self.previousSibling = None
00126         self.nextSibling = None
00127         if self.parent and self.parent.contents:
00128             self.previousSibling = self.parent.contents[-1]
00129             self.previousSibling.nextSibling = self

def BeautifulSoup::PageElement::setup (   self,
  parent = None,
  previous = None 
)
Sets up the initial relations between this element and
other elements.

Definition at line 118 of file BeautifulSoup.py.

00119                                                :
00120         """Sets up the initial relations between this element and
00121         other elements."""
00122         self.parent = parent
00123         self.previous = previous
00124         self.next = None
00125         self.previousSibling = None
00126         self.nextSibling = None
00127         if self.parent and self.parent.contents:
00128             self.previousSibling = self.parent.contents[-1]
00129             self.previousSibling.nextSibling = self

def BeautifulSoup::PageElement::substituteEncoding (   self,
  str,
  encoding = None 
)

Definition at line 381 of file BeautifulSoup.py.

00382                                                     :
00383         encoding = encoding or "utf-8"
00384         return str.replace("%SOUP-ENCODING%", encoding)

def BeautifulSoup::PageElement::substituteEncoding (   self,
  str,
  encoding = None 
)

Definition at line 381 of file BeautifulSoup.py.

00382                                                     :
00383         encoding = encoding or "utf-8"
00384         return str.replace("%SOUP-ENCODING%", encoding)

def BeautifulSoup::PageElement::toEncoding (   self,
  s,
  encoding = None 
)
Encodes an object to a string in some encoding, or to Unicode.
.

Definition at line 385 of file BeautifulSoup.py.

00386                                           :
00387         """Encodes an object to a string in some encoding, or to Unicode.
00388         ."""
00389         if isinstance(s, unicode):
00390             if encoding:
00391                 s = s.encode(encoding)
00392         elif isinstance(s, str):
00393             if encoding:
00394                 s = s.encode(encoding)
00395             else:
00396                 s = unicode(s)
00397         else:
00398             if encoding:
00399                 s  = self.toEncoding(str(s), encoding)
00400             else:
00401                 s = unicode(s)
00402         return s

def BeautifulSoup::PageElement::toEncoding (   self,
  s,
  encoding = None 
)
Encodes an object to a string in some encoding, or to Unicode.
.

Definition at line 385 of file BeautifulSoup.py.

00386                                           :
00387         """Encodes an object to a string in some encoding, or to Unicode.
00388         ."""
00389         if isinstance(s, unicode):
00390             if encoding:
00391                 s = s.encode(encoding)
00392         elif isinstance(s, str):
00393             if encoding:
00394                 s = s.encode(encoding)
00395             else:
00396                 s = unicode(s)
00397         else:
00398             if encoding:
00399                 s  = self.toEncoding(str(s), encoding)
00400             else:
00401                 s = unicode(s)
00402         return s


Member Data Documentation

BeautifulSoup::PageElement::fetchNextSiblings = findNextSiblings [static]

Definition at line 268 of file BeautifulSoup.py.

Definition at line 314 of file BeautifulSoup.py.

BeautifulSoup::PageElement::fetchPrevious = findAllPrevious [static]

Definition at line 281 of file BeautifulSoup.py.

BeautifulSoup::PageElement::fetchPreviousSiblings = findPreviousSiblings [static]

Definition at line 295 of file BeautifulSoup.py.

Definition at line 119 of file BeautifulSoup.py.

Definition at line 119 of file BeautifulSoup.py.

Definition at line 119 of file BeautifulSoup.py.

Reimplemented in BeautifulSoup::BeautifulStoneSoup.

Definition at line 119 of file BeautifulSoup.py.

Definition at line 119 of file BeautifulSoup.py.