def truncate_name(name, length=None, hash_len=4):
 if ((length is None) or (len(name) <= length)):
  return name
 hash = md5_constructor(name).hexdigest()[:hash_len]
 return ('%s%s' % (name[:(length - hash_len)], hash))

def truncate_name ( name , length = None , hash_len = 4 ) : if ( ( length is None ) or ( len ( name ) <= length ) ) : return name hash = md5_constructor ( name ) . hexdigest ( ) [ : hash_len ] return ( '%s%s' % ( name [ : ( length - hash_len ) ] , hash ) )
shortens a string to a repeatable mangled version with the given length .