def generate_pingback_content(soup, target, max_length, trunc_char='...'):
 link = soup.find('a', href=target)
 content = strip_tags(six.text_type(link.findParent()))
 index = content.index(link.string)
 if (len(content) > max_length):
  middle = (max_length // 2)
  start = (index - middle)
  end = (index + middle)
  if (start <= 0):
   end -= start
   extract = content[0:end]
  else:
   extract = ('%s%s' % (trunc_char, content[start:end]))
  if (end < len(content)):
   extract += trunc_char
  return extract
 return content

def generate_pingback_content ( soup , target , max_length , trunc_char = '...' ) : link = soup . find ( 'a' , href = target ) content = strip_tags ( six . text_type ( link . findParent ( ) ) ) index = content . index ( link . string ) if ( len ( content ) > max_length ) : middle = ( max_length // 2 ) start = ( index - middle ) end = ( index + middle ) if ( start <= 0 ) : end -= start extract = content [ 0 : end ] else : extract = ( '%s%s' % ( trunc_char , content [ start : end ] ) ) if ( end < len ( content ) ) : extract += trunc_char return extract return content
generate a description text for the pingback .