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


Python Syncer.copy方法代码示例

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


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

示例1: update_static_metadata

# 需要导入模块: from readthedocs.privacy.loader import Syncer [as 别名]
# 或者: from readthedocs.privacy.loader.Syncer import copy [as 别名]
def update_static_metadata(project_pk, path=None):
    """Update static metadata JSON file

    Metadata settings include the following project settings:

    version
      The default version for the project, default: `latest`

    language
      The default language for the project, default: `en`

    languages
      List of languages built by linked translation projects.
    """
    project = Project.objects.get(pk=project_pk)
    if not path:
        path = project.static_metadata_path()

    log.info(LOG_TEMPLATE.format(
        project=project.slug,
        version='',
        msg='Updating static metadata',
    ))
    translations = [trans.language for trans in project.translations.all()]
    languages = set(translations)
    # Convert to JSON safe types
    metadata = {
        'version': project.default_version,
        'language': project.language,
        'languages': list(languages),
        'single_version': project.single_version,
    }
    try:
        fh = open(path, 'w+')
        json.dump(metadata, fh)
        fh.close()
        Syncer.copy(path, path, host=socket.gethostname(), file=True)
    except (AttributeError, IOError) as e:
        log.debug(LOG_TEMPLATE.format(
            project=project.slug,
            version='',
            msg='Cannot write to metadata.json: {0}'.format(e)
        ))
开发者ID:npk,项目名称:readthedocs.org,代码行数:45,代码来源:tasks.py

示例2: move_files

# 需要导入模块: from readthedocs.privacy.loader import Syncer [as 别名]
# 或者: from readthedocs.privacy.loader.Syncer import copy [as 别名]
def move_files(version_pk, hostname, html=False, localmedia=False, search=False,
               pdf=False, epub=False):
    """Task to move built documentation to web servers

    :param version_pk: Version id to sync files for
    :param hostname: Hostname to sync to
    :param html: Sync HTML
    :type html: bool
    :param localmedia: Sync local media files
    :type localmedia: bool
    :param search: Sync search files
    :type search: bool
    :param pdf: Sync PDF files
    :type pdf: bool
    :param epub: Sync ePub files
    :type epub: bool
    """
    version = Version.objects.get(pk=version_pk)

    if html:
        from_path = version.project.artifact_path(
            version=version.slug, type_=version.project.documentation_type)
        target = version.project.rtd_build_path(version.slug)
        Syncer.copy(from_path, target, host=hostname)

    if 'sphinx' in version.project.documentation_type:
        if localmedia:
            from_path = version.project.artifact_path(
                version=version.slug, type_='sphinx_localmedia')
            to_path = version.project.get_production_media_path(
                type_='htmlzip', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

        if search:
            from_path = version.project.artifact_path(
                version=version.slug, type_='sphinx_search')
            to_path = version.project.get_production_media_path(
                type_='json', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

        # Always move PDF's because the return code lies.
        if pdf:
            from_path = version.project.artifact_path(version=version.slug,
                                                      type_='sphinx_pdf')
            to_path = version.project.get_production_media_path(
                type_='pdf', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)
        if epub:
            from_path = version.project.artifact_path(version=version.slug,
                                                      type_='sphinx_epub')
            to_path = version.project.get_production_media_path(
                type_='epub', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

    if 'mkdocs' in version.project.documentation_type:
        if search:
            from_path = version.project.artifact_path(version=version.slug,
                                                      type_='mkdocs_json')
            to_path = version.project.get_production_media_path(
                type_='json', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)
开发者ID:npk,项目名称:readthedocs.org,代码行数:63,代码来源:tasks.py

示例3: move_files

# 需要导入模块: from readthedocs.privacy.loader import Syncer [as 别名]
# 或者: from readthedocs.privacy.loader.Syncer import copy [as 别名]
def move_files(version_pk, hostname, html=False, localmedia=False, search=False, pdf=False, epub=False):
    version = Version.objects.get(pk=version_pk)

    if html:
        from_path = version.project.artifact_path(version=version.slug, type=version.project.documentation_type)
        target = version.project.rtd_build_path(version.slug)
        Syncer.copy(from_path, target, host=hostname)

    if 'sphinx' in version.project.documentation_type:
        if localmedia:
            from_path = version.project.artifact_path(version=version.slug, type='sphinx_localmedia')
            to_path = version.project.get_production_media_path(type='htmlzip', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

        if search:
            from_path = version.project.artifact_path(version=version.slug, type='sphinx_search')
            to_path = version.project.get_production_media_path(type='json', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

        # Always move PDF's because the return code lies.
        if pdf:
            from_path = version.project.artifact_path(version=version.slug, type='sphinx_pdf')
            to_path = version.project.get_production_media_path(type='pdf', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)
        if epub:
            from_path = version.project.artifact_path(version=version.slug, type='sphinx_epub')
            to_path = version.project.get_production_media_path(type='epub', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)

    if 'mkdocs' in version.project.documentation_type:
        if search:
            from_path = version.project.artifact_path(version=version.slug, type='mkdocs_json')
            to_path = version.project.get_production_media_path(type='json', version_slug=version.slug, include_file=False)
            Syncer.copy(from_path, to_path, host=hostname)
开发者ID:rrahn,项目名称:readthedocs.org,代码行数:36,代码来源:tasks.py


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