Changeset 2929 in products


Ignore:
Timestamp:
Oct 26, 2010 2:55:15 PM (13 years ago)
Author:
mylan
Message:

#233: Make code more readable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/keywords.py

    r2927 r2929  
    3838        if isExternal: 
    3939            # Not pass timeout option because: 
    40             # 1. its value get from the global default timeout settings by default. 
     40            # 1. its value get from the global default timeout settings. 
    4141            # 2. timeout option added in python 2.6 (so acceptable only in plone4+) 
    4242            try: 
     
    4545                    html = resp.read() 
    4646                finally: 
    47                     'resp' in locals().keys() and resp.close() 
     47                    if 'resp' in locals().keys(): 
     48                        resp.close() 
    4849            except (urllib2.URLError, urllib2.HTTPError), e: 
    4950                # In case of exceed timeout period or other URL connection errors. 
     
    5859        # If no html - information about problem with page retrieval should be returned 
    5960        result = [] 
    60         if html is not None: 
     61        if html is None: 
     62            sfx = error_url and ", details at %s." % error_url or "." 
     63            result.append("Problem with page retrieval" + sfx) 
     64        else: 
    6165            page_text = transforms.convert("html_to_text", html).getData() 
    6266            # check every keyword on appearing in body of html page 
     
    6468                keyword_on_page = unicode(len(re.findall(u'\\b%s\\b' % keyword, page_text, re.I|re.U))) 
    6569                result.append(' - '.join((keyword, keyword_on_page))) 
    66         else: 
    67             sfx = error_url and ", details at %s." % error_url or "." 
    68             result.append("Problem with page retrieval" + sfx) 
    6970 
    7071        return ts.utranslate(domain='quintagroup.seoptimizer', 
Note: See TracChangeset for help on using the changeset viewer.