#NEWLINE# def gerberise( manufacturer = 'default' ) : #NEWLINE# #INDENT# '\n    Generate Gerbers for one or more layers\n    ' #NEWLINE# svg_in = utils . openBoardSVG ( ) #NEWLINE# gcd = config . brd [ 'gerber' ] #NEWLINE# decimals = gcd [ 'decimals' ] #NEWLINE# digits = gcd [ 'digits' ] #NEWLINE# steps = gcd [ 'steps-per-segment' ] #NEWLINE# length = gcd [ 'min-segment-length' ] #NEWLINE# xpath_regex = '' #NEWLINE# ns = { #NEWLINE# #INDENT# 'pcbmode' : config . cfg [ 'ns' ] [ 'pcbmode' ] , #NEWLINE# 'svg' : config . cfg [ 'ns' ] [ 'svg' ] , #NEWLINE# #UNINDENT# } #NEWLINE# base_dir = os . path . join ( config . cfg [ 'base-dir' ] , config . cfg [ 'locations' ] [ 'build' ] , 'production' ) #NEWLINE# utils . create_dir ( base_dir ) #NEWLINE# base_name = ( '%s_rev_%s' % ( config . brd [ 'config' ] [ 'name' ] , config . brd [ 'config' ] [ 'rev' ] ) ) #NEWLINE# filename_info = config . cfg [ 'manufacturers' ] [ manufacturer ] [ 'filenames' ] [ 'gerbers' ] #NEWLINE# for pcb_layer in config . stk [ 'layer-names' ] : #NEWLINE# #INDENT# svg_layer = svg_in . find ( ( "//svg:g[@pcbmode:pcb-layer='%s']" % pcb_layer ) , namespaces = ns ) #NEWLINE# mask_paths = svg_in . findall ( ( ".//svg:defs//svg:mask[@pcbmode:pcb-layer='%s']//svg:path" % pcb_layer ) , namespaces = ns ) #NEWLINE# sheets = [ 'conductor' , 'soldermask' , 'solderpaste' , 'silkscreen' ] #NEWLINE# for sheet in sheets : #NEWLINE# #INDENT# sheet_layer = svg_layer . find ( ( ".//svg:g[@pcbmode:sheet='%s']" % sheet ) , namespaces = ns ) #NEWLINE# if ( sheet == 'conductor' ) : #NEWLINE# #INDENT# mask_paths_to_pass = mask_paths #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mask_paths_to_pass = [ ] #NEWLINE# #UNINDENT# if ( sheet_layer != None ) : #NEWLINE# #INDENT# gerber = Gerber ( sheet_layer , mask_paths_to_pass , decimals , digits , steps , length ) #NEWLINE# add = ( '_%s_%s.%s' % ( pcb_layer , sheet , ( filename_info [ pcb_layer . split ( '-' ) [ 0 ] ] [ sheet ] . get ( 'ext' ) or 'ger' ) ) ) #NEWLINE# filename = os . path . join ( base_dir , ( base_name + add ) ) #NEWLINE# with open ( filename , 'wb' ) as f : #NEWLINE# #INDENT# for line in gerber . getGerber ( ) : #NEWLINE# #INDENT# f . write ( line ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# sheets = [ 'outline' , 'documentation' ] #NEWLINE# for sheet in sheets : #NEWLINE# #INDENT# sheet_layer = svg_in . find ( ( ".//svg:g[@pcbmode:sheet='%s']" % sheet ) , namespaces = ns ) #NEWLINE# gerber = Gerber ( sheet_layer , [ ] , decimals , digits , steps , length ) #NEWLINE# add = ( '_%s.%s' % ( sheet , ( filename_info [ 'other' ] [ sheet ] . get ( 'ext' ) or 'ger' ) ) ) #NEWLINE# filename = os . path . join ( base_dir , ( base_name + add ) ) #NEWLINE# with open ( filename , 'wb' ) as f : #NEWLINE# #INDENT# for line in gerber . getGerber ( False ) : #NEWLINE# #INDENT# f . write ( line ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return [ 'bullshit' ]