Ejemplo n.º 1
0
def get_versioned_contents(filename):
    with open(filename, 'r') as f:
        original_contents = f.read()
        date = rev_info.current_date()
        rev = rev_info.git_short_rev()
        logger.info('Replacing placeholders with %s and %s' % (date, rev))
        return original_contents, original_contents \
            .replace('Date ""', 'Date "%s"' % date) \
            .replace('DATE: YYYY-MM-DD', 'DATE: %s' % date) \
            .replace('Rev ""', 'Rev "%s"' % rev) \
            .replace('COMMIT: deadbeef', 'COMMIT: %s' % rev)
Ejemplo n.º 2
0
if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--panelize',
        type=int,
        default=1,
        help='Quantity to panelize - must be 1 or an even number')

    args = parser.parse_args()

    laser_parts_directory = os.path.join('build', 'laser_parts')

    extra_variables = {
        'render_revision': rev_info.git_short_rev(),
        'render_date': rev_info.current_date(),
    }

    renderer = Renderer('splitflap.scad', laser_parts_directory,
                        extra_variables)
    renderer.clean()
    svg_output = renderer.render_svgs(panelize_quantity=args.panelize)

    logging.info('Removing redundant lines')
    processor = SvgProcessor(svg_output)
    redundant_lines = processor.remove_redundant_lines()
    processor.write(svg_output)

    # Export to png
    logging.info('Generating raster preview')
Ejemplo n.º 3
0
def _get_versioned_contents(filename):
    with open(filename, 'rb') as schematic:
        original_contents = schematic.read()
        return original_contents, original_contents \
            .replace('Date ""', 'Date "%s"' % rev_info.current_date()) \
            .replace('Rev ""', 'Rev "%s"' % rev_info.git_short_rev())
Ejemplo n.º 4
0
def _get_versioned_contents(filename):
    with open(filename, 'rb') as schematic:
        original_contents = schematic.read()
        return original_contents, original_contents \
            .replace('Date ""', 'Date "%s"' % rev_info.current_date()) \
            .replace('Rev ""', 'Rev "%s"' % rev_info.git_short_rev())
Ejemplo n.º 5
0
import os
import sys

from colored_stl_exporter import ColoredStlExporter

repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(repo_root)

from util import rev_info


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)
    folder = os.path.dirname(__file__)

    openscad_variables = {
        'render_3d': True,
        'render_enclosure': 2,
        'render_flaps': True,
        'render_units': 1,
        'render_pcb': True,
        'render_revision': rev_info.git_short_rev(),
        'render_date': rev_info.current_date(),
    }

    exporter = ColoredStlExporter(
        os.path.join(folder, 'splitflap.scad'),
        os.path.join(folder, 'build'),
        openscad_variables)
    exporter.run()