new module utils within package util containing helpers for this and that
This commit is contained in:
parent
dde360d4cc
commit
e4ddb8b55e
16
pylot/core/util/utils.py
Normal file
16
pylot/core/util/utils.py
Normal 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
|
Loading…
Reference in New Issue
Block a user