code: def addextension(path, ext=None):
      
      if ext:
          if '*' in path:
              return path
          elif os.path.splitext(path)[1]:
              return path
          else:
              if not ext.startswith('.'):
                  ext = '.'+ext
              if not path.endswith(ext):
                  if not path.endswith(os.path.sep):
                      path += os.path.sep
                  return path + '*' + ext
              else:
                  return path
      else:
          return path
docs: Helper function for handling of paths given separately passed file extensions.