本文整理汇总了Python中mincss.processor.Processor.process方法的典型用法代码示例。如果您正苦于以下问题:Python Processor.process方法的具体用法?Python Processor.process怎么用?Python Processor.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mincss.processor.Processor
的用法示例。
在下文中一共展示了Processor.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pseudo_selectors_hell
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_pseudo_selectors_hell(self):
html = os.path.join(HERE, 'three.html')
url = 'file://' + html
p = Processor(preserve_remote_urls=False)
p.process(url)
# two.html only has 1 link CSS ref
link = p.links[0]
after = link.after
self.assertTrue('a.three:hover' in after)
self.assertTrue('a.hundred:link' not in after)
self.assertTrue('.container > a.one' in after)
self.assertTrue('.container > a.notused' not in after)
self.assertTrue('input[type="button"]' not in after)
self.assertTrue('input[type="search"]::-webkit-search-decoration' in after)
self.assertTrue('input[type="reset"]::-webkit-search-decoration' not in after)
self.assertTrue('@media (max-width: 900px)' in after)
self.assertTrue('.container .two' in after)
self.assertTrue('a.four' not in after)
self.assertTrue('::-webkit-input-placeholder' in after)
self.assertTrue(':-moz-placeholder {' in after)
self.assertTrue('div::-moz-focus-inner' in after)
self.assertTrue('button::-moz-focus-inner' not in after)
self.assertTrue('@-webkit-keyframes progress-bar-stripes' in after)
self.assertTrue('from {' in after)
# some day perhaps this can be untangled and parsed too
self.assertTrue('@import url(other.css)' in after)
示例2: _execute
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def _execute(self, options, args):
"""Apply mincss the generated site."""
output_folder = self.site.config['OUTPUT_FOLDER']
if Processor is None:
print('To use the mincss command,'
' you have to install the "mincss" package.')
return
p = Processor(preserve_remote_urls=False)
urls = []
css_files = {}
for root, dirs, files in os.walk(output_folder):
for f in files:
url = os.path.join(root, f)
if url.endswith('.css'):
fname = os.path.basename(url)
if fname in css_files:
print("You have two CSS files with the same name and that confuses me.")
sys.exit(1)
css_files[fname] = url
if not f.endswith('.html'):
continue
urls.append(url)
p.process(*urls)
for inline in p.links:
fname = os.path.basename(inline.href)
print("===>", inline.href, len(inline.before), len(inline.after))
with open(css_files[fname], 'wb+') as outf:
outf.write(inline.after)
示例3: test_no_mincss_link
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_no_mincss_link(self):
html = os.path.join(HERE, 'no-mincss-link.html')
url = 'file://' + html
p = Processor()
p.process(url)
link = p.links[0]
eq_(link.before, link.after)
示例4: test_pseudo_selectors_hell
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_pseudo_selectors_hell(self):
html = os.path.join(HERE, "three.html")
url = "file://" + html
p = Processor(preserve_remote_urls=False)
p.process(url)
# two.html only has 1 link CSS ref
link = p.links[0]
after = link.after
ok_("a.three:hover" in after)
ok_("a.hundred:link" not in after)
ok_(".container > a.one" in after)
ok_(".container > a.notused" not in after)
ok_('input[type="button"]' not in after)
ok_('input[type="search"]::-webkit-search-decoration' in after)
ok_('input[type="reset"]::-webkit-search-decoration' not in after)
ok_("@media (max-width: 900px)" in after)
ok_(".container .two" in after)
ok_("a.four" not in after)
ok_("::-webkit-input-placeholder" in after)
ok_(":-moz-placeholder {" in after)
ok_("div::-moz-focus-inner" in after)
ok_("button::-moz-focus-inner" not in after)
ok_("@-webkit-keyframes progress-bar-stripes" in after)
ok_("from {" in after)
# print after
# some day perhaps this can be untangled and parsed too
ok_("@import url(other.css)" in after)
示例5: _execute
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def _execute(self, options, args):
"""Apply mincss the generated site."""
output_folder = self.site.config['OUTPUT_FOLDER']
if Processor is None:
req_missing(['mincss'], 'use the "mincss" command')
return
p = Processor(preserve_remote_urls=False)
urls = []
css_files = {}
for root, dirs, files in os.walk(output_folder, followlinks=True):
for f in files:
url = os.path.join(root, f)
if url.endswith('.css'):
fname = os.path.basename(url)
if fname in css_files:
self.logger.error("You have two CSS files with the same name and that confuses me.")
sys.exit(1)
css_files[fname] = url
if not f.endswith('.html'):
continue
urls.append(url)
p.process(*urls)
for inline in p.links:
fname = os.path.basename(inline.href)
with open(css_files[fname], 'wb+') as outf:
outf.write(inline.after)
示例6: run
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def run():
p = Processor()
for url in urls:
p.process(url)
for each in p.links:
print each.after
示例7: test_respect_link_order
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_respect_link_order(self):
html = os.path.join(HERE, 'three-links.html')
url = 'file://' + html
p = Processor()
p.process(url)
hrefs = [x.href for x in p.links]
eq_(hrefs, ['two.css', 'three.css'])
示例8: test_complex_colons_in_selector_expression
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_complex_colons_in_selector_expression(self):
html = os.path.join(HERE, 'complex-selector.html')
url = 'file://' + html
p = Processor()
p.process(url)
after = p.inlines[0].after
ok_('a[href^="javascript:"] { color: pink; }' in after)
ok_('a[href^="javascript:"]:after { content: "x"; }' in after)
示例9: test_before_after
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_before_after(self):
html = os.path.join(HERE, 'before-after.html')
url = 'file://' + html
p = Processor()
p.process(url)
after = p.inlines[0].after
ok_('ul li:after { content: "x"; }' not in after)
ok_('ol li:before { content: "x"; }' in after)
示例10: run
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def run(url):
p = Processor()
t0 = time.time()
p.process(url)
t1 = time.time()
print("INLINES ".ljust(79, '-'))
total_size_before = 0
total_size_after = 0
# for each in p.inlines:
# print("On line %s" % each.line)
# print('- ' * 40)
# print("BEFORE")
# print(each.before)
# total_size_before += len(each.before)
# print('- ' * 40)
# print("AFTER:")
# print(each.after)
# total_size_after += len(each.after)
# print("\n")
#
# print("LINKS ".ljust(79, '-'))
# for each in p.links:
# print("On href %s" % each.href)
# print('- ' * 40)
# print("BEFORE")
# print(each.before)
# total_size_before += len(each.before)
# print('- ' * 40)
# print("AFTER:")
# print(each.after)
# print("\n")
#
# print("LINKS ".ljust(79, '-'))
# for each in p.links:
# print("On href %s" % each.href)
# print('- ' * 40)
# print("BEFORE")
# print(each.before)
# total_size_before += len(each.before)
# print('- ' * 40)
# print("AFTER:")
# print(each.after)
# total_size_after += len(each.after)
# print("\n")
print(
"TOOK:".ljust(20),
"%.5fs" % (t1 - t0)
)
print(
"TOTAL SIZE BEFORE:".ljust(20),
"%.1fKb" % (total_size_before / 1024.0)
)
print(
"TOTAL SIZE AFTER:".ljust(20),
"%.1fKb" % (total_size_after / 1024.0)
)
示例11: test_non_ascii_html
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_non_ascii_html(self):
html = os.path.join(HERE, "eight.html")
url = "file://" + html
p = Processor()
p.process(url)
after = p.inlines[0].after
ok_(isinstance(after, unicode))
ok_(u"Varf\xf6r st\xe5r det h\xe4r?" in after)
示例12: test_non_ascii_html
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_non_ascii_html(self):
html = os.path.join(HERE, 'eight.html')
url = 'file://' + html
p = Processor()
p.process(url)
after = p.inlines[0].after
self.assertTrue(isinstance(after, unicode))
self.assertTrue(u'Varf\xf6r st\xe5r det h\xe4r?' in after)
示例13: test_complicated_keyframes
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_complicated_keyframes(self):
html = os.path.join(HERE, "six.html")
url = "file://" + html
p = Processor()
p.process(url)
after = p.inlines[0].after
eq_(after.count("{"), after.count("}"))
ok_(".pull-left" in after)
ok_(".pull-right" in after)
ok_(".pull-middle" not in after)
示例14: gencss
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def gencss(htmldir, htmlfiles):
fullpaths = map(lambda x: join(htmldir, x), htmlfiles)
basenames = map(lambda x: x.split('.')[0], htmlfiles)
cssdir = '../www/css/'
p = Processor(optimize_lookup=True)
for f, b in zip(fullpaths, basenames):
p.process(f)
for css in p.links:
cssfile = join(cssdir, b) + ".css"
with open(cssfile, 'wb') as fh:
fh.write(css.after)
示例15: test_double_classes
# 需要导入模块: from mincss.processor import Processor [as 别名]
# 或者: from mincss.processor.Processor import process [as 别名]
def test_double_classes(self):
html = os.path.join(HERE, "five.html")
url = "file://" + html
p = Processor()
p.process(url)
after = p.links[0].after
eq_(after.count("{"), after.count("}"))
ok_("input.span6" in after)
ok_(".uneditable-input.span9" in after)
ok_(".uneditable-{" not in after)
ok_(".uneditable-input.span3" not in after)