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