Changeset 487

Show
Ignore:
Timestamp:
09/09/08 16:17:26 (18 months ago)
Author:
tom
Message:

reverted html=False to full_strip=True

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • libraries/web/wikipedia.py

    r461 r487  
    427427class WikipediaPage: 
    428428     
    429     def __init__(self, title, markup, light=False, html=False): 
     429    def __init__(self, title, markup, light=False, full_strip=True): 
    430430         
    431431        """ Wikipedia page parser. 
     
    433433        The expected markup is the stuff in Wikipedia's edit textarea. 
    434434        With light=True, it will onlt parse links to other articles (which is faster). 
    435         With html=True, it will preserve some HTML markup (links, bold, italic). 
     435        With full_strip=False, it will preserve some HTML markup (links, bold, italic). 
    436436         
    437437        """ 
     
    439439        self.title = title 
    440440        self.markup = markup 
    441         self.html = html 
     441        self.full_strip = full_strip 
    442442         
    443443        self.disambiguation = [] 
     
    546546        Does some commonsense maintenance as well, 
    547547        like collapsing multiple spaces. 
    548         If you specified html=True for WikipediaPage instance, 
     548        If you specified full_strip=False for WikipediaPage instance, 
    549549        some markup is preserved as HTML (links, bold, italic). 
    550550         
     
    552552         
    553553        # Strip bold and italic. 
    554         if not self.html: 
     554        if self.full_strip: 
    555555            markup = markup.replace("'''", "") 
    556556            markup = markup.replace("''", "") 
     
    569569        # Strip links, keeping the display alias. 
    570570        # We'll strip the ending ]] later. 
    571         if not self.html: 
     571        if self.full_strip: 
    572572            markup = re.sub(r"\[\[[^\]]*?\|", "", markup) 
    573573        else: 
     
    626626         
    627627        # Strip all HTML except <math> tags. 
    628         if not self.html: 
     628        if self.full_strip: 
    629629            markup = strip_tags(markup, exclude=["math"], linebreaks=True) 
    630630         
     
    15471547     
    15481548    def __init__(self, q, language="en", light=False, wait=10, asynchronous=False, cached=True, 
    1549                  case_sensitive=False, html=False): 
     1549                 case_sensitive=False, full_strip=True): 
    15501550         
    15511551        """ A download manager for Wikipedia pages. 
     
    15611561         
    15621562        self._light = light 
    1563         self._html = html 
     1563        self._full_strip = full_strip 
    15641564         
    15651565        if cached:  
     
    15871587            data = "" 
    15881588 
    1589         WikipediaPage.__init__(self,  title, data, light=self._light, html=self._html) 
     1589        WikipediaPage.__init__(self,  title, data, light=self._light, full_strip=self._full_strip) 
    15901590 
    15911591def search(q, language="en", light=False, wait=10, asynchronous=False, cached=True,  
    1592            case_sensitive=False, html=False): 
    1593     return WikipediaSearch(q, language, light, wait, asynchronous, cached, case_sensitive, html) 
     1592           case_sensitive=False, full_strip=True): 
     1593    return WikipediaSearch(q, language, light, wait, asynchronous, cached, case_sensitive, full_strip) 
    15941594 
    15951595######################################################################################################