From c41b1fa1151fb5a7fe09cb3a4fb53c79ab99de71 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sun, 1 Mar 2020 10:55:52 +0000 Subject: [PATCH 1/2] Fix for issue #57, now searches multiple directories. --- scripts/exports.py | 4 ++-- scripts/views.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/exports.py b/scripts/exports.py index dd8117c..3a478d9 100644 --- a/scripts/exports.py +++ b/scripts/exports.py @@ -83,9 +83,9 @@ def make_parts(target, part_type, parts = None): # # Find all the scad files # - lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed' + lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in os.listdir(path)] module_suffix = '_dxf' if part_type == 'svg' else '_' + part_type - for dir in [source_dir, source_dir + '/printed', lib_dir]: + for dir in [source_dir, source_dir + '/printed'] + lib_dirs: if os.path.isdir(dir): for filename in os.listdir(dir): if filename[-5:] == ".scad": diff --git a/scripts/views.py b/scripts/views.py index e14b767..d7139b9 100755 --- a/scripts/views.py +++ b/scripts/views.py @@ -124,8 +124,8 @@ def views(target, do_assemblies = None): # Find all the scad files # main_blurb = None - lib_dir = os.environ['OPENSCADPATH'] + '/NopSCADlib/printed' - for dir in [source_dir, source_dir + '/printed', lib_dir]: + lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in os.listdir(path)] + for dir in [source_dir, source_dir + '/printed'] + lib_dirs: if os.path.isdir(dir): for filename in os.listdir(dir): if filename.endswith('.scad'): From 343351155c0146a990300cdb76ca054146036f8f Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sun, 1 Mar 2020 17:53:20 +0000 Subject: [PATCH 2/2] Made library search order deterministic by sorting the result of os.listdir() --- scripts/exports.py | 2 +- scripts/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/exports.py b/scripts/exports.py index 3a478d9..ae2d5f7 100644 --- a/scripts/exports.py +++ b/scripts/exports.py @@ -83,7 +83,7 @@ def make_parts(target, part_type, parts = None): # # Find all the scad files # - lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in os.listdir(path)] + lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in sorted(os.listdir(path))] module_suffix = '_dxf' if part_type == 'svg' else '_' + part_type for dir in [source_dir, source_dir + '/printed'] + lib_dirs: if os.path.isdir(dir): diff --git a/scripts/views.py b/scripts/views.py index d7139b9..a2eb7a1 100755 --- a/scripts/views.py +++ b/scripts/views.py @@ -124,7 +124,7 @@ def views(target, do_assemblies = None): # Find all the scad files # main_blurb = None - lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in os.listdir(path)] + lib_dirs = [path + '/' + lib + '/printed' for path in os.environ['OPENSCADPATH'].split(os.pathsep) for lib in sorted(os.listdir(path))] for dir in [source_dir, source_dir + '/printed'] + lib_dirs: if os.path.isdir(dir): for filename in os.listdir(dir):