NEW: added new toolbox library to parse filenames from path
This commit is contained in:
parent
5aae277ec2
commit
967a028106
|
@ -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
|
Loading…
Reference in New Issue