def default_combine_filenames_generator(filenames, max_length=<NUM_LIT>):
path = None<EOL>names = []<EOL>extension = None<EOL>timestamps = []<EOL>for filename in filenames:<EOL><INDENT>name = os.path.basename(filename)<EOL>if not extension:<EOL><INDENT>extension = os.path.splitext(name)[<NUM_LIT:1>]<EOL><DEDENT>elif os.path.splitext(name)[<NUM_LIT:1>] != extension:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>for each in re.finditer('<STR_LIT>', name):<EOL><INDENT>timestamps.append(int(each.group().replace('<STR_LIT:.>','<STR_LIT>')))<EOL>name = name.replace(each.group(), '<STR_LIT:.>')<EOL><DEDENT>name = os.path.splitext(name)[<NUM_LIT:0>]<EOL>names.append(name)<EOL>if path is None:<EOL><INDENT>path = os.path.dirname(filename)<EOL><DEDENT>else:<EOL><INDENT>if len(os.path.dirname(filename)) < len(path):<EOL><INDENT>path = os.path.dirname(filename)<EOL><DEDENT><DEDENT><DEDENT>new_filename = '<STR_LIT:_>'.join(names)<EOL>if timestamps:<EOL><INDENT>new_filename += "<STR_LIT>" % max(timestamps)<EOL><DEDENT>new_filename = new_filename[:max_length]<EOL>new_filename += extension<EOL>return os.path.join(path, new_filename)<EOL>
Return a new filename to use as the combined file name for a
    bunch of files.
    A precondition is that they all have the same file extension

    Given that the list of files can have different paths, we aim to use the
    most common path.

    Example:
      /somewhere/else/foo.js
      /somewhere/bar.js
      /somewhere/different/too/foobar.js
    The result will be
      /somewhere/foo_bar_foobar.js

    Another thing to note, if the filenames have timestamps in them, combine
    them all and use the highest timestamp.