Simplify some code

This commit is contained in:
Kovid Goyal 2015-01-01 08:58:45 +05:30
parent acfcc63cfc
commit eb6317512f

View File

@ -308,7 +308,7 @@ def upshift_markup(parts):
def handle_media_queries(raw): def handle_media_queries(raw):
# cssutils cannot handle CSS 3 media queries. We look for media queries # cssutils cannot handle CSS 3 media queries. We look for media queries
# that use amzn-mobi or amzn-kf8 and map them to asimple @media screen # that use amzn-mobi or amzn-kf8 and map them to a simple @media screen
# rule. See https://bugs.launchpad.net/bugs/1406708 for an example # rule. See https://bugs.launchpad.net/bugs/1406708 for an example
import tinycss import tinycss
parser = tinycss.make_full_parser() parser = tinycss.make_full_parser()
@ -317,10 +317,8 @@ def handle_media_queries(raw):
for mq in sheet.rules[0].media: for mq in sheet.rules[0].media:
# Only accept KF8 media types # Only accept KF8 media types
if (mq.media_type, mq.negated) in {('amzn-mobi', True), ('amzn-kf8', False)}: if (mq.media_type, mq.negated) in {('amzn-mobi', True), ('amzn-kf8', False)}:
break return '@media screen {'
else: return m.group()
return m.group()
return '@media screen {'
return re.sub(r'@media\s[^{]*{', replace, raw) return re.sub(r'@media\s[^{]*{', replace, raw)