1
0
mirror of https://github.com/nophead/NopSCADlib.git synced 2025-08-09 17:06:34 +02:00

Avoid makeing empty folders for dxfs, stls or png if there are no parts of that type.

This commit is contained in:
Chris Palmer
2025-01-21 14:22:50 +00:00
parent 70fd7fbe14
commit 923c3b5c57
2 changed files with 18 additions and 10 deletions

View File

@@ -66,9 +66,16 @@ def make_parts(target, part_type, parts = None):
top_dir = set_config(target, lambda: usage(part_type)) top_dir = set_config(target, lambda: usage(part_type))
target_dir = top_dir + part_type + 's' target_dir = top_dir + part_type + 's'
deps_dir = target_dir + "/deps" deps_dir = target_dir + "/deps"
bom_dir = top_dir + "bom"
tmp_dir = mktmpdir(top_dir)
#
# Check we have some of this type
#
bom_dir = top_dir + "bom"
all_parts = bom_to_parts(bom_dir, part_type)
if not all_parts:
return
tmp_dir = mktmpdir(top_dir)
if not os.path.isdir(target_dir): if not os.path.isdir(target_dir):
os.makedirs(target_dir) os.makedirs(target_dir)
@@ -83,7 +90,6 @@ def make_parts(target, part_type, parts = None):
# #
# Decide which files to make # Decide which files to make
# #
all_parts = bom_to_parts(bom_dir, part_type)
if parts: if parts:
targets = list(parts) #copy the list so we dont modify the list passed in targets = list(parts) #copy the list so we dont modify the list passed in
else: else:

View File

@@ -37,19 +37,21 @@ def usage():
sys.exit(1) sys.exit(1)
def render(target, type): def render(target, type):
#
# Make the target directory
#
top_dir = set_config(target, usage) top_dir = set_config(target, usage)
tmp_dir = mktmpdir(top_dir)
target_dir = top_dir + type + 's'
bom_dir = top_dir + 'bom' bom_dir = top_dir + 'bom'
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
# #
# Find all the parts # Find all the parts
# #
parts = bom_to_parts(bom_dir, type) parts = bom_to_parts(bom_dir, type)
if not parts:
return
#
# Make the target directory
#
tmp_dir = mktmpdir(top_dir)
target_dir = top_dir + type + 's'
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
# #
# Read the json bom to get the colours # Read the json bom to get the colours
# #