

def filenames_to_uniq(names, new_delim='.'):
    "\n    Given a set of file names, produce a list of names consisting of the\n    uniq parts of the names. This works from the end of the name.  Chunks of\n    the name are split on '.' and '-'.\n\n    For example:\n        A.foo.bar.txt\n        B.foo.bar.txt\n        returns: ['A','B']\n\n        AA.BB.foo.txt\n        CC.foo.txt\n        returns: ['AA.BB','CC']\n\n    >>> filenames_to_uniq('a.foo.bar.txt b.foo.bar.txt'.split())\n    ['a', 'b']\n    >>> filenames_to_uniq('a.b.foo.txt c.foo.txt'.split())\n    ['a.b', 'c']\n\n    "
    name_words = []
    maxlen = 0
    for name in names:
        name_words.append(names.replace('.', ' ').replace('-', ' ').strip().split())
        name_words[(- 1)].reverse()
        if (len(name_words[(- 1)]) > maxlen):
            maxlen = len(name_words[(- 1)])
    common = ([False] * maxlen)
    for i in xrange(maxlen):
        last = None
        same = True
        for nameword in name_words:
            if (i >= len(nameword)):
                same = False
                break
            if (not last):
                last = nameword[i]
            elif (nameword[i] != last):
                same = False
                break
        common[i] = same
    newnames = []
    for nameword in name_words:
        nn = []
        for (i, val) in enumerate(common):
            if ((not val) and (i < len(nameword))):
                nn.append(nameword[i])
        nn.reverse()
        newnames.append(new_delim.join(nn))
    return newnames

dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/support/ngs_utils.py filenames_to_uniq/VarMisuse@36/294 `name`->`names`