from . import conversions
from .file_formats import FileFormats


class FileConverter(object):

    def get_conversion(self, source_format, target_format):

        return {
            'application/pdf': conversions.NoOp,
            'image/jpeg': conversions.JpegToPdf,
            'image/png': conversions.PngToPdf,
            'image/gif': conversions.GifToPdf,
            'image/tiff': conversions.TiffToPdf,
            'text/plain': conversions.TextToPdf,
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document': conversions.DocxToPdf,
            'application/msword': conversions.DocToPdf,
            'application/vnd.openxmlformats-officedocument.presentationml.presentation': conversions.PptxToPdf,
            'application/vnd.ms-powerpoint': conversions.PptToPdf,
            'application/vnd.oasis.opendocument.text': conversions.OdtToPdf,
            'application/rtf': conversions.RtfToPdf,
        }[source_format]()

from . import conversions
from .file_formats import FileFormats


class FileConverter(object):

    def get_conversion(self, source_format, target_format):

        return {
            FileFormats.PDF: conversions.NoOp,
            FileFormats.JPEG: conversions.JpegToPdf,
            FileFormats.PNG: conversions.PngToPdf,
            FileFormats.GIF: conversions.GifToPdf,
            FileFormats.TIFF: conversions.TiffToPdf,
            FileFormats.TXT: conversions.TextToPdf,
            FileFormats.DOCX: conversions.DocxToPdf,
            FileFormats.DOC: conversions.DocToPdf,
            FileFormats.PPTX: conversions.PptxToPdf,
            FileFormats.PPT: conversions.PptToPdf,
            FileFormats.ODT: conversions.OdtToPdf,
            FileFormats.RTF: conversions.RtfToPdf,
        }[source_format]()

Fix how we find conversion to use file formats
Fix how we find conversion to use file formats

  from . import conversions
  from .file_formats import FileFormats
  
  
  class FileConverter(object):
  
      def get_conversion(self, source_format, target_format):
  
          return {
-             'application/pdf': conversions.NoOp,
+             FileFormats.PDF: conversions.NoOp,
-             'image/jpeg': conversions.JpegToPdf,
+             FileFormats.JPEG: conversions.JpegToPdf,
-             'image/png': conversions.PngToPdf,
+             FileFormats.PNG: conversions.PngToPdf,
-             'image/gif': conversions.GifToPdf,
+             FileFormats.GIF: conversions.GifToPdf,
-             'image/tiff': conversions.TiffToPdf,
+             FileFormats.TIFF: conversions.TiffToPdf,
-             'text/plain': conversions.TextToPdf,
-             'application/vnd.openxmlformats-officedocument.wordprocessingml.document': conversions.DocxToPdf,
-             'application/msword': conversions.DocToPdf,
-             'application/vnd.openxmlformats-officedocument.presentationml.presentation': conversions.PptxToPdf,
-             'application/vnd.ms-powerpoint': conversions.PptToPdf,
-             'application/vnd.oasis.opendocument.text': conversions.OdtToPdf,
-             'application/rtf': conversions.RtfToPdf,
+             FileFormats.TXT: conversions.TextToPdf,
+             FileFormats.DOCX: conversions.DocxToPdf,
+             FileFormats.DOC: conversions.DocToPdf,
+             FileFormats.PPTX: conversions.PptxToPdf,
+             FileFormats.PPT: conversions.PptToPdf,
+             FileFormats.ODT: conversions.OdtToPdf,
+             FileFormats.RTF: conversions.RtfToPdf,
          }[source_format]()
  
Fix how we find conversion to use file formats
## Code Before:
from . import conversions
from .file_formats import FileFormats


class FileConverter(object):

    def get_conversion(self, source_format, target_format):

        return {
            'application/pdf': conversions.NoOp,
            'image/jpeg': conversions.JpegToPdf,
            'image/png': conversions.PngToPdf,
            'image/gif': conversions.GifToPdf,
            'image/tiff': conversions.TiffToPdf,
            'text/plain': conversions.TextToPdf,
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document': conversions.DocxToPdf,
            'application/msword': conversions.DocToPdf,
            'application/vnd.openxmlformats-officedocument.presentationml.presentation': conversions.PptxToPdf,
            'application/vnd.ms-powerpoint': conversions.PptToPdf,
            'application/vnd.oasis.opendocument.text': conversions.OdtToPdf,
            'application/rtf': conversions.RtfToPdf,
        }[source_format]()

## Instruction:
Fix how we find conversion to use file formats
## Code After:
from . import conversions
from .file_formats import FileFormats


class FileConverter(object):

    def get_conversion(self, source_format, target_format):

        return {
            FileFormats.PDF: conversions.NoOp,
            FileFormats.JPEG: conversions.JpegToPdf,
            FileFormats.PNG: conversions.PngToPdf,
            FileFormats.GIF: conversions.GifToPdf,
            FileFormats.TIFF: conversions.TiffToPdf,
            FileFormats.TXT: conversions.TextToPdf,
            FileFormats.DOCX: conversions.DocxToPdf,
            FileFormats.DOC: conversions.DocToPdf,
            FileFormats.PPTX: conversions.PptxToPdf,
            FileFormats.PPT: conversions.PptToPdf,
            FileFormats.ODT: conversions.OdtToPdf,
            FileFormats.RTF: conversions.RtfToPdf,
        }[source_format]()
