Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
File format determination library for Python
|pypi version| |python version| |license|
fleep is a library that determines file format by file signature (also known as "magic number").
You can install fleep using pip. Simply run in CLI:
::
pip install fleep
fleep has main function get() that determines file format. It takes byte sequence (128 bytes are enough) as an argument and returns an instance of class Info with the following arguments:
You may presume that first element in list will be the most suitable.
Also an instance of class Info has the following methods:
There are 3 more functions:
You can find examples in examples folder. There is a simple example:
.. code:: python
import fleep
with open("png_image", "rb") as file:
info = fleep.get(file.read(128))
print(info.type) # prints ['raster-image']
print(info.extension) # prints ['png']
print(info.mime) # prints ['image/png']
print(info.type_matches("raster-image")) # prints True
print(info.extension_matches("gif")) # prints False
print(info.mime_matches("image/png")) # prints True
You can find tests in tests folder. There are results of speed test:
Workstation
Results
Note: 0.0012345 -> time in seconds
+-----------+---------+-----------+-----------+ | Iteration | Minimum | Maximum | Average | +===========+=========+===========+===========+ | 1 | 0.0 | 0.0005312 | 0.0000851 | +-----------+---------+-----------+-----------+ | 2 | 0.0 | 0.0005360 | 0.0000858 | +-----------+---------+-----------+-----------+ | 3 | 0.0 | 0.0005236 | 0.0000837 | +-----------+---------+-----------+-----------+ | 4 | 0.0 | 0.0005035 | 0.0000833 | +-----------+---------+-----------+-----------+ | 5 | 0.0 | 0.0005295 | 0.0000835 | +-----------+---------+-----------+-----------+
There is a list of supported formats (in alphabetical order):
Raster Image:
Raw Image:
Vector Image:
3D Image:
Audio:
Video:
Document:
Archive:
Executable:
Font:
System:
Database:
You can find changelog in CHANGELOG.md file.
This project is licensed under the MIT License.
Mykyta Paliienko - GitHub profile
_
.. _GitHub profile: https://github.com/floyernick
.. |pypi version| image:: https://img.shields.io/badge/pypi-v1.0.1-blue.svg :target: https://pypi.python.org/pypi/fleep .. |python version| image:: https://img.shields.io/badge/python-3-blue.svg .. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg :target: https://github.com/floyernick/fleep/blob/master/LICENSE
FAQs
File format determination library
We found that fleep demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.