def parsedoc(path, format=None):
 if isinstance(path, basestring):
  if ((format == 'pdf') or path.endswith('.pdf')):
   return parsepdf(path)
  if ((format == 'docx') or path.endswith('.docx')):
   return parsedocx(path)
  if ((format == 'html') or path.endswith(('.htm', '.html', '.xhtml'))):
   return parsehtml(path)
 for f in (parsepdf, parsedocx, parsehtml):
  try:
   return f(path)
  except:
   pass

def parsedoc ( path , format = None ) : if isinstance ( path , basestring ) : if ( ( format == 'pdf' ) or path . endswith ( '.pdf' ) ) : return parsepdf ( path ) if ( ( format == 'docx' ) or path . endswith ( '.docx' ) ) : return parsedocx ( path ) if ( ( format == 'html' ) or path . endswith ( ( '.htm' , '.html' , '.xhtml' ) ) ) : return parsehtml ( path ) for f in ( parsepdf , parsedocx , parsehtml ) : try : return f ( path ) except : pass
returns the content as a unicode string from the given document .