Skip to content

Commit bbff1dd

Browse files
committed
Formatting
1 parent 8623142 commit bbff1dd

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

InteractiveHtmlBom/generate_interactive_bom.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ def generate_bom(pcb, filter_layer=None):
1717
:param filter_layer: include only parts for given layer
1818
:return: BOM table (qty, value, footprint, refs)
1919
"""
20-
def convert(text): return int(text) if text.isdigit() else text.lower()
2120

22-
def alphanum_key(key): return [convert(c)
23-
for c in re.split('([0-9]+)', key)]
21+
def convert(text):
22+
return int(text) if text.isdigit() else text.lower()
23+
24+
def alphanum_key(key):
25+
return [convert(c)
26+
for c in re.split('([0-9]+)', key)]
2427

2528
def natural_sort(l):
2629
"""
@@ -29,7 +32,6 @@ def natural_sort(l):
2932

3033
return sorted(l, key=alphanum_key)
3134

32-
3335
attr_dict = {0: 'Normal',
3436
1: 'Normal+Insert',
3537
2: 'Virtual'
@@ -369,7 +371,7 @@ def get_file_content(file_name):
369371
with open(bom_file_name, "wt") as bom:
370372
bom.write(html)
371373
print "Created file", bom_file_name
372-
374+
return bom_file_name
373375

374376

375377
def main(pcb, launch_browser=True):
@@ -385,7 +387,7 @@ def main(pcb, launch_browser=True):
385387
if not file_date:
386388
file_mtime = os.path.getmtime(pcb_file_name)
387389
file_date = datetime.fromtimestamp(file_mtime).strftime(
388-
'%Y-%m-%d %H:%M:%S')
390+
'%Y-%m-%d %H:%M:%S')
389391
title = title_block.GetTitle()
390392
if not title:
391393
title = os.path.basename(pcb_file_name)
@@ -417,8 +419,8 @@ def main(pcb, launch_browser=True):
417419
bom_file = generate_file(bom_file_dir, pcbdata)
418420

419421
if launch_browser:
420-
print "Opening it in browser"
421-
open_file(os.path.join(bom_file_dir, 'ibom.html'))
422+
print "Opening file in browser"
423+
open_file(bom_file)
422424

423425

424426
class GenerateInteractiveBomPlugin(pcbnew.ActionPlugin):
@@ -433,7 +435,8 @@ def defaults(self):
433435
"""
434436
self.name = "Generate Interactive HTML BOM"
435437
self.category = "Read PCB"
436-
self.description = "Generate interactive HTML page that contains BOM table and pcb drawing."
438+
self.description = "Generate interactive HTML page that contains BOM " \
439+
"table and pcb drawing."
437440

438441
def Run(self):
439442
main(pcbnew.GetBoard())

0 commit comments

Comments
 (0)