From bf61e4920f95b5bc7c9faf8ed0e08a880b252f3c Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sun, 23 Sep 2018 17:33:07 +0200 Subject: [PATCH 1/2] Remove submodules SolidPython and ThingDoc. --- .gitmodules | 6 ------ README.markdown | 11 +++++------ SolidPython | 1 - ThingDoc | 1 - 4 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 .gitmodules delete mode 160000 SolidPython delete mode 160000 ThingDoc diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7c2d3dc..0000000 --- a/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "SolidPython"] - path = SolidPython - url = https://github.com/SolidCode/SolidPython.git -[submodule "ThingDoc"] - path = ThingDoc - url = https://github.com/SolidCode/ThingDoc.git diff --git a/README.markdown b/README.markdown index 7c3b097..266a637 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -OpenSCAD MCAD Library [![](http://stillmaintained.com/elmom/MCAD.png)](http://stillmaintained.com/elmom/MCAD) +OpenSCAD MCAD Library ===================== This library contains components commonly used in designing and moching up @@ -6,10 +6,10 @@ mechanical designs. It is currently unfinished and you can expect some API changes, however many things are already working. This library was created by various authors as named in the individual -files' comments. All the files except those ThingDoc are licensed under -the LGPL 2.1 (see http://creativecommons.org/licenses/LGPL/2.1/ or the -included file lgpl-2.1.txt), some of them allow distribution under more -permissive terms (as described in the files' comments). +files' comments. All the files are licensed under the LGPL 2.1 (see +http://creativecommons.org/licenses/LGPL/2.1/ or the included file +lgpl-2.1.txt), some of them allow distribution under more permissive +terms (as described in the files' comments). ## Usage ## @@ -73,7 +73,6 @@ External utils that generate and and process openscad code: * openscad_testing.py: testing code, see below * openscad_utils.py: code for scraping function names etc. -* SolidPython: An external Python library for solid cad ## Development ## diff --git a/SolidPython b/SolidPython deleted file mode 160000 index ecf1c08..0000000 --- a/SolidPython +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ecf1c0888ad323e2be5b2ec1578773be46b72435 diff --git a/ThingDoc b/ThingDoc deleted file mode 160000 index 54c83e5..0000000 --- a/ThingDoc +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 54c83e5a41131156cad0ce7e3271433b1035aab1 From 9eae9ba98e530b2bb73bbdcf14666d6d75177f12 Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sun, 23 Sep 2018 19:03:17 +0200 Subject: [PATCH 2/2] Update test code for Python3. --- .gitignore | 3 +++ README.markdown | 22 +++++++++++++++++++++- openscad_testing.py | 26 ++++++++++++++------------ openscad_utils.py | 16 ++++++++-------- test_docs.py | 8 +++++--- 5 files changed, 51 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index b25c15b..979f64b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *~ +*.pyc +.pytest_cache/ +__pycache__/ diff --git a/README.markdown b/README.markdown index 266a637..3128a55 100644 --- a/README.markdown +++ b/README.markdown @@ -46,7 +46,7 @@ Currently Provided Tools: * motors.scad: - stepper_motor_mount(nema_standard, slide_distance OPTIONAL, mochup OPTIONAL) -Other tools (alpha and beta quality): +Tools (alpha and beta quality): * nuts_and_bolts.scad: for creating metric and imperial bolt/nut holes * bearing.scad: standard/custom bearings @@ -69,6 +69,26 @@ Very generally useful functions and constants: * shapes.scad: DEPRECATED simple shapes by Catarina Mota * polyholes.scad: holes that should come out well when printed +Other: + +* alphabet_block.scad +* bitmap.scad +* letter_necklace.scad +* name_tag.scad +* height_map.scad +* trochoids.scad +* libtriangles.scad +* layouts.scad +* transformations.scad +* 2Dshapes.scad +* gridbeam.scad +* fonts.scad +* unregular_shapes.scad +* metric_fastners.scad +* lego_compatibility.scad +* multiply.scad +* hardware.scad + External utils that generate and and process openscad code: * openscad_testing.py: testing code, see below diff --git a/openscad_testing.py b/openscad_testing.py index cadbc2f..05f30e7 100644 --- a/openscad_testing.py +++ b/openscad_testing.py @@ -7,16 +7,20 @@ temppath = py.test.ensuretemp('MCAD') def pytest_generate_tests(metafunc): if "modpath" in metafunc.funcargnames: + args1 = [] + args2 = [] for fpath, modnames in collect_test_modules().items(): basename = os.path.splitext(os.path.split(str(fpath))[1])[0] - #os.system("cp %s %s/" % (fpath, temppath)) if "modname" in metafunc.funcargnames: for modname in modnames: - print modname - metafunc.addcall(id=basename+"/"+modname, funcargs=dict(modname=modname, modpath=fpath)) + args2.append([fpath, modname]) else: - metafunc.addcall(id=os.path.split(str(fpath))[1], funcargs=dict(modpath=fpath)) + args1.append(fpath) + if "modname" in metafunc.funcargnames: + metafunc.parametrize(["modpath", "modname"], args2) + else: + metafunc.parametrize("modpath", args1) def test_module_compile(modname, modpath): tempname = modpath.basename + '-' + modname + '.scad' @@ -29,23 +33,21 @@ use <%s> %s(); """ % (modpath, modname) - print code + print(code) f.write(code) f.flush() - output = call_openscad(path=fpath, stlpath=stlpath, timeout=15) - print output + output = call_openscad(path=fpath, stlpath=stlpath, timeout=60) + print(output) assert output[0] is 0 for s in ("warning", "error"): - assert s not in output[2].strip().lower() + assert s not in output[2].strip().lower().decode("utf-8") assert len(stlpath.readlines()) > 2 def test_file_compile(modpath): stlpath = temppath.join(modpath.basename + "-test.stl") output = call_openscad(path=modpath, stlpath=stlpath) - print output + print(output) assert output[0] is 0 for s in ("warning", "error"): - assert s not in output[2].strip().lower() + assert s not in output[2].strip().lower().decode("utf-8") assert len(stlpath.readlines()) == 2 - - diff --git a/openscad_utils.py b/openscad_utils.py index 00d8dd9..c4a0880 100644 --- a/openscad_utils.py +++ b/openscad_utils.py @@ -1,4 +1,4 @@ -import py, re, os, signal, time, commands, sys +import py, re, os, signal, time, subprocess, sys from subprocess import Popen, PIPE mod_re = (r"\bmodule\s+(", r")\s*\(\s*") @@ -17,11 +17,11 @@ def extract_func_names(fpath, name_re=r"\w+"): def collect_test_modules(dirpath=None): dirpath = dirpath or py.path.local("./") - print "Collecting openscad test module names" + print("Collecting openscad test module names") test_files = {} for fpath in dirpath.visit('*.scad'): - #print fpath + #print(fpath) modules = extract_mod_names(fpath, r"test\w*") #functions = extract_func_names(fpath, r"test\w*") test_files[fpath] = modules @@ -32,20 +32,20 @@ class Timeout(Exception): pass def call_openscad(path, stlpath, timeout=5): if sys.platform == 'darwin': exe = 'OpenSCAD.app/Contents/MacOS/OpenSCAD' else: exe = 'openscad' - command = [exe, '-s', str(stlpath), str(path)] - print command + command = [exe, '-o', str(stlpath), str(path)] + print(command) if timeout: try: proc = Popen(command, stdout=PIPE, stderr=PIPE, close_fds=True) calltime = time.time() time.sleep(0.05) - #print calltime + #print(calltime) while True: if proc.poll() is not None: break time.sleep(0.5) - #print time.time() + #print(time.time()) if time.time() > calltime + timeout: raise Timeout() finally: @@ -57,7 +57,7 @@ def call_openscad(path, stlpath, timeout=5): return (proc.returncode,) + proc.communicate() else: - output = commands.getstatusoutput(" ".join(command)) + output = subprocess.getstatusoutput(" ".join(command)).decode("utf-8") return output + ('', '') def parse_output(text): diff --git a/test_docs.py b/test_docs.py index cbf9b11..ff5c188 100644 --- a/test_docs.py +++ b/test_docs.py @@ -4,15 +4,17 @@ import os.path dirpath = py.path.local("./") def pytest_generate_tests(metafunc): + names = [] if "filename" in metafunc.funcargnames: for fpath in dirpath.visit('*.scad'): - metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename)) + names.append(fpath.basename) for fpath in dirpath.visit('*.py'): name = fpath.basename if not (name.startswith('test_') or name.startswith('_')): - metafunc.addcall(id=fpath.basename, funcargs=dict(filename=fpath.basename)) + names.append(name) + metafunc.parametrize("filename", names) def test_README(filename): - README = dirpath.join('README').read() + README = dirpath.join('README.markdown').read() assert filename in README