コード例 #1
0
def transfer_source(conf, sconf):
    target = os.path.join(conf.paths.projectroot, conf.paths.branch_source)

    if not os.path.exists(target):
        os.makedirs(target)
        logger.debug('created directory for sphinx build: {0}'.format(target))
    elif not os.path.isdir(target):
        msg = '"{0}" exists and is not a directory'.format(target)
        logger.error(msg)
        raise InvalidFile(msg)

    source_dir = os.path.join(conf.paths.projectroot, conf.paths.source)

    # we don't want rsync to delete directories that hold generated content in
    # the target so we can have more incremental
    exclusions = "--exclude=" + ' --exclude='.join(
        [os.path.join('includes', 'steps'),
         os.path.join('includes', 'toc')])

    command(
        'rsync --times --checksum --recursive {2} --delete {0}/ {1}'.format(
            source_dir, target, exclusions))

    source_exclusion(conf, sconf)
    dump_file_hashes(conf)

    logger.info('prepared source for sphinx build in {0}'.format(target))
コード例 #2
0
ファイル: source.py プロジェクト: stennie/docs-tools
def transfer_source(conf, sconf):
    target = os.path.join(conf.paths.projectroot, conf.paths.branch_source)

    dir_exists = safe_create_directory(target)

    # this operation is just for messaging the above operation, and error'ing
    # appropriately.
    if dir_exists is True:
        logger.info('created directory for sphinx build: {0}'.format(target))
    elif not os.path.isdir(target):
        msg = '"{0}" exists and is not a directory'.format(target)
        logger.error(msg)
        raise InvalidFile(msg)

    source_dir = os.path.join(conf.paths.projectroot, conf.paths.source)
    exclusions = [
        os.path.join('includes', 'table'),
        os.path.join('includes', 'generated')
    ]

    if conf.paths.images is not None:
        image_dir = os.path.join(conf.paths.images[len(conf.paths.source) +
                                                   1:])
        exclusions.append(image_dir + os.path.sep + '*.png')
        exclusions.append(image_dir + os.path.sep + '*.rst')

    prefix_len = len(
        os.path.join(conf.paths.projectroot, conf.paths.branch_source)) + 1

    exclusions.extend([
        o for o in conf.system.content.output_directories(prefix_len)
        if o != "includes/changelogs"
    ])

    # we don't want rsync to delete directories that hold generated content in
    # the target so we can have more incremental builds.
    exclusions = "--exclude=" + ' --exclude='.join(exclusions)

    cmd = 'rsync --links --checksum --recursive {2} --delete {0}/ {1}'
    cmd = cmd.format(source_dir, target, exclusions)

    try:
        subprocess.check_call(shlex.split(cmd))
    except subprocess.CalledProcessError as e:
        logger.error('source transfer rsync had error: ' + str(e.returncode))
        logger.info(cmd)

    # remove files from the source tree specified in the sphinx config for this
    # build.
    source_exclusion(conf, sconf)
    os.utime(target, None)

    logger.info(
        'prepared and migrated source for sphinx build in {0}'.format(target))
コード例 #3
0
ファイル: serialization.py プロジェクト: banlyst/docs-tools
def ingest_yaml(filename):
    o = []
    with open(filename, 'r') as f:
        try:
            data = yaml.load_all(f)
        except:
            logger.error("error decoding yaml in: " + filename)
            raise InvalidFile(filename)

        o.extend(data)

    if len(o) == 1:
        o = o[0]

    return o
コード例 #4
0
ファイル: source.py プロジェクト: banlyst/docs-tools
def transfer_source(conf, sconf):
    target = os.path.join(conf.paths.projectroot, conf.paths.branch_source)

    dir_exists = safe_create_directory(target)

    # this operation is just for messaging the above operation, and error'ing
    # appropriately.
    if dir_exists is True:
        logger.info('created directory for sphinx build: {0}'.format(target))
    elif not os.path.isdir(target):
        msg = '"{0}" exists and is not a directory'.format(target)
        logger.error(msg)
        raise InvalidFile(msg)

    source_dir = os.path.join(conf.paths.projectroot, conf.paths.source)
    image_dir = os.path.join(conf.paths.images[len(conf.paths.source)+1:])
    ref_dir = 'reference'

    exclusions = [ os.path.join('includes', 'table'),
                   os.path.join('includes', 'generated'),
                   os.path.join(ref_dir, 'method') + os.path.sep + "*.rst",
                   os.path.join(ref_dir, 'command') + os.path.sep + "*.rst",
                   os.path.join(ref_dir, 'operator', 'query') + os.path.sep + "*.rst",
                   os.path.join(ref_dir, 'operator', 'aggregation') + os.path.sep + "*.rst",
                   ref_dir + os.path.sep + "*.rst",
                   image_dir + os.path.sep + "*.png",
                   image_dir + os.path.sep + "*.rst",
                   image_dir + os.path.sep + "*.eps" ]

    prefix_len = len(os.path.join(conf.paths.projectroot, conf.paths.branch_source)) + 1
    exclusions.extend([ o for o in conf.system.content.output_directories(prefix_len) ])

    # we don't want rsync to delete directories that hold generated content in
    # the target so we can have more incremental builds.
    exclusions = "--exclude=" + ' --exclude='.join(exclusions)

    cmd = 'rsync --checksum --recursive {2} --delete {0}/ {1}'.format(source_dir, target, exclusions)
    command(cmd)

    # remove files from the source tree specified in the sphinx config for this
    # build.
    source_exclusion(conf, sconf)
    os.utime(target, None)

    logger.info('prepared and migrated source for sphinx build in {0}'.format(target))