Remove unused parameter, fix default parameter (#76)

This commit is contained in:
Jason 2020-07-12 02:21:28 -04:00 committed by GitHub
parent 0cef5e3687
commit 3eed9681da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 13 deletions

View File

@ -4,7 +4,9 @@
from wireviz.DataClasses import Connector, Cable from wireviz.DataClasses import Connector, Cable
from graphviz import Graph from graphviz import Graph
from wireviz import wv_colors from wireviz import wv_colors
from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, nested_html_table, flatten2d, index_if_list, html_line_breaks, graphviz_line_breaks, remove_line_breaks from wireviz.wv_helper import awg_equiv, mm2_equiv, tuplelist2tsv, nested, \
nested_html_table, flatten2d, index_if_list, html_line_breaks, \
graphviz_line_breaks, remove_line_breaks
from collections import Counter from collections import Counter
from typing import List from typing import List
@ -23,8 +25,7 @@ class Harness:
self.cables[name] = Cable(name, *args, **kwargs) self.cables[name] = Cable(name, *args, **kwargs)
def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin): def connect(self, from_name, from_pin, via_name, via_pin, to_name, to_pin):
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]): # check from and to connectors
for (name, pin) in zip([from_name, to_name], [from_pin, to_pin]): # check from and to connectors
if name is not None and name in self.connectors: if name is not None and name in self.connectors:
connector = self.connectors[name] connector = self.connectors[name]
if pin in connector.pinnumbers and pin in connector.pinout: if pin in connector.pinnumbers and pin in connector.pinout:
@ -274,7 +275,7 @@ class Harness:
data.seek(0) data.seek(0)
return data.read() return data.read()
def output(self, filename, directory='_output', view=False, cleanup=True, fmt='pdf', gen_bom=False): def output(self, filename, directory='_output', view=False, cleanup=True, fmt=('pdf', )):
# graphical output # graphical output
graph = self.create_graph() graph = self.create_graph()
for f in fmt: for f in fmt:

View File

@ -16,7 +16,7 @@ if demos:
for i in range(1,demos+1): for i in range(1,demos+1):
fn = '../../examples/demo{:02d}.yml'.format(i) fn = '../../examples/demo{:02d}.yml'.format(i)
print(fn) print(fn)
wireviz.parse_file(fn, generate_bom=True) wireviz.parse_file(fn)
if examples: if examples:
with open(os.path.abspath('../../examples/readme.md'), 'w') as file: with open(os.path.abspath('../../examples/readme.md'), 'w') as file:
@ -24,7 +24,7 @@ if examples:
for i in range(1,examples+1): for i in range(1,examples+1):
fn = '../../examples/ex{:02d}.yml'.format(i) fn = '../../examples/ex{:02d}.yml'.format(i)
print(fn) print(fn)
wireviz.parse_file(fn, generate_bom=True) wireviz.parse_file(fn)
file.write('## Example {:02d}\n'.format(i)) file.write('## Example {:02d}\n'.format(i))
file.write('![](ex{:02d}.png)\n\n'.format(i)) file.write('![](ex{:02d}.png)\n\n'.format(i))
@ -36,7 +36,7 @@ if tutorials:
for i in range(1,tutorials+1): for i in range(1,tutorials+1):
fn = '../../tutorial/tutorial{:02d}.yml'.format(i) fn = '../../tutorial/tutorial{:02d}.yml'.format(i)
print(fn) print(fn)
wireviz.parse_file(fn, generate_bom=True) wireviz.parse_file(fn)
with open(os.path.abspath('../../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info: with open(os.path.abspath('../../tutorial/tutorial{:02d}.md'.format(i)), 'r') as info:
for line in info: for line in info:

View File

@ -16,13 +16,12 @@ from wireviz.Harness import Harness
from wireviz.wv_helper import expand from wireviz.wv_helper import expand
def parse(yaml_input, file_out=None, generate_bom=False, return_types: (None, str, Tuple[str]) = None): def parse(yaml_input, file_out=None, return_types: (None, str, Tuple[str]) = None):
""" """
Parses yaml input string and does the high-level harness conversion Parses yaml input string and does the high-level harness conversion
:param yaml_input: a string containing the yaml input data :param yaml_input: a string containing the yaml input data
:param file_out: :param file_out:
:param generate_bom:
:param return_types: if None, then returns None; if the value is a string, then a :param return_types: if None, then returns None; if the value is a string, then a
corresponding data format will be returned; if the value is a tuple of strings, corresponding data format will be returned; if the value is a tuple of strings,
then for every valid format in the `return_types` tuple, another return type then for every valid format in the `return_types` tuple, another return type
@ -171,7 +170,7 @@ def parse(yaml_input, file_out=None, generate_bom=False, return_types: (None, st
harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin) harness.connect(from_name, from_pin, via_name, via_pin, to_name, to_pin)
if file_out is not None: if file_out is not None:
harness.output(filename=file_out, fmt=('png', 'svg'), gen_bom=generate_bom, view=False) harness.output(filename=file_out, fmt=('png', 'svg'), view=False)
if return_types is not None: if return_types is not None:
returns = [] returns = []
@ -188,7 +187,7 @@ def parse(yaml_input, file_out=None, generate_bom=False, return_types: (None, st
return tuple(returns) if len(returns) != 1 else returns[0] return tuple(returns) if len(returns) != 1 else returns[0]
def parse_file(yaml_file, file_out=None, generate_bom=False): def parse_file(yaml_file, file_out=None):
with open(yaml_file, 'r') as file: with open(yaml_file, 'r') as file:
yaml_input = file.read() yaml_input = file.read()
@ -197,7 +196,7 @@ def parse_file(yaml_file, file_out=None, generate_bom=False):
file_out = fn file_out = fn
file_out = os.path.abspath(file_out) file_out = os.path.abspath(file_out)
parse(yaml_input, file_out=file_out, generate_bom=generate_bom) parse(yaml_input, file_out=file_out)
def parse_cmdline(): def parse_cmdline():
@ -238,7 +237,7 @@ def main():
file_out = args.output_file file_out = args.output_file
file_out = os.path.abspath(file_out) file_out = os.path.abspath(file_out)
parse(yaml_input, file_out=file_out, generate_bom=args.generate_bom) parse(yaml_input, file_out=file_out)
if __name__ == '__main__': if __name__ == '__main__':