old_contents: # utilities.language_parser
  # coding=utf-8
  
  from __future__ import unicode_literals
  import yvs.shared as shared
  from HTMLParser import HTMLParser
  
  
  # Finds on the YouVersion website the language name associated with the given
  # language code
  class LanguageParser(HTMLParser):
  
      # Associates the given language ID with this parser instance
      def __init__(self, language_id):
          HTMLParser.__init__(self)
          self.language_url_base = '/languages/{}'.format(language_id)
  
      # Resets parser variables (implicitly called on instantiation)
      def reset(self):
          HTMLParser.reset(self)
          self.depth = 0
          self.in_language = False
          self.language_depth = 0
          self.language_name = None
          self.language_name_parts = []
  
      # Detects the start of a language link
      def handle_starttag(self, tag, attrs):
          attr_dict = dict(attrs)
          self.depth += 1
          if self.language_url_base in attr_dict['href']:
              self.in_language = True
              self.language_depth = self.depth
  
      # Detects the end of a language link
      def handle_endtag(self, tag):
          if self.in_language and self.depth == self.language_depth:
              self.in_language = False
              self.language_name = ''.join(self.language_name_parts).strip()
              # Empty the list containing the language name parts
              del self.language_name_parts[:]
              # Stop parsing HTML now that the language name has been found
          self.depth -= 1
  
      # Handles the language name contained within the current language link
      def handle_data(self, content):
          if self.in_language:
              self.language_name_parts.append(content)
  
      # Handles all HTML entities within the language name
      def handle_charref(self, name):
          if self.in_language:
              char = shared.eval_html_charref(name)
              self.language_name_parts.append(char)
  
  
  # Retrieves the language with
  def get_language_name(language_id):
  
      language_id = language_id.replace('-', '_')
  
      page_html = shared.get_url_content(
          'https://www.bible.com/languages'.format(language_id))
  
      parser = LanguageParser(language_id)
      parser.feed(page_html)
  
      return parser.language_name
  
new_contents: # utilities.language_parser
  # coding=utf-8
  
  from __future__ import unicode_literals
  import yvs.shared as shared
  from HTMLParser import HTMLParser
  
  
  # Finds on the YouVersion website the language name associated with the given
  # language code
  class LanguageParser(HTMLParser):
  
      # Associates the given language ID with this parser instance
      def __init__(self, language_id):
          HTMLParser.__init__(self)
          self.language_url_suffix = '/languages/{}'.format(language_id)
  
      # Resets parser variables (implicitly called on instantiation)
      def reset(self):
          HTMLParser.reset(self)
          self.depth = 0
          self.in_language = False
          self.language_depth = 0
          self.language_name = None
          self.language_name_parts = []
  
      # Detects the start of a language link
      def handle_starttag(self, tag, attrs):
          attr_dict = dict(attrs)
          self.depth += 1
          if attr_dict['href'].endswith(self.language_url_suffix):
              self.in_language = True
              self.language_depth = self.depth
  
      # Detects the end of a language link
      def handle_endtag(self, tag):
          if self.in_language and self.depth == self.language_depth:
              self.in_language = False
              self.language_name = ''.join(self.language_name_parts).strip()
              # Empty the list containing the language name parts
              del self.language_name_parts[:]
              # Stop parsing HTML now that the language name has been found
          self.depth -= 1
  
      # Handles the language name contained within the current language link
      def handle_data(self, content):
          if self.in_language:
              self.language_name_parts.append(content)
  
      # Handles all HTML entities within the language name
      def handle_charref(self, name):
          if self.in_language:
              char = shared.eval_html_charref(name)
              self.language_name_parts.append(char)
  
  
  # Retrieves the language with
  def get_language_name(language_id):
  
      language_id = language_id.replace('-', '_')
  
      page_html = shared.get_url_content(
          'https://www.bible.com/languages'.format(language_id))
  
      parser = LanguageParser(language_id)
      parser.feed(page_html)
  
      return parser.language_name
  
subject: Fix bug where language parser would return incorrect name