"""Module for checking glossary links found within Markdown conversions."""

from utils.errors.CouldNotFindGlossaryTerm import CouldNotFindGlossaryTerm
from topics.models import GlossaryTerm


def check_converter_glossary_links(glossary_links, md_file_path):
    """Process glossary links found by Markdown converter.

    Args:
        glossary_links: Dictionary of glossary links (dict).
    """
    for term in glossary_links.keys():
        if not GlossaryTerm.objects.filter(slug=term).exists():
            raise CouldNotFindGlossaryTerm(term, md_file_path)

"""Module for checking glossary links found within Markdown conversions."""

from utils.errors.CouldNotFindGlossaryTerm import CouldNotFindGlossaryTerm
from topics.models import GlossaryTerm


def check_converter_glossary_links(glossary_links, md_file_path):
    """Process glossary links found by Markdown converter.

    Args:
        glossary_links: Dictionary of glossary links (dict).
    """
    for term in glossary_links.keys():
        try:
            GlossaryTerm.objects.get(slug=term)
        except ObjectDoesNotExist:
            raise CouldNotFindGlossaryTerm(term, md_file_path)

Use clearer Django method and exception for glossary term checking
Use clearer Django method and exception for glossary term checking

  """Module for checking glossary links found within Markdown conversions."""
  
  from utils.errors.CouldNotFindGlossaryTerm import CouldNotFindGlossaryTerm
  from topics.models import GlossaryTerm
  
  
  def check_converter_glossary_links(glossary_links, md_file_path):
      """Process glossary links found by Markdown converter.
  
      Args:
          glossary_links: Dictionary of glossary links (dict).
      """
      for term in glossary_links.keys():
+         try:
-         if not GlossaryTerm.objects.filter(slug=term).exists():
+             GlossaryTerm.objects.get(slug=term)
+         except ObjectDoesNotExist:
              raise CouldNotFindGlossaryTerm(term, md_file_path)
  
Use clearer Django method and exception for glossary term checking
## Code Before:
"""Module for checking glossary links found within Markdown conversions."""

from utils.errors.CouldNotFindGlossaryTerm import CouldNotFindGlossaryTerm
from topics.models import GlossaryTerm


def check_converter_glossary_links(glossary_links, md_file_path):
    """Process glossary links found by Markdown converter.

    Args:
        glossary_links: Dictionary of glossary links (dict).
    """
    for term in glossary_links.keys():
        if not GlossaryTerm.objects.filter(slug=term).exists():
            raise CouldNotFindGlossaryTerm(term, md_file_path)

## Instruction:
Use clearer Django method and exception for glossary term checking
## Code After:
"""Module for checking glossary links found within Markdown conversions."""

from utils.errors.CouldNotFindGlossaryTerm import CouldNotFindGlossaryTerm
from topics.models import GlossaryTerm


def check_converter_glossary_links(glossary_links, md_file_path):
    """Process glossary links found by Markdown converter.

    Args:
        glossary_links: Dictionary of glossary links (dict).
    """
    for term in glossary_links.keys():
        try:
            GlossaryTerm.objects.get(slug=term)
        except ObjectDoesNotExist:
            raise CouldNotFindGlossaryTerm(term, md_file_path)
