From ac721bf89fc590622605018b6acc8a5f4b7d5a1e Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 25 Dec 2021 20:55:49 +0100 Subject: [PATCH] =?UTF-8?q?add=20umlauts=20handling=20for=20paths=202=20op?= =?UTF-8?q?enscad=20(fix=20fails=20for=20filenames=20containing=20=C3=A4?= =?UTF-8?q?=C3=B6=C3=BC=C3=84=C3=96=C3=9C=C3=9F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paths_to_openscad/paths_to_openscad.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/extensions/fablabchemnitz/paths_to_openscad/paths_to_openscad.py b/extensions/fablabchemnitz/paths_to_openscad/paths_to_openscad.py index 7fe932ee..f478d049 100644 --- a/extensions/fablabchemnitz/paths_to_openscad/paths_to_openscad.py +++ b/extensions/fablabchemnitz/paths_to_openscad/paths_to_openscad.py @@ -412,6 +412,32 @@ def msg_extrude_by_hull_and_paths(id, prefix): return msg +def remove_umlaut(string): + """ + Removes umlauts from strings and replaces them with the letter+e convention + :param string: string to remove umlauts from + :return: unumlauted string + """ + u = 'ü'.encode() + U = 'Ü'.encode() + a = 'ä'.encode() + A = 'Ä'.encode() + o = 'ö'.encode() + O = 'Ö'.encode() + ss = 'ß'.encode() + + string = string.encode() + string = string.replace(u, b'ue') + string = string.replace(U, b'Ue') + string = string.replace(a, b'ae') + string = string.replace(A, b'Ae') + string = string.replace(o, b'oe') + string = string.replace(O, b'Oe') + string = string.replace(ss, b'ss') + + string = string.decode('utf-8') + return string + class PathsToOpenSCAD(inkex.EffectExtension): def add_arguments(self, pars): @@ -1319,6 +1345,7 @@ module chamfer_sphere(rad=chamfer, res=chamfer_fn) # Remove all punctuation except underscore. badchars = string.punctuation.replace("_", "") + " " name = re.sub("[" + badchars + "]", "_", name) + name = remove_umlaut(name) self.outfile.write("\nmodule %s(h)\n{\n" % name) mi = ""