Skip to content

Commit 97755c3

Browse files
committed
Allow directory separators in name format
Fixes #96
1 parent 3587244 commit 97755c3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

InteractiveHtmlBom/core/ibom.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ def process_substitutions(bom_name_format, pcb_file_name, metadata):
196196
name = name.replace('%D', now.strftime('%Y-%m-%d'))
197197
name = name.replace('%T', now.strftime('%H-%M-%S'))
198198
# sanitize the name to avoid characters illegal in file systems
199-
name = re.sub(r'[/\\?%*:|"<>]', '_', name)
199+
name = name.replace('\\', '/')
200+
name = re.sub(r'[?%*:|"<>]', '_', name)
200201
return name + '.html'
201202

202203

@@ -212,11 +213,12 @@ def get_file_content(file_name):
212213
bom_file_dir = config.bom_dest_dir
213214
else:
214215
bom_file_dir = os.path.join(pcb_file_dir, config.bom_dest_dir)
215-
if not os.path.isdir(bom_file_dir):
216-
os.makedirs(bom_file_dir)
217216
bom_file_name = process_substitutions(
218217
config.bom_name_format, pcb_file_name, pcbdata['metadata'])
219218
bom_file_name = os.path.join(bom_file_dir, bom_file_name)
219+
bom_file_dir = os.path.dirname(bom_file_name)
220+
if not os.path.isdir(bom_file_dir):
221+
os.makedirs(bom_file_dir)
220222
pcbdata_js = "var pcbdata = " + json.dumps(pcbdata)
221223
config_js = "var config = " + config.get_html_config()
222224
html = get_file_content("ibom.html")

0 commit comments

Comments
 (0)