python类FileSystemLoader()的实例源码

templating.py 文件源码 项目:charm-swift-proxy 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
application.py 文件源码 项目:aiowing 作者: embali 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def create_app(loop=None):
    app = web.Application(
        middlewares=[
            session_middleware(EncryptedCookieStorage(settings.COOKIE_SECRET)),
            error_middleware],
        loop=loop if loop is not None else settings.loop)
    aiohttp_jinja2.setup(
        app,
        loader=jinja2.FileSystemLoader(settings.TEMPLATES_PATH))

    for route in routes.routes:
        app.router.add_route(*route[0], **route[1])
    if settings.DEBUG:
        app.router.add_static(settings.STATIC_URL, settings.STATIC_PATH)

    return app
templating.py 文件源码 项目:charm-plumgrid-gateway 作者: openstack 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, templates_dir, openstack_release):
        if not os.path.isdir(templates_dir):
            log('Could not locate templates dir %s' % templates_dir,
                level=ERROR)
            raise OSConfigException

        self.templates_dir = templates_dir
        self.openstack_release = openstack_release
        self.templates = {}
        self._tmpl_env = None

        if None in [Environment, ChoiceLoader, FileSystemLoader]:
            # if this code is running, the object is created pre-install hook.
            # jinja2 shouldn't get touched until the module is reloaded on next
            # hook execution, with proper jinja2 bits successfully imported.
            apt_install('python-jinja2')
deploy.py 文件源码 项目:picoCTF 作者: picoCTF 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def template_file(in_file_path, out_file_path, **kwargs):
    """
    Templates the given file with the keyword arguments.

    Args:
        in_file_path: The path to the template
        out_file_path: The path to output the templated file
        **kwargs: Variables to use in templating
    """

    env = Environment(loader=FileSystemLoader(os.path.dirname(in_file_path)), keep_trailing_newline=True)
    template = env.get_template(os.path.basename(in_file_path))
    output = template.render(**kwargs)

    with open(out_file_path, "w") as f:
        f.write(output)
__init__.py 文件源码 项目:mblog 作者: moling3650 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def init_jinja2(app, **kw):
    logging.info('init jinja2...')
    options = {
        'autoescape': kw.get('autoescape', True),
        'block_start_string': kw.get('block_start_string', '{%'),
        'block_end_string': kw.get('block_end_string', '%}'),
        'variable_start_string': kw.get('variable_start_string', '{{'),
        'variable_end_string': kw.get('variable_end_string', '}}'),
        'auto_reload': kw.get('auto_reload', True)
    }
    path = kw.get('path', os.path.join(__path__[0], 'templates'))
    logging.info('set jinja2 template path: %s' % path)
    env = Environment(loader=FileSystemLoader(path), **options)
    filters = kw.get('filters')
    if filters is not None:
        for name, ftr in filters.items():
            env.filters[name] = ftr
    app['__templating__'] = env
burrowbeat.py 文件源码 项目:burrowbeat 作者: Goomzee 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def setUp(self):
        self.template_env = jinja2.Environment(
            loader=jinja2.FileSystemLoader("config")
        )

        # create working dir
        self.working_dir = os.path.join(build_path + "run", self.id())
        if os.path.exists(self.working_dir):
            shutil.rmtree(self.working_dir)
        os.makedirs(self.working_dir)

        try:
            # update the last_run link
            if os.path.islink(build_path + "last_run"):
                os.unlink(build_path + "last_run")
            os.symlink(build_path + "run/{}".format(self.id()),
                       build_path + "last_run")
        except:
            # symlink is best effort and can fail when 
            # running tests in parallel
            pass
css.py 文件源码 项目:v2ex-tornado-2 作者: coderyy 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get(self,theme):
        template_values = {}
        themes = os.listdir(os.path.join(os.path.dirname(__file__),'tpl', 'themes'))
        if theme in themes:
            path = os.path.join(theme, 'style.css')
        else:
            path = os.path.join('default', 'style.css')
        env = Environment(loader=FileSystemLoader(os.path.join(os.path.dirname(__file__),"tpl/themes")))
        template = env.get_template(path)
        output = template.render(template_values)
        expires_date = datetime.datetime.now(pytz.timezone('Asia/Shanghai')) + datetime.timedelta(days=7)
        expires_str = expires_date.strftime("%d %b %Y %H:%M:%S GMT")
        self.add_header("Expires", expires_str)
        self.set_header('Cache-Control', 'max-age=120, must-revalidate')
        self.set_header('Content-type','text/css;charset=UTF-8')
        self.write(output)
templating.py 文件源码 项目:charm-heat 作者: openstack 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
templating.py 文件源码 项目:charm-heat 作者: openstack 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, templates_dir, openstack_release):
        if not os.path.isdir(templates_dir):
            log('Could not locate templates dir %s' % templates_dir,
                level=ERROR)
            raise OSConfigException

        self.templates_dir = templates_dir
        self.openstack_release = openstack_release
        self.templates = {}
        self._tmpl_env = None

        if None in [Environment, ChoiceLoader, FileSystemLoader]:
            # if this code is running, the object is created pre-install hook.
            # jinja2 shouldn't get touched until the module is reloaded on next
            # hook execution, with proper jinja2 bits successfully imported.
            if six.PY2:
                apt_install('python-jinja2')
            else:
                apt_install('python3-jinja2')
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def __init__(self, templates_dir, openstack_release):
        if not os.path.isdir(templates_dir):
            log('Could not locate templates dir %s' % templates_dir,
                level=ERROR)
            raise OSConfigException

        self.templates_dir = templates_dir
        self.openstack_release = openstack_release
        self.templates = {}
        self._tmpl_env = None

        if None in [Environment, ChoiceLoader, FileSystemLoader]:
            # if this code is running, the object is created pre-install hook.
            # jinja2 shouldn't get touched until the module is reloaded on next
            # hook execution, with proper jinja2 bits successfully imported.
            if six.PY2:
                apt_install('python-jinja2')
            else:
                apt_install('python3-jinja2')
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, templates_dir, openstack_release):
        if not os.path.isdir(templates_dir):
            log('Could not locate templates dir %s' % templates_dir,
                level=ERROR)
            raise OSConfigException

        self.templates_dir = templates_dir
        self.openstack_release = openstack_release
        self.templates = {}
        self._tmpl_env = None

        if None in [Environment, ChoiceLoader, FileSystemLoader]:
            # if this code is running, the object is created pre-install hook.
            # jinja2 shouldn't get touched until the module is reloaded on next
            # hook execution, with proper jinja2 bits successfully imported.
            if six.PY2:
                apt_install('python-jinja2')
            else:
                apt_install('python3-jinja2')
templating.py 文件源码 项目:charm-keystone 作者: openstack 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
dactyl_build.py 文件源码 项目:dactyl 作者: ripple 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def setup_pp_env(page=None, page_filters=[], no_loader=False):
    remote, path = get_page_where(page)
    if remote:
        logger.debug("Using remote template loader for page %s" % page)
        pp_env = jinja2.Environment(loader=jinja2.FunctionLoader(read_markdown_remote))
    elif no_loader:
        logger.debug("Using a no-loader Jinja environment")
        pp_env = jinja2.Environment()
    else:
        logger.debug("Using FileSystemLoader for page %s" % page)
        pp_env = jinja2.Environment(loader=jinja2.FileSystemLoader(path))

    # Pull exported values (& functions) from page filters into the pp_env
    for filter_name in page_filters:
        if filter_name not in config.filters.keys():
            logger.debug("Skipping unloaded filter '%s'" % filter_name)
            continue
        if "export" in dir(config.filters[filter_name]):
            for key,val in config.filters[filter_name].export.items():
                logger.debug("... pulling in filter_%s's exported key '%s'" % (filter_name, key))
                pp_env.globals[key] = val
    return pp_env
template.py 文件源码 项目:dractor 作者: VerizonDigital 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def __init__(self):
        _LOGGER.debug("Begin setting up jinja2 environment")
        try:
            j2_loader = jinja2.FileSystemLoader(PySrcRenderer.TEMPLATES_PATH)
            j2_env = jinja2.Environment(loader=j2_loader, trim_blocks=True)
        except Exception as error:
            raise my_exceptions.CodeGenError(
                "Couldn't setup jinja environment using path {}".format(
                    PySrcRenderer.TEMPLATES_PATH), error)
        else:
            _LOGGER.debug("Finished setting up jinja2 environment")

        _LOGGER.debug("Begin loading templates")
        self._parent_module_template = PySrcRenderer._load_template(
            j2_env, PySrcRenderer.PARENT_MODULE_TEMPLATE_NAME)
        self._sub_module_template = PySrcRenderer._load_template(
            j2_env, PySrcRenderer.SUB_MODULE_TEMPLATE_NAME)
        _LOGGER.debug("Finished loading templates")
templating.py 文件源码 项目:charm-nova-cloud-controller 作者: openstack 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def render_and_write(template_dir, path, context):
    """Renders the specified template into the file.

    :param template_dir: the directory to load the template from
    :param path: the path to write the templated contents to
    :param context: the parameters to pass to the rendering engine
    """
    env = Environment(loader=FileSystemLoader(template_dir))
    template_file = os.path.basename(path)
    template = env.get_template(template_file)
    log('Rendering from template: %s' % template.name, level=DEBUG)
    rendered_content = template.render(context)
    if not rendered_content:
        log("Render returned None - skipping '%s'" % path,
            level=WARNING)
        return

    write(path, rendered_content.encode('utf-8').strip())
    log('Wrote template %s' % path, level=DEBUG)
templating.py 文件源码 项目:charm-nova-cloud-controller 作者: openstack 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self, templates_dir, openstack_release):
        if not os.path.isdir(templates_dir):
            log('Could not locate templates dir %s' % templates_dir,
                level=ERROR)
            raise OSConfigException

        self.templates_dir = templates_dir
        self.openstack_release = openstack_release
        self.templates = {}
        self._tmpl_env = None

        if None in [Environment, ChoiceLoader, FileSystemLoader]:
            # if this code is running, the object is created pre-install hook.
            # jinja2 shouldn't get touched until the module is reloaded on next
            # hook execution, with proper jinja2 bits successfully imported.
            if six.PY2:
                apt_install('python-jinja2')
            else:
                apt_install('python3-jinja2')
log_api.py 文件源码 项目:geekcloud 作者: Mr-Linus 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def renderTemplate(script_path, time_file_path, dimensions=(24, 80), templatename=DEFAULT_TEMPLATE):
    with copen(script_path, encoding='utf-8', errors='replace', newline='\r\n') as scriptf:
    # with open(script_path) as scriptf:
        with open(time_file_path) as timef:
            timing = getTiming(timef)
            json = scriptToJSON(scriptf, timing)

    fsl = FileSystemLoader(dirname(templatename), 'utf-8')
    e = Environment()
    e.loader = fsl

    templatename = basename(templatename)
    rendered = e.get_template(templatename).render(json=json,
                                                   dimensions=dimensions)

    return rendered
auto-acl-doc.py 文件源码 项目:ldap2pg 作者: dalibo 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def main(args=sys.argv[1:]):
    acls, groups, aliases = process_acls(make_well_known_acls())

    env = Environment(
        loader=FileSystemLoader(os.getcwd()),
        undefined=StrictUndefined,
        trim_blocks=True,
    )
    env.filters['slugify'] = slugify_filter
    template = env.get_template(args[0])
    values = dict(
        acls=acls,
        aliases=aliases,
        groups=groups,
        version=__version__,
    )
    print(template.render(**values))
make_conf.py 文件源码 项目:airflow-docker 作者: Shinichi-Nakagawa 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create_airflow_cfg(path, tpl, filename='airflow.cfg', encoding='utf8'):
    """
    create airflow.cfg
    :param path: root path
    :param tpl: template file
    :param filename: output filename
    :param encoding: Encoding(default:utf8)
    """
    env = Environment(loader=FileSystemLoader(path, encoding=encoding))
    cfg_tpl = env.get_template(tpl)
    cfg = cfg_tpl.render({env: os.environ.get(env) for env in ENVIRONMENTS})
    file_path = '/'.join([path, filename])
    if os.path.exists(file_path):
        os.remove(file_path)

    with open(file_path, 'w', encoding=encoding) as f:
        f.write(cfg)
        f.close()
deploy.py 文件源码 项目:picoCTF 作者: royragsdale 项目源码 文件源码 阅读 45 收藏 0 点赞 0 评论 0
def template_file(in_file_path, out_file_path, **kwargs):
    """
    Templates the given file with the keyword arguments.

    Args:
        in_file_path: The path to the template
        out_file_path: The path to output the templated file
        **kwargs: Variables to use in templating
    """

    env = Environment(loader=FileSystemLoader(os.path.dirname(in_file_path)), keep_trailing_newline=True)
    template = env.get_template(os.path.basename(in_file_path))
    output = template.render(**kwargs)

    with open(out_file_path, "w") as f:
        f.write(output)
build.py 文件源码 项目:kolla-kubernetes-personal 作者: rthallisey 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def create_dockerfiles(self):
        kolla_version = version.version_info.cached_version_string()
        for path in self.docker_build_paths:
            template_name = "Dockerfile.j2"
            env = jinja2.Environment(loader=jinja2.FileSystemLoader(path))
            template = env.get_template(template_name)
            values = {'base_distro': self.base,
                      'base_distro_tag': self.base_tag,
                      'install_metatype': self.install_metatype,
                      'image_prefix': self.image_prefix,
                      'install_type': self.install_type,
                      'namespace': self.namespace,
                      'tag': self.tag,
                      'maintainer': self.maintainer,
                      'kolla_version': kolla_version,
                      'rpm_setup': self.rpm_setup}
            if self.include_header:
                with open(self.include_header, 'r') as f:
                    values['include_header'] = f.read()
            if self.include_footer:
                with open(self.include_footer, 'r') as f:
                    values['include_footer'] = f.read()
            content = template.render(values)
            with open(os.path.join(path, 'Dockerfile'), 'w') as f:
                f.write(content)
build.py 文件源码 项目:kolla-kubernetes-personal 作者: rthallisey 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def create_dockerfiles(self):
        kolla_version = version.version_info.cached_version_string()
        for path in self.docker_build_paths:
            template_name = "Dockerfile.j2"
            env = jinja2.Environment(loader=jinja2.FileSystemLoader(path))
            template = env.get_template(template_name)
            values = {'base_distro': self.base,
                      'base_distro_tag': self.base_tag,
                      'install_metatype': self.install_metatype,
                      'image_prefix': self.image_prefix,
                      'install_type': self.install_type,
                      'namespace': self.namespace,
                      'tag': self.tag,
                      'maintainer': self.maintainer,
                      'kolla_version': kolla_version,
                      'rpm_setup': self.rpm_setup}
            if self.include_header:
                with open(self.include_header, 'r') as f:
                    values['include_header'] = f.read()
            if self.include_footer:
                with open(self.include_footer, 'r') as f:
                    values['include_footer'] = f.read()
            content = template.render(values)
            with open(os.path.join(path, 'Dockerfile'), 'w') as f:
                f.write(content)
generate_scripts.py 文件源码 项目:envoy-perf 作者: envoyproxy 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def main():
  parser = argparse.ArgumentParser(
      formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument("template_dir",
                      help="the absolute path to the template directory")
  parser.add_argument("username",
                      help="your username on the VM in the cloud-platform")

  args = parser.parse_args()

  j2_env = Environment(loader=FileSystemLoader(args.template_dir),
                       trim_blocks=True)

  with open("Makefile", "w") as f:
    f.write(j2_env.get_template("Makefile.template").render(
        username=str(args.username)))
message.py 文件源码 项目:bottery 作者: rougeth 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def render(message, template_name, context={}):
    base_dir = os.path.join(os.getcwd(), 'templates')
    paths = [base_dir]
    # Include paths on settings
    # paths.extend(settings.TEMPLATES)

    env = Environment(
        loader=FileSystemLoader(paths),
        autoescape=select_autoescape(['html']))

    template = env.get_template(template_name)

    default_context = {
        'user': message.user
    }
    default_context.update(context)
    return template.render(**default_context)
core.py 文件源码 项目:bossimage 作者: cloudboss 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def load_config(path='.boss.yml'):
    loader = j.FileSystemLoader('.')
    try:
        template = loader.load(j.Environment(), path, os.environ)
        yml = template.render()
        doc = yaml.load(yml)
        return transform_config(doc)
    except j.TemplateNotFound:
        error = 'Error loading {}: not found'.format(path)
        raise ConfigurationError(error)
    except j.TemplateSyntaxError as e:
        error = 'Error loading {}: {}, line {}'.format(path, e, e.lineno)
        raise ConfigurationError(error)
    except IOError as e:
        error = 'Error loading {}: {}'.format(path, e.strerror)
        raise ConfigurationError(error)
    except v.Invalid as e:
        error = 'Error validating {}: {}'.format(path, e)
        raise ConfigurationError(error)
app.py 文件源码 项目:awesome-python3-webapp 作者: syusonn 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def init_jinja2(app,**kw):
    logging.info('init jinja2...')
    options = dict(
        autoescape = kw.get('autoescape',True),
        block_start_string = kw.get('block_start_string','{%'),
        block_end_string = kw.get('block_end_string','%}'),
        variable_start_string = kw.get('variable_start_string','{{'),
        variable_end_string = kw.get('variable_end_string','}}'),
        auto_reload = kw.get('auto_reload',True)
    )
    path = kw.get('path',None)
    if path is None:
        path = os.path.join(os.path.dirname(os.path.abspath(__file__)),'templates')
    logging.info('set jinja2 template path:%s ' % path)
    env = Environment(loader=FileSystemLoader(path),**options)
    filters = kw.get('filters',None)
    if filters is not None:
        for name,f in filters.items():
            env.filters[name] = f
    app['__templating__'] = env     

# ??????
better_apidoc.py 文件源码 项目:better-apidoc 作者: goerz 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def create_module_file(package, module, opts):
    # type: (unicode, unicode, Any) -> None
    """Generate RST for a top-level module (i.e., not part of a package)"""
    if not opts.noheadings:
        text = format_heading(1, '%s module' % module)
    else:
        text = ''
    # text += format_heading(2, ':mod:`%s` Module' % module)
    text += format_directive(module, package)

    if opts.templates:
        template_loader = FileSystemLoader(opts.templates)
        template_env = SandboxedEnvironment(loader=template_loader)
        try:
            mod_ns = _get_mod_ns(
                name=module, fullname=module,
                includeprivate=opts.includeprivate)
            template = template_env.get_template('module.rst')
            text = template.render(**mod_ns)
        except ImportError as e:
            _warn('failed to import %r: %s' % (module, e))
    write_file(makename(package, module), text, opts)


问题


面经


文章

微信
公众号

扫码关注公众号