示例#1
0
  def getAllowedConversionFormatList(source_mimetype):
    """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/vnd.oasis.opendocument.text', 'ODF Text Document'),
     ('application/pdf', 'PDF - Portable Document Format'),
     ...
    ]
    """
    # XXX please never guess extension from mimetype
    output_set = set()
    if "/" in source_mimetype:
      parsed_mimetype_type = parseContentType(source_mimetype).gettype()
      # here `guess_all_extensions` never handles mimetype parameters
      #   (even for `text/plain;charset=UTF-8` which is standard)
      extension_list = mimetypes.guess_all_extensions(parsed_mimetype_type)  # XXX never guess
    else:
      extension_list = [source_mimetype]

    for ext in extension_list:
      for ext, title in mimemapper.getAllowedExtensionList(extension=ext.replace(".", "")):
        if ext in ("fodt", ".fodt"):  # BBB
          output_set.add(("application/vnd.oasis.opendocument.text-flat-xml", title))
          continue
        if ext:
          mimetype, _ = mimetypes.guess_type("a." + ext)  # XXX never guess
          if mimetype:
            output_set.add((mimetype, title))
    return list(output_set)
示例#2
0
    def getAllowedConversionFormatList(source_mimetype):
        """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/vnd.oasis.opendocument.text', 'ODF Text Document'),
     ('application/pdf', 'PDF - Portable Document Format'),
     ...
    ]
    """
        # XXX please never guess extension from mimetype
        output_set = set()
        if "/" in source_mimetype:
            parsed_mimetype_type = parseContentType(source_mimetype).gettype()
            # here `guess_all_extensions` never handles mimetype parameters
            #   (even for `text/plain;charset=UTF-8` which is standard)
            extension_list = mimetypes.guess_all_extensions(
                parsed_mimetype_type)  # XXX never guess
        else:
            extension_list = [source_mimetype]

        for ext in extension_list:
            for ext, title in mimemapper.getAllowedExtensionList(
                    extension=ext.replace(".", "")):
                if ext in ("fodt", ".fodt"):  # BBB
                    output_set.add(
                        ("application/vnd.oasis.opendocument.text-flat-xml",
                         title))
                    continue
                if ext:
                    mimetype, _ = mimetypes.guess_type("a." +
                                                       ext)  # XXX never guess
                    if mimetype:
                        output_set.add((mimetype, title))
        return list(output_set)
示例#3
0
    def getAllowedConversionFormatList(source_mimetype):
        """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/pdf', 'PDF - Portable Document Format'),
     ...
    ]
    """
        source_mimetype = parseContentType(source_mimetype).gettype()
        if source_mimetype in ("text/html", "htm", "html"):
            return [("application/pdf", "PDF - Portable Document Format")]
        return []
示例#4
0
  def getAllowedConversionFormatList(source_mimetype):
    """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('text/plain', 'Plain Text'),
     ...
    ]
    """
    source_mimetype = parseContentType(source_mimetype).gettype()
    if source_mimetype in ("application/pdf", "pdf"):
      return [("text/plain", "Plain Text")]
    return []
示例#5
0
  def getAllowedConversionFormatList(source_mimetype):
    """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/pdf', 'PDF - Portable Document Format'),
     ...
    ]
    """
    source_mimetype = parseContentType(source_mimetype).gettype()
    if source_mimetype in ("text/html", "htm", "html"):
      return [("application/pdf", "PDF - Portable Document Format")]
    return []
示例#6
0
    def getAllowedConversionFormatList(source_mimetype):
        """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('text/plain', 'Plain Text'),
     ...
    ]
    """
        source_mimetype = parseContentType(source_mimetype).gettype()
        if source_mimetype in ("application/pdf", "pdf"):
            return [("text/plain", "Plain Text")]
        return []
示例#7
0
def BBB_guess_extension(mimetype, title=None):
  return {
    # title : extension
    "Flat XML ODF Text Document": ".fodt",
    "MET - OS/2 Metafile": ".met",
    "Microsoft Excel 2007-2013 XML": ".ms.xlsx",
    "Microsoft PowerPoint 2007-2013 XML": ".ms.pptx",
    "Microsoft PowerPoint 2007-2013 XML AutoPlay": ".ms.ppsx",
    "Microsoft Word 2007-2013 XML": ".ms.docx",
  }.get(title, None) or {
    # mediatype : extension
    "application/postscript": ".eps",
    "application/vnd.ms-excel": ".xls",
    "application/vnd.ms-excel.sheet.macroenabled.12": ".xlsm",
    "application/vnd.ms-powerpoint": ".ppt",
    "text/plain": ".txt",
    "image/jpeg": ".jpg",
  }.get(parseContentType(mimetype).gettype(), None) or guess_extension(mimetype)
示例#8
0
def BBB_guess_extension(mimetype, title=None):
    return {
        # title : extension
        "Flat XML ODF Text Document": ".fodt",
        "MET - OS/2 Metafile": ".met",
        "Microsoft Excel 2007-2013 XML": ".ms.xlsx",
        "Microsoft PowerPoint 2007-2013 XML": ".ms.pptx",
        "Microsoft PowerPoint 2007-2013 XML AutoPlay": ".ms.ppsx",
        "Microsoft Word 2007-2013 XML": ".ms.docx",
    }.get(title, None) or {
        # mediatype : extension
        "application/postscript": ".eps",
        "application/vnd.ms-excel": ".xls",
        "application/vnd.ms-excel.sheet.macroenabled.12": ".xlsm",
        "application/vnd.ms-powerpoint": ".ppt",
        "text/plain": ".txt",
        "image/jpeg": ".jpg",
    }.get(parseContentType(mimetype).gettype(),
          None) or guess_extension(mimetype)
示例#9
0
    def getAllowedConversionFormatList(source_mimetype):
        """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/x-asc-text', 'OnlyOffice Text Document'),
     ...
    ]
    """
        source_mimetype = parseContentType(source_mimetype).gettype()
        if source_mimetype in (
                "docx",
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
        ):
            return [("application/x-asc-text", "OnlyOffice Text Document")]
        if source_mimetype in ("docy", "application/x-asc-text"):
            return [(
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
                "Word 2007 Document")]
        if source_mimetype in (
                "xlsx",
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ):
            return [("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet")
                    ]
        if source_mimetype in ("xlsy", "application/x-asc-spreadsheet"):
            return [(
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                "Excel 2007 Spreadsheet")]
        if source_mimetype in (
                "pptx",
                "application/vnd.openxmlformats-officedocument.presentationml.presentation"
        ):
            return [("application/x-asc-presentation",
                     "OnlyOffice Presentation")]
        if source_mimetype in ("ppty", "application/x-asc-presentation"):
            return [(
                "application/vnd.openxmlformats-officedocument.presentationml.presentation",
                "PowerPoint 2007 Presentation")]
        return []
示例#10
0
  def getAllowedConversionFormatList(source_mimetype):
    """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/x-asc-text', 'OnlyOffice Text Document'),
     ...
    ]
    """
    source_mimetype = parseContentType(source_mimetype).gettype()
    if source_mimetype in ("docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"):
      return [("application/x-asc-text", "OnlyOffice Text Document")]
    if source_mimetype in ("docy", "application/x-asc-text"):
      return [("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document")]
    if source_mimetype in ("xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"):
      return [("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet")]
    if source_mimetype in ("xlsy", "application/x-asc-spreadsheet"):
      return [("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet")]
    if source_mimetype in ("pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"):
      return [("application/x-asc-presentation", "OnlyOffice Presentation")]
    if source_mimetype in ("ppty", "application/x-asc-presentation"):
      return [("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation")]
    return []
示例#11
0
  def getAllowedConversionFormatList(source_mimetype):
    """Returns a list content_type and their titles which are supported
    by enabled handlers.

    [('application/x-asc-text', 'OnlyOffice Text Document'),
     ...
    ]
    """
    source_mimetype = parseContentType(source_mimetype).gettype()
    if source_mimetype in ("docy", "application/x-asc-text"):
      return [
        ("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Word 2007 Document"),
        ("application/vnd.oasis.opendocument.text", "ODF Text Document"),
      ]
    if source_mimetype in ("xlsy", "application/x-asc-spreadsheet"):
      return [
        ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Excel 2007 Spreadsheet"),
        ("application/vnd.oasis.opendocument.spreadsheet", "ODF Spreadsheet Document"),
      ]
    if source_mimetype in ("ppty", "application/x-asc-presentation"):
      return [
        ("application/vnd.openxmlformats-officedocument.presentationml.presentation", "PowerPoint 2007 Presentation"),
        ("application/vnd.oasis.opendocument.presentation", "ODF Presentation Document"),
      ]

    get_format_list = OOoHandler.getAllowedConversionFormatList
    format_list = get_format_list(source_mimetype)
    format_list_append = format_list.append
    for f_type, _ in format_list:
      if f_type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
        format_list_append(("application/x-asc-text", "OnlyOffice Text Document"))
        break
      if f_type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
        format_list_append(("application/x-asc-spreadsheet", "OnlyOffice Spreadsheet"))
        break
      if f_type == "application/vnd.openxmlformats-officedocument.presentationml.presentation":
        format_list_append(("application/x-asc-presentation", "OnlyOffice Presentation"))
        break
    return format_list