new module utils within package util containing helpers for this and that

This commit is contained in:
Sebastian Wehling 2014-07-25 14:14:19 +02:00
parent dde360d4cc
commit e4ddb8b55e

16
pylot/core/util/utils.py Normal file
View File

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