当前位置: 首页>>代码示例>>Python>>正文


Python processor.Processor类代码示例

本文整理汇总了Python中mincss.processor.Processor的典型用法代码示例。如果您正苦于以下问题:Python Processor类的具体用法?Python Processor怎么用?Python Processor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Processor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_pseudo_selectors_hell

    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)
开发者ID:supersha,项目名称:mincss,代码行数:33,代码来源:test_mincss.py

示例2: test_respect_link_order

 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"])
开发者ID:alamehor,项目名称:mincss,代码行数:7,代码来源:test_mincss.py

示例3: test_no_mincss_link

 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)
开发者ID:bee-k,项目名称:mincss,代码行数:7,代码来源:test_mincss.py

示例4: _execute

    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)
开发者ID:Nicogue,项目名称:nikola,代码行数:29,代码来源:command_mincss.py

示例5: test_pseudo_selectors_hell

    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)
开发者ID:myint,项目名称:mincss,代码行数:32,代码来源:test_mincss.py

示例6: _execute

    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)
开发者ID:ChillarAnand,项目名称:plugins,代码行数:27,代码来源:mincss.py

示例7: run

def run():
	p = Processor()
	for url in urls:
		p.process(url)

	for each in p.links:
		print each.after
开发者ID:darkwebdev,项目名称:tinyGB,代码行数:7,代码来源:clean_css.py

示例8: test_before_after

 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)
开发者ID:bee-k,项目名称:mincss,代码行数:8,代码来源:test_mincss.py

示例9: test_complex_colons_in_selector_expression

 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)
开发者ID:bee-k,项目名称:mincss,代码行数:8,代码来源:test_mincss.py

示例10: run

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)
    )
开发者ID:MA3STR0,项目名称:mincss,代码行数:58,代码来源:run_mincss.py

示例11: test_non_ascii_html

    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)
开发者ID:supersha,项目名称:mincss,代码行数:9,代码来源:test_mincss.py

示例12: test_non_ascii_html

    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)
开发者ID:myint,项目名称:mincss,代码行数:9,代码来源:test_mincss.py

示例13: gencss

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)
开发者ID:setr,项目名称:pollen-site,代码行数:11,代码来源:tag_and_inlink.py

示例14: test_complicated_keyframes

    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)
开发者ID:bee-k,项目名称:mincss,代码行数:11,代码来源:test_mincss.py

示例15: test_make_absolute_url

 def test_make_absolute_url(self):
     p = Processor()
     eq_(p.make_absolute_url("http://www.com/", "./style.css"), "http://www.com/style.css")
     eq_(p.make_absolute_url("http://www.com", "./style.css"), "http://www.com/style.css")
     eq_(p.make_absolute_url("http://www.com", "//cdn.com/style.css"), "http://cdn.com/style.css")
     eq_(p.make_absolute_url("http://www.com/", "//cdn.com/style.css"), "http://cdn.com/style.css")
     eq_(p.make_absolute_url("http://www.com/", "/style.css"), "http://www.com/style.css")
     eq_(p.make_absolute_url("http://www.com/elsewhere", "/style.css"), "http://www.com/style.css")
     eq_(p.make_absolute_url("http://www.com/elsewhere/", "/style.css"), "http://www.com/style.css")
     eq_(p.make_absolute_url("http://www.com/elsewhere/", "./style.css"), "http://www.com/elsewhere/style.css")
     eq_(p.make_absolute_url("http://www.com/elsewhere", "./style.css"), "http://www.com/style.css")
开发者ID:alamehor,项目名称:mincss,代码行数:11,代码来源:test_mincss.py


注:本文中的mincss.processor.Processor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。