diff --git a/libs/toolbox.py b/libs/toolbox.py new file mode 100644 index 0000000..4b5bec1 --- /dev/null +++ b/libs/toolbox.py @@ -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