• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.get_path_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_css

    def get_css(self):
        """ Fetches and returns stylesheet file path or contents, for both
            print and screen contexts, depending if we want a standalone
            presentation or not.
        """
        css = {}

        print_css = os.path.join(self.theme_dir, 'css', 'print.css')
        if not os.path.exists(print_css):
            # Fall back to default theme
            print_css = os.path.join(THEMES_DIR, 'default', 'css', 'print.css')

            if not os.path.exists(print_css):
                raise IOError(u"Cannot find css/print.css in default theme")

        css['print'] = {
            'path_url': utils.get_path_url(print_css, self.relative),
            'contents': self.css_contents(print_css),
        }

        screen_css = os.path.join(self.theme_dir, 'css', 'screen.css')
        if (os.path.exists(screen_css)):
            css['screen'] = {
                'path_url': utils.get_path_url(screen_css, self.relative),
                'contents': self.css_contents(screen_css),
            }
        else:
            self.log(u"No screen stylesheet provided in current theme",
                      'warning')

        return css
开发者ID:iyotake,项目名称:landslide,代码行数:31,代码来源:generator.py


示例2: get_css

    def get_css(self):
        """ Fetches and returns stylesheet file path or contents, for both
            print and screen contexts, depending if we want a standalone
            presentation or not.
        """
        css = {}

        print_css = os.path.join(self.theme_dir, "css", "print.css")
        if not os.path.exists(print_css):
            # Fall back to default theme
            print_css = os.path.join(THEMES_DIR, "default", "css", "print.css")

            if not os.path.exists(print_css):
                raise IOError(u"Cannot find css/print.css in default theme")

        css["print"] = {"path_url": utils.get_path_url(print_css, self.relative), "contents": open(print_css).read()}

        screen_css = os.path.join(self.theme_dir, "css", "screen.css")
        if os.path.exists(screen_css):
            css["screen"] = {
                "path_url": utils.get_path_url(screen_css, self.relative),
                "contents": open(screen_css).read(),
            }
        else:
            self.log(u"No screen stylesheet provided in current theme", "warning")

        return css
开发者ID:ninickck,项目名称:landslide,代码行数:27,代码来源:generator.py


示例3: get_js

    def get_js(self):
        """ Fetches and returns javascript file path or contents, depending if
            we want a standalone presentation or not.
        """
        js_file = os.path.join(self.theme_dir, "js", "slides.js")

        if not os.path.exists(js_file):
            js_file = os.path.join(THEMES_DIR, "default", "js", "slides.js")

            if not os.path.exists(js_file):
                raise IOError(u"Cannot find slides.js in default theme")

        return {"path_url": utils.get_path_url(js_file, self.relative), "contents": open(js_file).read()}
开发者ID:ninickck,项目名称:landslide,代码行数:13,代码来源:generator.py


示例4: get_css

    def get_css(self):
        """ Fetches and returns stylesheet file path or contents, for both
            print and screen contexts, depending if we want a standalone
            presentation or not.
        """
        css = {}

        print_css = os.path.join(self.theme_dir, 'css', 'print.css')
        if not os.path.exists(print_css):
            # Fall back to default theme
            print_css = os.path.join(THEMES_DIR, 'default', 'css', 'print.css')

            if not os.path.exists(print_css):
                raise IOError(u"Cannot find css/print.css in default theme")

        css['print'] = {
            'path_url': utils.get_path_url(print_css, self.relative),
            'contents': open(print_css).read(),
        }

        screen_css = os.path.join(self.theme_dir, 'css', 'screen.css')
        if (os.path.exists(screen_css)):
            css['screen'] = {
                'path_url': utils.get_path_url(screen_css, self.relative),
                'contents': open(screen_css).read(),
            }
        else:
            self.log(u"No screen stylesheet provided in current theme",
                      'warning')

        if self.notes and self.file_type == 'pdf':
            css['print']['contents'] += ".presenter_notes { display: block; }"

        if self.embed:
            contents = css['screen']['contents']
            css['screen']['contents'] = self.embed_imported_files(contents)

        return css
开发者ID:agonzalezro,项目名称:landslide,代码行数:38,代码来源:generator.py


示例5: process

    def process(self, content, source=None):
        classes = []

        if self.embed:
            return content, classes
        base_path = utils.get_path_url(source, self.options.get('relative'))
        base_url = os.path.split(base_path)[0]
        fn = lambda p: r'<img src="%s" />' % os.path.join(base_url, p.group(1))

        sub_regex = r'<img.*?src="(?!http://)(.*?)".*/?>'

        content = re.sub(sub_regex, fn, content, re.UNICODE)

        return content, classes
开发者ID:Lothiraldan,项目名称:landslide,代码行数:14,代码来源:macro.py


示例6: add_user_js

 def add_user_js(self, js_list):
     """ Adds supplementary user javascript files to the presentation. The
         ``js_list`` arg can be either a ``list`` or a ``basestring``
         instance.
     """
     if isinstance(js_list, basestring):
         js_list = [js_list]
     for js_path in js_list:
         if js_path and not js_path in self.user_js:
             if not os.path.exists(js_path):
                 raise IOError("%s user js file not found" % (js_path,))
             self.user_js.append(
                 {"path_url": utils.get_path_url(js_path, self.relative), "contents": open(js_path).read()}
             )
开发者ID:ninickck,项目名称:landslide,代码行数:14,代码来源:generator.py


示例7: add_user_css

 def add_user_css(self, css_list):
     """ Adds supplementary user css files to the presentation. The
         ``css_list`` arg can be either a ``list`` or a ``basestring``
         instance.
     """
     if isinstance(css_list, basestring):
         css_list = [css_list]
     for css_path in css_list:
         if css_path and not css_path in self.user_css:
             if not os.path.exists(css_path):
                 raise IOError("%s user css file not found" % (css_path,))
             self.user_css.append(
                 {"path_url": utils.get_path_url(css_path, self.relative), "contents": open(css_path).read()}
             )
开发者ID:ninickck,项目名称:landslide,代码行数:14,代码来源:generator.py


示例8: get_js

    def get_js(self):
        """ Fetches and returns javascript file path or contents, depending if
            we want a standalone presentation or not.
        """
        js_file = os.path.join(self.theme_dir, 'js', 'slides.js')

        if not os.path.exists(js_file):
            js_file = os.path.join(THEMES_DIR, 'default', 'js', 'slides.js')

            if not os.path.exists(js_file):
                raise IOError(u"Cannot find slides.js in default theme")

        return {
            'path_url': utils.get_path_url(js_file, self.relative),
            'contents': codecs.open(js_file, encoding=self.encoding).read(),
        }
开发者ID:iyotake,项目名称:landslide,代码行数:16,代码来源:generator.py


示例9: process

    def process(self, content, source=None):
        classes = []

        if self.embed:
            return content, classes
        base_path = utils.get_path_url(source, self.options.get('relative'))
        base_url = os.path.split(base_path)[0]

        images = re.findall(r'<img.*?src="(?!http://)(.*?)".*/?>', content,
            re.DOTALL | re.UNICODE)

        for image in images:
            full_path = os.path.join(base_url, image)

            content = content.replace(image, full_path)

        return content, classes
开发者ID:ShiZhan,项目名称:landslide,代码行数:17,代码来源:macro.py


示例10: add_user_js

 def add_user_js(self, js_list):
     """ Adds supplementary user javascript files to the presentation. The
         ``js_list`` arg can be either a ``list`` or a ``basestring``
         instance.
     """
     if isinstance(js_list, basestring):
         js_list = [js_list]
     for js_path in js_list:
         if js_path and not js_path in self.user_js:
             if js_path.startswith("http:"):
                 self.user_js.append({
                     'path_url': js_path,
                     'contents': '',
                 })
             elif not os.path.exists(js_path):
                 raise IOError('%s user js file not found' % (js_path,))
             else:
                 self.user_js.append({
                     'path_url': utils.get_path_url(js_path, self.relative),
                     'contents': open(js_path).read(),
                 })
开发者ID:fozziethebeat,项目名称:landslide,代码行数:21,代码来源:generator.py


示例11: get_js

    def get_js(self):
        """ Fetches and returns javascript file path or contents, depending if
            we want a standalone presentation or not.
        """
        js_dir = os.path.join(self.theme_dir, 'js')

        if not os.path.exists(js_dir):
            js_dir = os.path.join(THEMES_DIR, 'default', 'js')

            if not os.path.exists(js_dir):
                raise IOError(u"Cannot find js folder in default theme")

        js_files = []

        for path in os.listdir(js_dir):
            filename, ext = os.path.splitext(path)
            if ext == ".js":
                js_file = os.path.join(js_dir, path)
                js_files.append({
                        'path_url': utils.get_path_url(js_file, self.relative),
                        'contents': open(js_file).read(),
                        })

        return js_files
开发者ID:kyleconroy,项目名称:landslide,代码行数:24,代码来源:generator.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_power_types函数代码示例发布时间:2022-05-26
下一篇:
Python utils.get_path函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap