+ re = SanitizeHook()
+ if not hasattr(picard.util, "_re_slashes"):
+ # Harder to globally monkey patch this picard.util function on newer
+ # Picard, so instead we patch it in the two modules which import it.
+ orig_sanitize_filename = picard.util.sanitize_filename
+ def sanitize_filename_hook(string, **kwargs):
+ return orig_sanitize_filename(re.sub(None, string), **kwargs)
+
+ picard.util.scripttofilename.sanitize_filename = sanitize_filename_hook
+ picard.util.textencoding.sanitize_filename = sanitize_filename_hook
+ else:
+ # On older picard we can monkey patch the underlying re object.
+ picard.util._re_slashes = re
+