Make BOM output optional
This commit is contained in:
parent
db313365ee
commit
d2abf5f597
@ -9,12 +9,12 @@ with open(readme, 'w') as file:
|
|||||||
for i in range(1,3):
|
for i in range(1,3):
|
||||||
fn = '../examples/demo{:02d}.yml'.format(i)
|
fn = '../examples/demo{:02d}.yml'.format(i)
|
||||||
print(fn)
|
print(fn)
|
||||||
wireviz.parse(fn)
|
wireviz.parse(fn, gen_bom=False)
|
||||||
|
|
||||||
for i in range(1,7):
|
for i in range(1,7):
|
||||||
fn = '../examples/ex{:02d}.yml'.format(i)
|
fn = '../examples/ex{:02d}.yml'.format(i)
|
||||||
print(fn)
|
print(fn)
|
||||||
wireviz.parse(fn)
|
wireviz.parse(fn, gen_bom=False)
|
||||||
|
|
||||||
file.write('## Example {:02d}\n'.format(i))
|
file.write('## Example {:02d}\n'.format(i))
|
||||||
file.write('\n\n'.format(i))
|
file.write('\n\n'.format(i))
|
||||||
|
|||||||
@ -245,7 +245,7 @@ class Harness:
|
|||||||
|
|
||||||
return dot
|
return dot
|
||||||
|
|
||||||
def output(self, filename, directory='_output', view=False, cleanup=True, format='pdf'):
|
def output(self, filename, directory='_output', view=False, cleanup=True, format='pdf', gen_bom=False):
|
||||||
# graphical output
|
# graphical output
|
||||||
d = self.create_graph()
|
d = self.create_graph()
|
||||||
for f in format:
|
for f in format:
|
||||||
@ -253,6 +253,7 @@ class Harness:
|
|||||||
d.render(filename=filename, directory=directory, view=view, cleanup=cleanup)
|
d.render(filename=filename, directory=directory, view=view, cleanup=cleanup)
|
||||||
d.save(filename='{}.gv'.format(filename), directory=directory)
|
d.save(filename='{}.gv'.format(filename), directory=directory)
|
||||||
# bom output
|
# bom output
|
||||||
|
if gen_bom:
|
||||||
# connectors
|
# connectors
|
||||||
_con = self.bom_connectors()
|
_con = self.bom_connectors()
|
||||||
header_con = ['Type','Gender','Pin count','Qty','Designators']
|
header_con = ['Type','Gender','Pin count','Qty','Designators']
|
||||||
@ -499,7 +500,7 @@ def awg_equiv(mm2):
|
|||||||
else:
|
else:
|
||||||
return 'unknown'
|
return 'unknown'
|
||||||
|
|
||||||
def parse(file_in, file_out=None):
|
def parse(file_in, file_out=None, gen_bom=False):
|
||||||
|
|
||||||
file_in = os.path.abspath(file_in)
|
file_in = os.path.abspath(file_in)
|
||||||
if not file_out:
|
if not file_out:
|
||||||
@ -683,7 +684,7 @@ def parse(file_in, file_out=None):
|
|||||||
else:
|
else:
|
||||||
raise Exception('Wrong number of connection parameters')
|
raise Exception('Wrong number of connection parameters')
|
||||||
|
|
||||||
h.output(filename=file_out, format=('png','svg'), view=False)
|
h.output(filename=file_out, format=('png','svg'), gen_bom=gen_bom, view=False)
|
||||||
|
|
||||||
def tuplelist2tsv(input, header=None):
|
def tuplelist2tsv(input, header=None):
|
||||||
output = ''
|
output = ''
|
||||||
@ -701,6 +702,7 @@ if __name__ == '__main__':
|
|||||||
ap = argparse.ArgumentParser()
|
ap = argparse.ArgumentParser()
|
||||||
ap.add_argument('file_input', nargs='?', default='_test/test.yml')
|
ap.add_argument('file_input', nargs='?', default='_test/test.yml')
|
||||||
ap.add_argument('file_output', nargs='?', default=None)
|
ap.add_argument('file_output', nargs='?', default=None)
|
||||||
|
ap.add_argument('--bom', action='store_const', default=False, const=True)
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
|
||||||
parse(args.file_input, args.file_output)
|
parse(args.file_input, file_out=args.file_output, gen_bom=args.bom)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user