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


Python Tempita.sub方法代码示例

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


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

示例1: build_extensions

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
    def build_extensions(self):

        for _pxifile in _pxifiles:
            # build pxifiles first, template extention must be .pxi.in
            assert _pxifile.endswith(".pxi.in")
            pxifile = pjoin(_pxipath, _pxifile)
            outfile = pxifile[:-3]

            if os.path.exists(outfile) and os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime:
                # if .pxi.in is not updated, no need to output .pxi
                continue

            with open(pxifile, "r") as f:
                tmpl = f.read()
            pyxcontent = tempita.sub(tmpl)

            with open(outfile, "w") as f:
                f.write(pyxcontent)

        numpy_incl = pkg_resources.resource_filename("numpy", "core/include")

        for ext in self.extensions:
            if hasattr(ext, "include_dirs") and not numpy_incl in ext.include_dirs:
                ext.include_dirs.append(numpy_incl)
        _build_ext.build_extensions(self)
开发者ID:ChristopherShort,项目名称:pandas,代码行数:27,代码来源:setup.py

示例2: build_extensions

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
    def build_extensions(self):

        # if builing from c files, don't need to
        # generate template output
        if cython:
            for pxifile in _pxifiles:
                # build pxifiles first, template extension must be .pxi.in
                assert pxifile.endswith('.pxi.in')
                outfile = pxifile[:-3]

                if (os.path.exists(outfile) and
                        os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime):
                    # if .pxi.in is not updated, no need to output .pxi
                    continue

                with open(pxifile, "r") as f:
                    tmpl = f.read()
                pyxcontent = tempita.sub(tmpl)

                with open(outfile, "w") as f:
                    f.write(pyxcontent)

        numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')

        for ext in self.extensions:
            if (hasattr(ext, 'include_dirs') and
                    numpy_incl not in ext.include_dirs):
                ext.include_dirs.append(numpy_incl)
        _build_ext.build_extensions(self)
开发者ID:BobMcFry,项目名称:pandas,代码行数:31,代码来源:setup.py

示例3: process_tempita_pyx

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pyx(fromfile, tofile):
    try:
        try:
            from Cython import Tempita as tempita
        except ImportError:
            import tempita
    except ImportError:
        raise Exception("Building Statsmodels requires Tempita: " "pip install --user Tempita")
    with open(fromfile, "r") as f:
        tmpl = f.read()
    pyxcontent = tempita.sub(tmpl)
    assert fromfile.endswith(".pyx.in")
    pyxfile = fromfile[: -len(".pyx.in")] + ".pyx"
    with open(pyxfile, "w") as f:
        f.write(pyxcontent)
    process_pyx(pyxfile, tofile)
开发者ID:Clever-Boy,项目名称:statsmodels,代码行数:18,代码来源:cythonize.py

示例4: process_tempita_pxi

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pxi(fromfile, tofile):
    try:
        try:
            from Cython import Tempita as tempita
        except ImportError:
            import tempita
    except ImportError:
        raise Exception('Building %s requires Tempita: '
                        'pip install --user Tempita' % VENDOR)
    assert fromfile.endswith('.pxi.in')
    assert tofile.endswith('.pxi')
    with open(fromfile, "r") as f:
        tmpl = f.read()
    pyxcontent = tempita.sub(tmpl)
    with open(tofile, "w") as f:
        f.write(pyxcontent)
开发者ID:stuartarchibald,项目名称:numpy,代码行数:18,代码来源:cythonize.py

示例5: render_templates

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
    def render_templates(cls, pxifiles):
        for pxifile in pxifiles:
            # build pxifiles first, template extension must be .pxi.in
            assert pxifile.endswith('.pxi.in')
            outfile = pxifile[:-3]

            if (os.path.exists(outfile) and
                    os.stat(pxifile).st_mtime < os.stat(outfile).st_mtime):
                # if .pxi.in is not updated, no need to output .pxi
                continue

            with open(pxifile, "r") as f:
                tmpl = f.read()
            pyxcontent = tempita.sub(tmpl)

            with open(outfile, "w") as f:
                f.write(pyxcontent)
开发者ID:dalejung,项目名称:pandas,代码行数:19,代码来源:setup.py

示例6: process_tempita

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita(source_name):
    """Runs pyx.in files through tempita is needed"""
    if source_name.endswith('pyx.in'):
        with open(source_name, 'r') as templated:
            pyx_template = templated.read()
        pyx = Tempita.sub(pyx_template)
        pyx_filename = source_name[:-3]
        with open(pyx_filename, 'w') as pyx_file:
            pyx_file.write(pyx)
        file_stats = os.stat(source_name)
        try:
            os.utime(pyx_filename, ns=(file_stats.st_atime_ns,
                                       file_stats.st_mtime_ns))
        except AttributeError:
            os.utime(pyx_filename, (file_stats.st_atime, file_stats.st_mtime))
        source_name = pyx_filename
    return source_name
开发者ID:bashtage,项目名称:statsmodels,代码行数:19,代码来源:setup.py

示例7: process_tempita_pyx

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def process_tempita_pyx(fromfile, tofile):
    try:
        try:
            from Cython import Tempita as tempita
        except ImportError:
            import tempita
    except ImportError:
        raise Exception('Building DismalPy requires Tempita: '
                        'pip install --user Tempita')
    with open(fromfile, "r") as f:
        tmpl = f.read()
    pyxcontent = tempita.sub(tmpl)
    assert fromfile.endswith('.pyx.in')
    pyxfile = fromfile[:-len('.pyx.in')] + '.pyx'
    with open(pyxfile, "w") as f:
        f.write(pyxcontent)
    process_pyx(pyxfile, tofile)
开发者ID:dismalpy,项目名称:dismalpy,代码行数:19,代码来源:cythonize.py

示例8: configuration

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration

    config = Configuration('linear_model', parent_package, top_path)

    libraries = []
    if os.name == 'posix':
        libraries.append('m')

    config.add_extension('cd_fast',
                         sources=['cd_fast.pyx'],
                         include_dirs=numpy.get_include(),
                         libraries=libraries)

    config.add_extension('sgd_fast',
                         sources=['sgd_fast.pyx'],
                         include_dirs=numpy.get_include(),
                         libraries=libraries)

    # generate sag_fast from template
    sag_cython_file = 'sklearn/linear_model/sag_fast.pyx.tp'
    sag_file = sag_cython_file.replace('.tp', '')

    if not (os.path.exists(sag_file) and
            os.stat(sag_cython_file).st_mtime < os.stat(sag_file).st_mtime):

        with open(sag_cython_file, "r") as f:
            tmpl = f.read()
        tmpl_ = Tempita.sub(tmpl)

        with open(sag_file, "w") as f:
            f.write(tmpl_)

    config.add_extension('sag_fast',
                         sources=['sag_fast.pyx'],
                         include_dirs=numpy.get_include())

    # add other directories
    config.add_subpackage('tests')

    return config
开发者ID:allefpablo,项目名称:scikit-learn,代码行数:43,代码来源:setup.py

示例9: open

# 需要导入模块: from Cython import Tempita [as 别名]
# 或者: from Cython.Tempita import sub [as 别名]
    try:
        from Cython import Tempita as tempita
    except ImportError:
        import tempita
except ImportError:
    notempita_msg = ("# tempita needed to finish setup.  run:\n\n" +
    "    $ pip install tempita  # or easy_install tempita\n")
    sys.exit(notempita_msg)

# DOC: Tempita create pyx files
code_cdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "affine")
for folder, subdirs, files in os.walk(code_cdir):
    for fil in files:
        if fil.endswith(".pyx.in"):
            with open(os.path.join(folder, fil), "r") as f:
                cython_file = tempita.sub(f.read())
            with open(os.path.join(folder, os.path.splitext(fil)[0]), "w") as f:
                f.write(cython_file)

extensions = [Extension('affine.model.Cython_extensions',
                       ['affine/extensions/Cython_extensions.pyx'])]

setup(
    name='affine',
    author='Barton Baker',
    version='0.3',
    packages=find_packages(),
    description='This package offers a solver class for affine ' \
                  + 'term structure models.',
    author_email="[email protected]",
    use_2to3=True,
开发者ID:bartbkr,项目名称:affine,代码行数:33,代码来源:setup.py


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