def basenames(words): for w in words: dir, file = pathsplit(w, '') base, dot, suffix = util.strrpartition(file, '.') if dot == '': base = suffix yield dir + base
def pathsplit(path, default='./'): """ Splits a path into dirpart, filepart on the last slash. If there is no slash, dirpart is ./ """ dir, slash, file = util.strrpartition(path, '/') if dir == '': return default, file return dir + slash, file
def suffixes(words): for w in words: dir, file = pathsplit(w) base, dot, suffix = util.strrpartition(file, '.') if base != '': yield dot + suffix