'see new for what \'spec\' can be.'

def _getbyspec(self, spec):

    res = []
    parts = self.strpath.split(self.sep)
    args = filter(None, spec.split(','))
    append = res.append
    for name in args:
        if (name == 'drive'):
            append(parts[0])
        elif (name == 'dirname'):
            append(self.sep.join(parts[:(-1)]))
        else:
            basename = parts[(-1)]
            if (name == 'basename'):
                append(basename)
            else:
                i = basename.rfind('.')
                if (i == (-1)):
                    (purebasename, ext) = (basename, '')
                else:
                    (purebasename, ext) = (basename[:i], basename[i:])
                if (name == 'purebasename'):
                    append(purebasename)
                elif (name == 'ext'):
                    append(ext)
                else:
                    raise ValueError(('invalid    part    specification    %r' % name))
    return res
