fttlib


Namefttlib JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/brondavies/filetypetranslator
SummaryA library of helper methods for your Python project to get mime types and general file category
upload_time2023-11-10 00:26:18
maintainer
docs_urlNone
authorBron Davies
requires_python
license
keywords file type mime mapping path inspection upload download email ftt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ![FTT Logo](https://raw.githubusercontent.com/brondavies/filetypetranslator/master/ftt-icon.png) File Type Translator (FTT)

A library of helper methods for your Python project to get [mime types](https://en.wikipedia.org/wiki/Media_type) and general file category

# Releases
Available as a [pypi package](https://pypi.org/packages/fttlib)
#### 1.1.5 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types
#### 1.1.3 - Updated sources, Notably the mime type for .js is now text/javascript instead of application/javascript according to the [IANA standard specification](https://www.iana.org/assignments/media-types/application/javascript)
#### 1.1.2 - Initial python release

# Examples

#### Import the library

```python
from FTTLib import FTT
```

####  When you need to know the mime type of a file based on its extension.

```python
mimeType = FTT.getMimeType("Path/To/My/File.doc")
print(mimeType)

mimeType = FTT.getMimeType("Path/To/My/File.docx")
print(mimeType)

>  application/msword
>  application/vnd.openxmlformats-officedocument.wordprocessingml.document
```

####  When you need to know the file type category of a file based on its extension.

```python
category = FTT.getFileCategory("Path/To/My/File.docx")
print(category)

category = FTT.getFileCategory("Path/To/My/File.jpg")
print(category)

>  FileCategory.Document
>  FileCategory.Image
```

####  When you need to know the preferred file extension for a file based on its mime type.

```python
string[] extensions = FTT.getMimeTypeFileExtensions("text/csv")
print(extensions[0])

>  csv
```

# Design

This library is designed along the following tenets:

* No external dependencies
* No file system access
* Small memory footprint
* Simple static methods (no extension methods and no instantiatable classes)
* Case-insensitive
* Portable - works in applications targeting any runtime

# File Categories

File media types are broken down into relatively few categories.  Sub-categories may be considered in a future release according to information on [Wikipedia](https://en.wikipedia.org/wiki/List_of_file_formats)  Here are the guidelines that determine a file's category

* Archive: any file that can be extracted into several files
* Audio: any file that can only contain an audio stream
* Binary: any file that is unclassified or does not have a text representation
* Code: any file that contains instructions that are compilable or machine-readable
* Document: any file that is designed for conveying structured information between people
* Image: any file that can only contain a single image or series of images
* PDF: any file that is considered a document archive format
* Presentation: any file that is designed for electronic presentations consisting of a series of separate pages or slides
* Spreadsheet: any file in which data is arranged in rows and columns and can be manipulated and used in calculations
* Text: any file that is not classified under another category and is not binary
* Video: any file that is designed to be a container for a video stream

# Known Limitations

* Even though a mime type to file extension mapping is not necessarily one-to-one, the most common should be returned by the library
* This library does not provide file sniffing capabilities - in other words, if you have a file and you want to verify the contents are of a specific type, look elsewhere. FTT only uses the file name with an extension.  That capability may be added in a future release.
* The only file categories presently considered are Archive, Audio, Binary, Code, Document, Image, PDF, Presentation, Spreadsheet, Text, and Video.  Binary is the default if there is no match in the database.

# Sources

While it is unrealistic to expect this library to provide a comprehensive list with *all* the file types the world has to offer, it would be nice if we could get close.  Generally, if the file type is even remotely common, it is listed in one of the sources.  You can [submit a bug report](https://github.com/brondavies/filetypetranslator/issues/new) for a file type that is missing or that you think should be added.  You will have to include a reputable source as well.

### Information sources for this library are provided through the following and in order of preference:

1. http://www.iana.org/assignments/media-types/media-types.xhtml
1. https://gitlab.freedesktop.org/xdg/shared-mime-info
1. https://cdn.rawgit.com/jshttp/mime-db/master/db.json
1. http://www.file-extensions.org/



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/brondavies/filetypetranslator",
    "name": "fttlib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "file,type,mime,mapping,path,inspection,upload,download,email,FTT",
    "author": "Bron Davies",
    "author_email": "bron@brontech.com",
    "download_url": "https://files.pythonhosted.org/packages/94/8a/a007db31843aa902119f6ee7a0efbc7c2a3f2f3c65df4859c94444f74a32/fttlib-1.1.5.tar.gz",
    "platform": null,
    "description": "# ![FTT Logo](https://raw.githubusercontent.com/brondavies/filetypetranslator/master/ftt-icon.png) File Type Translator (FTT)\n\nA library of helper methods for your Python project to get [mime types](https://en.wikipedia.org/wiki/Media_type) and general file category\n\n# Releases\nAvailable as a [pypi package](https://pypi.org/packages/fttlib)\n#### 1.1.5 - Updated sources, adds many modern file types and updates/eliminates some legacy mime types\n#### 1.1.3 - Updated sources, Notably the mime type for .js is now text/javascript instead of application/javascript according to the [IANA standard specification](https://www.iana.org/assignments/media-types/application/javascript)\n#### 1.1.2 - Initial python release\n\n# Examples\n\n#### Import the library\n\n```python\nfrom FTTLib import FTT\n```\n\n####  When you need to know the mime type of a file based on its extension.\n\n```python\nmimeType = FTT.getMimeType(\"Path/To/My/File.doc\")\nprint(mimeType)\n\nmimeType = FTT.getMimeType(\"Path/To/My/File.docx\")\nprint(mimeType)\n\n>  application/msword\n>  application/vnd.openxmlformats-officedocument.wordprocessingml.document\n```\n\n####  When you need to know the file type category of a file based on its extension.\n\n```python\ncategory = FTT.getFileCategory(\"Path/To/My/File.docx\")\nprint(category)\n\ncategory = FTT.getFileCategory(\"Path/To/My/File.jpg\")\nprint(category)\n\n>  FileCategory.Document\n>  FileCategory.Image\n```\n\n####  When you need to know the preferred file extension for a file based on its mime type.\n\n```python\nstring[] extensions = FTT.getMimeTypeFileExtensions(\"text/csv\")\nprint(extensions[0])\n\n>  csv\n```\n\n# Design\n\nThis library is designed along the following tenets:\n\n* No external dependencies\n* No file system access\n* Small memory footprint\n* Simple static methods (no extension methods and no instantiatable classes)\n* Case-insensitive\n* Portable - works in applications targeting any runtime\n\n# File Categories\n\nFile media types are broken down into relatively few categories.  Sub-categories may be considered in a future release according to information on [Wikipedia](https://en.wikipedia.org/wiki/List_of_file_formats)  Here are the guidelines that determine a file's category\n\n* Archive: any file that can be extracted into several files\n* Audio: any file that can only contain an audio stream\n* Binary: any file that is unclassified or does not have a text representation\n* Code: any file that contains instructions that are compilable or machine-readable\n* Document: any file that is designed for conveying structured information between people\n* Image: any file that can only contain a single image or series of images\n* PDF: any file that is considered a document archive format\n* Presentation: any file that is designed for electronic presentations consisting of a series of separate pages or slides\n* Spreadsheet: any file in which data is arranged in rows and columns and can be manipulated and used in calculations\n* Text: any file that is not classified under another category and is not binary\n* Video: any file that is designed to be a container for a video stream\n\n# Known Limitations\n\n* Even though a mime type to file extension mapping is not necessarily one-to-one, the most common should be returned by the library\n* This library does not provide file sniffing capabilities - in other words, if you have a file and you want to verify the contents are of a specific type, look elsewhere. FTT only uses the file name with an extension.  That capability may be added in a future release.\n* The only file categories presently considered are Archive, Audio, Binary, Code, Document, Image, PDF, Presentation, Spreadsheet, Text, and Video.  Binary is the default if there is no match in the database.\n\n# Sources\n\nWhile it is unrealistic to expect this library to provide a comprehensive list with *all* the file types the world has to offer, it would be nice if we could get close.  Generally, if the file type is even remotely common, it is listed in one of the sources.  You can [submit a bug report](https://github.com/brondavies/filetypetranslator/issues/new) for a file type that is missing or that you think should be added.  You will have to include a reputable source as well.\n\n### Information sources for this library are provided through the following and in order of preference:\n\n1. http://www.iana.org/assignments/media-types/media-types.xhtml\n1. https://gitlab.freedesktop.org/xdg/shared-mime-info\n1. https://cdn.rawgit.com/jshttp/mime-db/master/db.json\n1. http://www.file-extensions.org/\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A library of helper methods for your Python project to get mime types and general file category",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/brondavies/filetypetranslator"
    },
    "split_keywords": [
        "file",
        "type",
        "mime",
        "mapping",
        "path",
        "inspection",
        "upload",
        "download",
        "email",
        "ftt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "475a9a3d9e0932b590d4d55b000e8cc1d0c923d371d134154b55a22ce2709202",
                "md5": "49da6dd3fbf9126b0a5fe5e03453ca38",
                "sha256": "c080bdcf551c60c901142a90c726ecda45827858e178e4a3ad1e374ce406c4c5"
            },
            "downloads": -1,
            "filename": "fttlib-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "49da6dd3fbf9126b0a5fe5e03453ca38",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 61289,
            "upload_time": "2023-11-10T00:26:16",
            "upload_time_iso_8601": "2023-11-10T00:26:16.791204Z",
            "url": "https://files.pythonhosted.org/packages/47/5a/9a3d9e0932b590d4d55b000e8cc1d0c923d371d134154b55a22ce2709202/fttlib-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "948aa007db31843aa902119f6ee7a0efbc7c2a3f2f3c65df4859c94444f74a32",
                "md5": "f32b11e167c19b3203f406c14d776f45",
                "sha256": "8424e428be13c88e1441a8c6f230a73a60ca9a28465c3a8e4a8e31bf318a35c9"
            },
            "downloads": -1,
            "filename": "fttlib-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f32b11e167c19b3203f406c14d776f45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 61603,
            "upload_time": "2023-11-10T00:26:18",
            "upload_time_iso_8601": "2023-11-10T00:26:18.621971Z",
            "url": "https://files.pythonhosted.org/packages/94/8a/a007db31843aa902119f6ee7a0efbc7c2a3f2f3c65df4859c94444f74a32/fttlib-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-10 00:26:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brondavies",
    "github_project": "filetypetranslator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fttlib"
}
        
Elapsed time: 0.15423s