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

Python template.Template类代码示例

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

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



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

示例1: pre

    def pre(self, command, output_dir, vars):
        """
        Overrides ``pyramid.scaffold.template.Template.pre``, adding
        several variables to the default variables list. Also prevents
        common misnamings (such as naming a package "site" or naming a
        package logger "root").
        """

        ret = Template.pre(self, command, output_dir, vars)

        self._set_package_in_vars(command, vars)

        if vars["package"] == "site":
            raise ValueError(
                "Sorry, you may not name your package 'site'. "
                "The package name 'site' has a special meaning in "
                "Python.  Please name it anything except 'site'.")

        package_logger = vars["package"]
        if package_logger == "root":
            # Rename the app logger in the rare case a project
            # is named "root"
            package_logger = "app"
        vars["package_logger"] = package_logger

        return ret
开发者ID:blattmann,项目名称:c2cgeoportal,代码行数:26,代码来源:__init__.py


示例2: pre

 def pre(self, command, output_dir, vars):
     vars["random_string"] = native_(binascii.hexlify(os.urandom(20)))
     package_logger = vars["package"]
     if package_logger == "root":
         # Rename the app logger in the rare case a project is named 'root'
         package_logger = "app"
     vars["package_logger"] = package_logger
     return Template.pre(self, command, output_dir, vars)
开发者ID:alertedsnake,项目名称:pyramid,代码行数:8,代码来源:__init__.py


示例3: pre

 def pre(self, command, output_dir, vars):
     vars['random_string'] = os.urandom(20).encode('hex')
     package_logger = vars['package']
     if package_logger == 'root':
         # Rename the app logger in the rare case a project is named 'root'
         package_logger = 'app'
     vars['package_logger'] = package_logger
     return Template.pre(self, command, output_dir, vars)
开发者ID:Rygbee,项目名称:pyramid_appengine,代码行数:8,代码来源:__init__.py


示例4: pre

 def pre(self, command, output_dir, vars):
     if vars['package'] == 'site':
         raise ValueError('Sorry, you may not name your package "site". '
                          'The package name "site" has a special meaning in '
                          'Python.  Please name it anything except "site".')
     vars['random_string'] = native_(binascii.hexlify(os.urandom(20)))
     package_logger = vars['package']
     if package_logger == 'root':
         # Rename the app logger in the rare case a project is named 'root'
         package_logger = 'app'
     vars['package_logger'] = package_logger
     return Template.pre(self, command, output_dir, vars)
开发者ID:cloudappsetup,项目名称:pyramid,代码行数:12,代码来源:__init__.py


示例5: pre

 def pre(self, command, output_dir, vars):
     """ Overrides :meth:`pyramid.scaffolds.template.Template.pre`, adding
     several variables to the default variables list (including
     ``random_string``, and ``package_logger``).  It also prevents common
     misnamings (such as naming a package "site" or naming a package
     logger "root".
     """
     vars['random_string'] = native_(binascii.hexlify(os.urandom(20)))
     package_logger = vars['package']
     if package_logger == 'root':
         # Rename the app logger in the rare case a project is named 'root'
         package_logger = 'app'
     vars['package_logger'] = package_logger
     return Template.pre(self, command, output_dir, vars)
开发者ID:7924102,项目名称:pyramid,代码行数:14,代码来源:__init__.py


示例6: pre

    def pre(self, command, output_dir, vars_):
        """
        Overrides ``pyramid.scaffold.template.Template.pre``, adding
        several variables to the default variables list. Also prevents
        common misnamings (such as naming a package "site" or naming a
        package logger "root").
        """

        self._get_vars(vars_, "package", "Get a package name: ")
        self._get_vars(
            vars_, "srid",
            "Spatial Reference System Identifier (e.g. 21781): ", int,
        )
        srid = vars_["srid"]
        extent = self._epsg2bbox(srid)
        self._get_vars(
            vars_, "extent",
            "Extent (minx miny maxx maxy): in EPSG: {srid} projection, default is "
            "[{bbox[0]} {bbox[1]} {bbox[2]} {bbox[3]}]: ".format(srid=srid, bbox=extent)
            if extent else
            "Extent (minx miny maxx maxy): in EPSG: {srid} projection: ".format(srid=srid)
        )
        match = re.match(r"([\d.]+)[,; ] *([\d.]+)[,; ] *([\d.]+)[,; ] *([\d.]+)", vars_["extent"])
        if match is not None:
            extent = [match.group(n + 1) for n in range(4)]
        vars_["extent"] = ",".join(extent)
        vars_["extent_mapserver"] = " ".join(extent)
        vars_["extent_viewer"] = json.dumps(extent)

        ret = Template.pre(self, command, output_dir, vars_)

        if vars_["package"] == "site":
            raise ValueError(
                "Sorry, you may not name your package 'site'. "
                "The package name 'site' has a special meaning in "
                "Python.  Please name it anything except 'site'.")

        package_logger = vars_["package"]
        if package_logger == "root":
            # Rename the app logger in the rare case a project
            # is named "root"
            package_logger = "app"
        vars_["package_logger"] = package_logger

        c2cgeoportal_version = pkg_resources.get_distribution('c2cgeoportal_commons') \
            .parsed_version._version.release
        vars_["geomapfish_version"] = "{}.{}".format(c2cgeoportal_version[0], c2cgeoportal_version[1])

        return ret
开发者ID:yjacolin,项目名称:c2cgeoportal,代码行数:49,代码来源:__init__.py


示例7: pre

    def pre(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
        several variables to the default variables list (including
        ``random_string``, and ``package_logger``).  It also prevents common
        misnamings (such as naming a package "site" or naming a package
        logger "root".
        """
        if vars['package'] == 'site':
            raise ValueError('Sorry, you may not name your package "site". '
                             'The package name "site" has a special meaning in '
                             'Python.  Please name it anything except "site".')
        package_logger = vars['package']
        if package_logger == 'root':
            # Rename the app logger in the rare case a project is named 'root'
            package_logger = 'app'
        vars['package_logger'] = package_logger

        vars['package_dirname'] = os.path.dirname(vars['package_full_name'])

        vars['test_package_full_name'] = re.sub(r'\/', '/test_', vars['package_full_name'])
        if vars['test_package_full_name'][0:3] != 'test' and vars['test_package_full_name'][0:4] != '/test':
            vars['test_package_full_name'] = re.sub(r'^', 'test_', vars['test_package_full_name'])

        vars['test_package_dirname'] = re.sub(r'\/', '/test_', vars['package_dirname'])
        if vars['test_package_dirname'][0:3] != 'test' and vars['test_package_dirname'][0:4] != '/test':
            vars['test_package_dirname'] = re.sub(r'^', 'test_', vars['test_package_dirname'])
        if vars['package_dirname'] == '' or vars['package_dirname'] == '.':
            vars['test_package_dirname'] = '.'
            
        vars['package_full_name_dot'] = re.sub(r'\/', '.', vars['package_full_name'])
        vars['package_dirname_dot'] = re.sub(r'\/', '.', vars['package_dirname'])
        vars['package_dirname_dot_with_app'] = 'app.' + vars['package_dirname_dot']
        if vars['package_dirname'] == '' or vars['package_dirname'] == '.':
            vars['package_dirname_dot_with_app'] = 'app'

        logging.warning('command: ' + repr(command))
        logging.warning('output_dir: ' + repr(output_dir))
        logging.warning('vars: ' + repr(vars))
        vars['project_camelcase'] = underscore_to_camelcase(vars['project'])
        vars['project_camelcase_uppercase'] = underscore_to_camelcase_uppercase(vars['project'])

        the_tmp = re.sub(ur'\.', '_', vars['project'])
        vars['project_underscore'] = re.sub(ur'-', '_', the_tmp)

        return Template.pre(self, command, output_dir, vars)
开发者ID:ChuyuHsu,项目名称:LittleBeeGeo,代码行数:45,代码来源:__init__.py


示例8: pre

 def pre(self, command, output_dir, vars):
     """ Overrides :meth:`pyramid.scaffold.template.Template.pre`, adding
     several variables to the default variables list (including
     ``random_string``, and ``package_logger``).  It also prevents common
     misnamings (such as naming a package "site" or naming a package
     logger "root".
     """
     if vars['package'] == 'site':
         raise ValueError('Sorry, you may not name your package "site". '
                          'The package name "site" has a special meaning in '
                          'Python.  Please name it anything except "site".')
     vars['random_string'] = native_(binascii.hexlify(os.urandom(20)))
     package_logger = vars['package']
     if package_logger == 'root':
         # Rename the app logger in the rare case a project is named 'root'
         package_logger = 'app'
     vars['package_logger'] = package_logger
     return Template.pre(self, command, output_dir, vars)
开发者ID:aadabi,项目名称:pyramid,代码行数:18,代码来源:__init__.py


示例9: post

    def post(self, command, output_dir, vars): # pragma: no cover
        """ Overrides :meth:`pyramid.scaffolds.template.Template.post`, to
        print "Welcome to Pyramid.  Sorry for the convenience." after a
        successful scaffolding rendering."""

        if os.path.exists(os.path.join(self.template_dir(), ".gitignore")):
            # .gitignore needs special handling because leading dot
            shutil.copy(os.path.join(self.template_dir(), ".gitignore"), output_dir)

        separator = "=" * 79
        msg = dedent(
            """
            %(separator)s
            Welcome to Websauna. See README.rst for further information.
            %(separator)s
        """ % {'separator': separator})

        self.out(msg)
        return Template.post(self, command, output_dir, vars)
开发者ID:rmoorman,项目名称:websauna,代码行数:19,代码来源:__init__.py


示例10: post

    def post(self, command, output_dir, vars):
        """ Overrides :meth:`pyramid.scaffold.template.Template.post`, to
        print "Welcome to PyCK.  Sorry for the convenience." after a
        successful scaffolding rendering."""

        # Unzip the projectname/scripts/newapp_scaffold.zip
        self.out('\n  Extracting the new app creation templates\n')
        pkg_name = vars['package']

        extract_path = "%s/%s/scripts" % (pkg_name, pkg_name)
        zipfilepath = "%s/newapp_scaffold.zip" % extract_path

        z = zipfile.ZipFile(zipfilepath)
        z.extractall(extract_path)

        os.unlink(zipfilepath)

        self.out('Welcome to PyCK.  Sorry for the convenience :-)')
        return Template.post(self, command, output_dir, vars)
开发者ID:kashifpk,项目名称:PyCK,代码行数:19,代码来源:__init__.py


示例11: post

    def post(self, command, output_dir, vars): # pragma: no cover
        """ Overrides :meth:`pyramid.scaffolds.template.Template.post`, to
        print "Welcome to Pyramid.  Sorry for the convenience." after a
        successful scaffolding rendering."""

        separator = "=" * 79
        msg = dedent(
            """
            %(separator)s
            Tutorials:     http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/
            Documentation: http://docs.pylonsproject.org/projects/pyramid/en/latest/
            Twitter:       https://twitter.com/trypyramid
            Mailing List:  https://groups.google.com/forum/#!forum/pylons-discuss

            Welcome to Pyramid.  Sorry for the convenience.
            %(separator)s
        """ % {'separator': separator})

        self.out(msg)
        return Template.post(self, command, output_dir, vars)
开发者ID:vardhan26,项目名称:pyramid,代码行数:20,代码来源:__init__.py


示例12: pre

    def pre(self, command, output_dir, vars):
        """ Overrides `pre` method to verify if package name is not equals of
        anything package.
        """
        package_name = os.path.abspath('.').split('/')[-1]
        blacklist_names = ('site', package_name)

        if vars['package'] in blacklist_names:
            msg = """
            Sorry, you may not name your "{0}". This name "{0}" has been
            defined. Please name it anything except "{0}".
            """.format(vars['package'])
            raise ValueError(msg)

        vars['random_string'] = native_(binascii.hexlify(os.urandom(20)))
        vars['root_project'] = package_name
        package_logger = vars['package']
        if package_logger == 'root':
            # Rename the app logger in the rare case a project is named 'root'
            package_logger = 'app'
        vars['package_logger'] = package_logger
        return Template.pre(self, command, output_dir, vars)
开发者ID:marioidival,项目名称:iampharaoh,代码行数:22,代码来源:__init__.py


示例13: post

    def post(self, command, output_dir, vars): # pragma: no cover
        """ Overrides :meth:`pyramid.scaffolds.template.Template.post`, to
        print "Welcome to Pyramid.  Sorry for the convenience." after a
        successful scaffolding rendering."""

        separator = "X" * 79
        msg = dedent("""
        %(separator)s
        Tutorials: http://docs.pylonsproject.org/projects/pyramid_tutorials
        Documentation: http://docs.pylonsproject.org/projects/pyramid
        Twitter (tips & updates): http://twitter.com/pylons
        Mailing List: http://groups.google.com/group/pylons-discuss

        Creator of this scaffold: Mario Idival
        Twitter/Github: @marioidival

        Welcome to Pyramid.  Sorry for the convenience.
        %(separator)s
        """ % {'separator': separator})

        self.out(msg)
        return Template.post(self, command, output_dir, vars)
开发者ID:marioidival,项目名称:iampharaoh,代码行数:22,代码来源:__init__.py


示例14: post

 def post(self, command, output_dir, vars): # pragma: no cover
     """ Overrides :meth:`pyramid.scaffold.template.Template.post`, to
     print "Welcome to Pyramid.  Sorry for the convenience." after a
     successful scaffolding rendering."""
     self.out('Welcome to Pyramid.  Sorry for the convenience.')
     return Template.post(self, command, output_dir, vars)
开发者ID:ChuyuHsu,项目名称:LittleBeeGeo,代码行数:6,代码来源:__init__.py


示例15: post

 def post(self, command, output_dir, vars):
     self.out('Welcome to pyramid_appengine.  Go HACK!!!')
     return Template.post(self, command, output_dir, vars)
开发者ID:Rygbee,项目名称:pyramid_appengine,代码行数:3,代码来源:__init__.py


示例16: post

 def post(self, command, output_dir, vars): # pragma: no cover
     self.out('Welcome to Pyramid.  Sorry for the convenience.')
     return Template.post(self, command, output_dir, vars)
开发者ID:jpcw,项目名称:pyramid,代码行数:3,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.parse_vars函数代码示例发布时间:2022-05-27
下一篇:
Python response.Response类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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