def get_blueprint_info(path, transform_str):
    """
    Returns information about the blueprint at path. If transform_str
    is given, blueprint will be transformed accordingly before returning.
    """
    sheets = filereader.get_sheet_names(path)

    newphase, transforms, ztransforms = \
        transformer.parse_transform_str(transform_str)

    result = ''
    for sheet in sheets:
        try:
            (layers, details) = filereader.parse_file(path, sheet[1])

            # transform the blueprint
            if transforms is not None:
                logmsg('transform', 'Transforming with: %s' % transform_str)

                if newphase is not None:
                    details['build_type'] = buildconfig.get_full_build_type_name(newphase)

                tran = Transformer(layers, details['start'])
                tran.transform(transforms)  # do the x/y transformations
                details['start'] = tran.start
                layers = tran.layers

                logmsg('transform', 'Results of transform:')
                loglines('transform', lambda: FileLayer.str_layers(layers))

            layers = FileLayers_to_GridLayers(layers)
            bp = Blueprint(sheet[0], layers, details)

            # perform any requested z-transforms
            if ztransforms is not None:
                layers = bp.repeat_ztransforms(ztransforms, bp.layers,
                    Blueprint.repeater_layers)
                bp.layers = layers

            formatted = bp.get_info()

            # add this sheet's info to the result string
            result += '>>>> Sheet id %d\n' % sheet[1]
            result += formatted + '\n'
        except BlueprintError as ex:
            continue    # ignore blank/missing sheets

    if result:
        return result
    else:
        raise BlueprintError("No valid blueprints found in '%s'." % path)
예제 #2
0
def get_blueprint_info(path, transform_str):
    """
    Returns information about the blueprint at path. If transform_str
    is given, blueprint will be transformed accordingly before returning.
    """
    sheets = filereader.get_sheet_names(path)

    newphase, transforms, ztransforms = \
        transformer.parse_transform_str(transform_str)

    result = ''
    for sheet in sheets:
        try:
            (layers, details) = filereader.parse_file(path, sheet[1])

            # transform the blueprint
            if transforms is not None:
                logmsg('transform', 'Transforming with: %s' % transform_str)

                if newphase is not None:
                    details[
                        'build_type'] = buildconfig.get_full_build_type_name(
                            newphase)

                tran = Transformer(layers, details['start'])
                tran.transform(transforms)  # do the x/y transformations
                details['start'] = tran.start
                layers = tran.layers

                logmsg('transform', 'Results of transform:')
                loglines('transform', lambda: FileLayer.str_layers(layers))

            layers = FileLayers_to_GridLayers(layers)
            bp = Blueprint(sheet[0], layers, details)

            # perform any requested z-transforms
            if ztransforms is not None:
                layers = bp.repeat_ztransforms(ztransforms, bp.layers,
                                               Blueprint.repeater_layers)
                bp.layers = layers

            formatted = bp.get_info()

            # add this sheet's info to the result string
            result += '>>>> Sheet id %d\n' % sheet[1]
            result += formatted + '\n'
        except BlueprintError as ex:
            continue  # ignore blank/missing sheets

    if result:
        return result
    else:
        raise BlueprintError("No valid blueprints found in '%s'." % path)
예제 #3
0
def process_blueprint_file(path, sheetid, startpos, transform_str, output_mode,
                           output_title, visualize):
    """
    Parses a blueprint file and converts it to desired output.
    """

    # parse sheetid
    if sheetid is None:
        sheetid = 0
    elif not re.match('^\d+$', str(sheetid)):
        # TODO Fix this so it works
        sheetid = filereader.get_sheet_names(path)[1]

    # read in the blueprint
    layers, details = filereader.parse_file(path, sheetid)

    logmsg('file', 'Parsed %s' % path)
    loglines('file', lambda: FileLayer.str_layers(layers))

    return convert_blueprint(layers, details, startpos, transform_str,
                             output_mode, output_title, visualize)
def process_blueprint_file(path, sheetid, startpos, transform_str,
    output_mode, output_title, visualize):
    """
    Parses a blueprint file and converts it to desired output.
    """

    # parse sheetid
    if sheetid is None:
        sheetid = 0
    elif not re.match('^\d+$', str(sheetid)):
        # TODO Fix this so it works
        sheetid = filereader.get_sheet_names(path)[1]

    # read in the blueprint
    layers, details = filereader.parse_file(path, sheetid)

    logmsg('file', 'Parsed %s' % path)
    loglines('file', lambda: FileLayer.str_layers(layers))

    return convert_blueprint(layers, details, startpos, transform_str,
        output_mode, output_title, visualize)