當前位置: 首頁>>代碼示例>>Python>>正文


Python template.Template類代碼示例

本文整理匯總了Python中pyramid.scaffolds.template.Template的典型用法代碼示例。如果您正苦於以下問題:Python Template類的具體用法?Python Template怎麽用?Python Template使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Template類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的pyramid.scaffolds.template.Template類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。