def elide_filename(filename, length):
 elidestr = '...'
 if (length < len(elidestr)):
  raise ValueError('length must be greater or equal to 3')
 if (len(filename) <= length):
  return filename
 length -= len(elidestr)
 left = (length // 2)
 right = (length - left)
 if (right == 0):
  return (filename[:left] + elidestr)
 else:
  return ((filename[:left] + elidestr) + filename[(- right):])

def elide_filename ( filename , length ) : elidestr = '...' if ( length < len ( elidestr ) ) : raise ValueError ( 'length must be greater or equal to 3' ) if ( len ( filename ) <= length ) : return filename length -= len ( elidestr ) left = ( length // 2 ) right = ( length - left ) if ( right == 0 ) : return ( filename [ : left ] + elidestr ) else : return ( ( filename [ : left ] + elidestr ) + filename [ ( - right ) : ] )
elide a filename to the given length .