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


Python Template.pre方法代码示例

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


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

示例1: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
    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,代码行数:28,代码来源:__init__.py

示例2: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
 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:jpcw,项目名称:pyramid,代码行数:10,代码来源:__init__.py

示例3: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
 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,代码行数:10,代码来源:__init__.py

示例4: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
 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,代码行数:14,代码来源:__init__.py

示例5: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
 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,代码行数:16,代码来源:__init__.py

示例6: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
    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,代码行数:51,代码来源:__init__.py

示例7: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
    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,代码行数:47,代码来源:__init__.py

示例8: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
 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,代码行数:20,代码来源:__init__.py

示例9: pre

# 需要导入模块: from pyramid.scaffolds.template import Template [as 别名]
# 或者: from pyramid.scaffolds.template.Template import pre [as 别名]
    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,代码行数:24,代码来源:__init__.py


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