diff --git a/pylot/core/util/utils.py b/pylot/core/util/utils.py new file mode 100644 index 00000000..fd1fa215 --- /dev/null +++ b/pylot/core/util/utils.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# +# -*- coding: utf-8 -*- + +import re + +def fnConstructor(s): + + badchars = re.compile(r'[^A-Za-z0-9_. ]+|^\.|\.$|^ | $|^$') + badsuffix = re.compile(r'(aux|com[1-9]|con|lpt[1-9]|prn)(\.|$)') + + fn = badchars.sub('_', s) + + if badsuffix.match(fn): + fn = '_' + fn + return fn