def contains_warnings(filename): openscad.run_silent('-o', config.paths['dummycsg'], filename) warnings = [] for line in open(config.paths['openscadlog'], "rt").readlines(): # warnings r = re.search(r".*WARNING:(.*)$", line, re.I) if r: warnings.append(line) return warnings
def contains_warnings(filename): openscad.run_silent('-o','dummy.csg',filename); warnings = [] for line in open('openscad.log', "rt").readlines(): # warnings r = re.search(r".*WARNING:(.*)$", line, re.I) if r: warnings.append(line) return warnings
def contains_syntax_error(filename): openscad.run_silent('-o', config.paths['dummycsg'], filename) errorlevel = 0 for line in open(config.paths['openscadlog'], "rt").readlines(): # errors r = re.search(r".*(Parser.*line\s(\w+): syntax error)$", line, re.I) if r: errorlevel = int(r.group(2)) continue return errorlevel
def contains_syntax_error(filename): openscad.run_silent('-o','dummy.csg',filename); errorlevel = 0 for line in open('openscad.log', "rt").readlines(): # errors r = re.search(r".*(Parser.*line\s(\w+): syntax error)$", line, re.I) if r: errorlevel = int(r.group(2)) continue return errorlevel
def plateup(target, part_type, usage=None): # # Make the target directory # top_dir = set_config(target, usage) parts_dir = top_dir + part_type + 's' target_dir = parts_dir + '/' + target_dirs[part_type] source_dir = top_dir + source_dirs[part_type] deps_dir = source_dir + "/deps" if not os.path.isdir(source_dir): return if not os.path.isdir(target_dir): os.makedirs(target_dir) if not os.path.isdir(deps_dir): os.makedirs(deps_dir) # # Decide which files to make # sources = [ file for file in os.listdir(source_dir) if file.endswith('.scad') ] # # Run OpenSCAD on the source files to make the targets # used = [] for src in sources: src_file = source_dir + '/' + src part_file = target_dir + '/' + src[:-4] + part_type dname = deps_name(deps_dir, src) changed = check_deps(part_file, dname) if changed: print(changed) openscad.run("-D$bom=1", "-d", dname, "-o", part_file, src_file) if part_type == 'stl': c14n_stl.canonicalise(part_file) log_name = 'openscad.log' else: log_name = 'openscad.echo' openscad.run_silent("-D$bom=1", "-o", log_name, src_file) # # Add the files on the BOM to the used list # with open(log_name) as file: for line in file.readlines(): if line.startswith('ECHO: "~') and line.endswith('.' + part_type + '"\n'): used.append(line[8:-2]) # # Copy file that are not included # copied = [] for file in os.listdir(parts_dir): if file.endswith('.' + part_type) and not file in used: src = parts_dir + '/' + file dst = target_dir + '/' + file if mtime(src) > mtime(dst): print("Copying %s to %s" % (src, dst)) copyfile(src, dst) copied.append(file) # # Remove any cruft # targets = [file[:-4] + part_type for file in sources] for file in os.listdir(target_dir): if file.endswith('.' + part_type): if not file in targets and not file in copied: print("Removing %s" % file) os.remove(target_dir + '/' + file)
def plateup(target, part_type, usage=None): # # Make the target directory # top_dir = set_config(target, usage) parts_dir = top_dir + part_type + 's' target_dir = parts_dir + '/' + target_dirs[part_type] source_dir1 = source_dirs[part_type] source_dir2 = top_dir + source_dirs[part_type] # # Loop through source directories # used = [] all_sources = [] for dir in [source_dir1, source_dir2]: if not os.path.isdir(dir): continue if not os.path.isdir(target_dir): os.makedirs(target_dir) # # Make the deps dir # deps_dir = dir + "/deps" if not os.path.isdir(deps_dir): os.makedirs(deps_dir) # # Decide which files to make # sources = [file for file in os.listdir(dir) if file.endswith('.scad')] all_sources += sources # # Run OpenSCAD on the source files to make the targets # for src in sources: src_file = dir + '/' + src part_file = target_dir + '/' + src[:-4] + part_type dname = deps_name(deps_dir, src) changed = check_deps(part_file, dname) if changed: print(changed) openscad.run("-D$bom=1", "-d", dname, "-o", part_file, src_file) if part_type == 'stl': c14n_stl.canonicalise(part_file) log_name = 'openscad.log' else: log_name = 'openscad.echo' openscad.run_silent("-D$bom=1", "-o", log_name, src_file) # # Add the files on the BOM to the used list # with open(log_name) as file: for line in file.readlines(): match = re.match(r'^ECHO: "~(.*?\.' + part_type + r').*"$', line) if match: used.append(match.group(1)) # # Copy file that are not included # copied = [] for file in os.listdir(parts_dir): if file.endswith('.' + part_type) and not file in used: src = parts_dir + '/' + file dst = target_dir + '/' + file if mtime(src) > mtime(dst): print("Copying %s to %s" % (src, dst)) copyfile(src, dst) copied.append(file) # # Remove any cruft # targets = [file[:-4] + part_type for file in all_sources] for file in os.listdir(target_dir): if file.endswith('.' + part_type): if not file in targets and not file in copied: print("Removing %s" % file) os.remove(target_dir + '/' + file)