Add a simple open wrapper for the bom python plugins to handle directory creation

This commit is contained in:
Marek Roszko
2021-12-02 01:07:55 -05:00
parent 0f67c7ed25
commit 50c1a91d44
7 changed files with 27 additions and 6 deletions
@@ -0,0 +1,15 @@
#
# KiCad python module for some helper functions
#
import os
def open_file_write(path, mode):
''' Open "path" for writing, creating any parent directories as needed.
'''
dir_path = os.path.dirname(path)
if not os.path.isdir(dir_path):
os.makedirs(dir_path)
return open(path, mode)