Changeset 2891:1c3b8d323456 in livinglogic.python.xist

Show
Ignore:
Timestamp:
08/21/07 12:02:17 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Rename css.replaceurl() to css.replaceurls() and use the replaceUrls() function from cssutils r242.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/css.py

    r2881 r2891  
    3535 
    3636 
    37 def replaceurl(style, replacer): 
     37def replaceurls(style, replacer): 
    3838    """ 
    3939    Replace all &url;s appearing in the <class>CSSStyleDeclaration<class> 
     
    4141    called and the &url; will be replace with the result. 
    4242    """ 
    43     for proplist in style.seq: 
    44         if not isinstance(proplist, css.CSSComment): 
    45             for prop in proplist: 
    46                 newvalue = [] 
    47                 for value in prop.cssValue.seq: 
    48                     if value.startswith("url(") and value.endswith(")"): 
    49                         value = "url(%s)" % replacer(url.URL(value[4:-1])) 
    50                     newvalue.append(value) 
    51                 prop.cssValue = "".join(newvalue) 
     43    def newreplacer(u): 
     44        if u.startswith("'") and u.endswith("'"): 
     45            u = u[1:-1] 
     46        elif u.startswith('"') and u.endswith('"'): 
     47            u = u[1:-1] 
     48        u = replacer(url.URL(u)) 
     49        return unicode(u) 
     50    style.replaceUrls(newreplacer) # This needs at least r242 of cssutils 
    5251 
    5352 
     
    8584                if wantmedia in rule.media: 
    8685                    for subrule in rule.cssRules: 
    87                         replaceurl(subrule.style, prependbase) 
     86                        replaceurls(subrule.style, prependbase) 
    8887                        yield subrule 
    8988            elif rule.type == css.CSSRule.STYLE_RULE: 
    90                 replaceurl(rule.style, prependbase) 
     89                replaceurls(rule.style, prependbase) 
    9190                yield rule 
    9291