NEW: added new toolbox library to parse filenames from path

This commit is contained in:
JohnE 2015-08-25 02:36:17 -07:00
parent 5aae277ec2
commit 967a028106
1 changed files with 40 additions and 0 deletions

40
libs/toolbox.py Normal file
View File

@ -0,0 +1,40 @@
#
#
#
import re
#
class ToolBox:
"""
Various tools
"""
#
# -c tablename:colName,colName2 userstable:names,ages
# -b tablename:colName,colName2 userstable:names,ages
#
# TODO: change the split to a smart regex, instead of spliting on space
#
@staticmethod
def parseColParams(param):
tblCols = {}
tables = param.split()
for table in tables:
cols = table.split(':')
tblCols[cols[0]] = cols[1].split(',')
return tblCols
#
@staticmethod
def parseFilename(fqfilepath):
results = re.search(r'.*[\\/](\S*)\..*', fqfilepath)
if len(results.group(1)) != 0:
filename = results.group(1)
return filename
#
@staticmethod
def parseFilenameIncExt(fqfilepath):
results = re.search(r'.*[\\/](\S*\..*)', fqfilepath)
if len(results.group(1)) != 0:
filename = results.group(1)
return filename