def _parser_dispatch(flavor):
 valid_parsers = list(_valid_parsers.keys())
 if (flavor not in valid_parsers):
  raise ValueError(('%r is not a valid flavor, valid flavors are %s' % (flavor, valid_parsers)))
 if (flavor in ('bs4', 'html5lib')):
  if (not _HAS_HTML5LIB):
   raise ImportError('html5lib not found, please install it')
  if (not _HAS_BS4):
   raise ImportError('BeautifulSoup4 (bs4) not found, please install it')
  import bs4
  if (bs4.__version__ == LooseVersion('4.2.0')):
   raise ValueError("You're using a version of BeautifulSoup4 (4.2.0) that has been known to cause problems on certain operating systems such as Debian. Please install a version of BeautifulSoup4 != 4.2.0, both earlier and later releases will work.")
 elif (not _HAS_LXML):
  raise ImportError('lxml not found, please install it')
 return _valid_parsers[flavor]

def _parser_dispatch ( flavor ) : valid_parsers = list ( _valid_parsers . keys ( ) ) if ( flavor not in valid_parsers ) : raise ValueError ( ( '%r is not a valid flavor, valid flavors are %s' % ( flavor , valid_parsers ) ) ) if ( flavor in ( 'bs4' , 'html5lib' ) ) : if ( not _HAS_HTML5LIB ) : raise ImportError ( 'html5lib not found, please install it' ) if ( not _HAS_BS4 ) : raise ImportError ( 'BeautifulSoup4 (bs4) not found, please install it' ) import bs4 if ( bs4 . __version__ == LooseVersion ( '4.2.0' ) ) : raise ValueError ( "You're using a version of BeautifulSoup4 (4.2.0) that has been known to cause problems on certain operating systems such as Debian. Please install a version of BeautifulSoup4 != 4.2.0, both earlier and later releases will work." ) elif ( not _HAS_LXML ) : raise ImportError ( 'lxml not found, please install it' ) return _valid_parsers [ flavor ]
choose the parser based on the input flavor .