add umlauts handling for paths 2 openscad (fix fails for filenames

containing äöüÄÖÜß)
This commit is contained in:
Mario Voigt 2021-12-25 20:55:49 +01:00
parent 23141d82a0
commit ac721bf89f

View File

@ -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 = ""