當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。