identify

File identification library for Python

https://github.com/pre-commit/identify

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    6 of 139 committers (4.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary

Keywords from Contributors

unit-testing closember templates autopep8 codeformatter formatter gofmt pre-commit-hook yapf distributed
Last synced: 10 months ago · JSON representation

Repository

File identification library for Python

Basic Info
  • Host: GitHub
  • Owner: pre-commit
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 660 KB
Statistics
  • Stars: 281
  • Watchers: 6
  • Forks: 165
  • Open Issues: 4
  • Releases: 0
Created over 9 years ago · Last pushed 10 months ago
Metadata Files
Readme License

README.md

build status pre-commit.ci status

identify

File identification library for Python.

Given a file (or some information about a file), return a set of standardized tags identifying what the file is.

Installation

bash pip install identify

Usage

With a file on disk

If you have an actual file on disk, you can get the most information possible (a superset of all other methods):

```python

from identify import identify identify.tagsfrompath('/path/to/file.py') {'file', 'text', 'python', 'non-executable'} identify.tagsfrompath('/path/to/file-with-shebang') {'file', 'text', 'shell', 'bash', 'executable'} identify.tagsfrompath('/bin/bash') {'file', 'binary', 'executable'} identify.tagsfrompath('/path/to/directory') {'directory'} identify.tagsfrompath('/path/to/symlink') {'symlink'} ```

When using a file on disk, the checks performed are:

  • File type (file, symlink, directory, socket)
  • Mode (is it executable?)
  • File name (mostly based on extension)
  • If executable, the shebang is read and the interpreter interpreted

If you only have the filename

```python

identify.tagsfromfilename('file.py') {'text', 'python'} ```

If you only have the interpreter

```python

identify.tagsfrominterpreter('python3.5') {'python', 'python3'} identify.tagsfrominterpreter('bash') {'shell', 'bash'} identify.tagsfrominterpreter('some-unrecognized-thing') set() ```

As a cli

``` $ identify-cli --help usage: identify-cli [-h] [--filename-only] path

positional arguments: path

optional arguments: -h, --help show this help message and exit --filename-only ```

console $ identify-cli setup.py; echo $? ["file", "non-executable", "python", "text"] 0 $ identify-cli setup.py --filename-only; echo $? ["python", "text"] 0 $ identify-cli wat.wat; echo $? wat.wat does not exist. 1 $ identify-cli wat.wat --filename-only; echo $? 1

Identifying LICENSE files

identify also has an api for determining what type of license is contained in a file. This routine is roughly based on the approaches used by licensee.

The approach that identify uses is as follows:

  1. Strip the copyright line
  2. Normalize all whitespace
  3. Return any exact matches
  4. Return the closest by edit distance (where edit distance < 5%)

To use the api, install via pip install identify[license]

```pycon

from identify import identify identify.license_id('LICENSE') 'MIT' ```

The return value of the license_id function is an SPDX id. Currently licenses are sourced from choosealicense.com.

How it works

A call to tags_from_path does this:

  1. What is the type: file, symlink, directory? If it's not file, stop here.
  2. Is it executable? Add the appropriate tag.
  3. Do we recognize the file extension? If so, add the appropriate tags, stop here. These tags would include binary/text.
  4. Peek at the first X bytes of the file. Use these to determine whether it is binary or text, add the appropriate tag.
  5. If identified as text above, try to read and interpret the shebang, and add appropriate tags.

By design, this means we don't need to partially read files where we recognize the file extension.

Owner

  • Name: pre-commit
  • Login: pre-commit
  • Kind: organization

A framework for managing and maintaining multi-language pre-commit hooks.

GitHub Events

Total
  • Issues event: 14
  • Watch event: 26
  • Delete event: 15
  • Issue comment event: 39
  • Push event: 50
  • Pull request review comment event: 3
  • Pull request review event: 14
  • Pull request event: 75
  • Fork event: 22
  • Create event: 25
Last Year
  • Issues event: 14
  • Watch event: 26
  • Delete event: 15
  • Issue comment event: 39
  • Push event: 50
  • Pull request review comment event: 3
  • Pull request review event: 14
  • Pull request event: 75
  • Fork event: 22
  • Create event: 25

Committers

Last synced: 12 months ago

All Time
  • Total Commits: 600
  • Total Committers: 139
  • Avg Commits per committer: 4.317
  • Development Distribution Score (DDS): 0.563
Past Year
  • Commits: 55
  • Committers: 19
  • Avg Commits per committer: 2.895
  • Development Distribution Score (DDS): 0.673
Top Committers
Name Email Commits
Anthony Sottile a****e@u****u 262
pre-commit-ci[bot] 6****] 129
Chris Kuehl c****l@o****u 21
Christian Knittl-Frank l****l@g****m 8
Max R m****r 4
C.A.M. Gerlach C****h@G****M 4
Rob Orr r****r@a****m 4
Thibaud Colas t****s@g****m 4
Vitaliy Lotorev v****v 3
Taylor Buchanan t****n@e****m 3
Stephan Wolski s****n@w****i 3
ColemanTom 1****m 3
AleksaC a****1@g****m 3
Aaron Gokaslan a****n@g****m 3
David Arnold d****r@x****s 3
Stephen Rosen s****n@g****g 2
Raphael Boidol b****r 2
Qexat 4****t 2
Markus Hofbauer m****r@t****e 2
Kat Rossiter s****e 2
Abdulelah Bin Mahfoodh a****m@g****m 2
Stuart Jansen s****n@b****g 2
W. Augusto Andreoli a****a@g****m 2
dkolepp d****2@g****m 2
Marco m****o@m****m 2
Adam Johnson me@a****u 2
Bradley Dice b****e@b****m 2
ClasherKasten c****0@g****m 2
Dafydd Jones d****d@t****t 2
Ersin Yildirim 9****n 2
and 109 more...

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 39
  • Total pull requests: 278
  • Average time to close issues: 3 months
  • Average time to close pull requests: 12 days
  • Total issue authors: 39
  • Total pull request authors: 102
  • Average comments per issue: 1.67
  • Average comments per pull request: 0.76
  • Merged pull requests: 198
  • Bot issues: 1
  • Bot pull requests: 105
Past Year
  • Issues: 9
  • Pull requests: 90
  • Average time to close issues: about 1 hour
  • Average time to close pull requests: 6 days
  • Issue authors: 9
  • Pull request authors: 30
  • Average comments per issue: 0.78
  • Average comments per pull request: 0.66
  • Merged pull requests: 61
  • Bot issues: 0
  • Bot pull requests: 24
Top Authors
Issue Authors
  • SerTetora (1)
  • HartmutLeister (1)
  • tungol (1)
  • ghostsquad (1)
  • UtkarshKunwar (1)
  • KORraNpl (1)
  • randdusing (1)
  • mondeja (1)
  • inknos (1)
  • ioggstream (1)
  • iainelder (1)
  • denini08 (1)
  • andresmanelli (1)
  • spaceone (1)
  • SebastianSchildt (1)
Pull Request Authors
  • pre-commit-ci[bot] (105)
  • asottile (12)
  • jalaziz (6)
  • vlotorev (5)
  • havocesp (4)
  • ColemanTom (4)
  • gtbuchanan (4)
  • qexat (4)
  • benspaulding (3)
  • mike325 (3)
  • elinscott (2)
  • cidlik (2)
  • AustinZhang1024 (2)
  • dafyddj (2)
  • mondeja (2)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels

Packages

  • Total packages: 13
  • Total downloads:
    • pypi 57,538,498 last-month
  • Total docker downloads: 891,666,266
  • Total dependent packages: 111
    (may contain duplicates)
  • Total dependent repositories: 19,157
    (may contain duplicates)
  • Total versions: 550
  • Total maintainers: 4
pypi.org: identify

File identification library for Python

  • Versions: 180
  • Dependent Packages: 104
  • Dependent Repositories: 19,097
  • Downloads: 57,538,498 Last month
  • Docker Downloads: 891,666,266
Rankings
Downloads: 0.1%
Dependent repos count: 0.1%
Docker downloads count: 0.1%
Dependent packages count: 0.2%
Average: 1.9%
Forks count: 5.4%
Stargazers count: 5.6%
Maintainers (2)
Last synced: 10 months ago
proxy.golang.org: github.com/pre-commit/identify
  • Versions: 180
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 2.4%
Stargazers count: 3.5%
Average: 6.6%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 10 months ago
alpine-edge: py3-identify

File identification library for Python

  • Versions: 37
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 6.0%
Average: 8.7%
Forks count: 11.2%
Stargazers count: 17.5%
Maintainers (1)
Last synced: 10 months ago
alpine-edge: py3-identify-pyc

Precompiled Python bytecode for py3-identify

  • Versions: 30
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 10.9%
Forks count: 11.5%
Dependent packages count: 14.1%
Stargazers count: 18.1%
Maintainers (1)
Last synced: 10 months ago
spack.io: py-identify

File identification library for Python. Given a file (or some information about a file), return a set of standardized tags identifying what the file is.

  • Versions: 4
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 14.0%
Dependent packages count: 28.1%
Maintainers (1)
Last synced: 10 months ago
conda-forge.org: identify
  • Versions: 112
  • Dependent Packages: 4
  • Dependent Repositories: 30
Rankings
Dependent repos count: 6.7%
Dependent packages count: 12.5%
Average: 15.5%
Forks count: 16.5%
Stargazers count: 26.4%
Last synced: 10 months ago
anaconda.org: identify
  • Versions: 1
  • Dependent Packages: 1
  • Dependent Repositories: 30
Rankings
Dependent repos count: 29.0%
Forks count: 29.3%
Dependent packages count: 30.6%
Average: 31.9%
Stargazers count: 38.8%
Last synced: 10 months ago
alpine-v3.21: py3-identify

File identification library for Python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago
alpine-v3.22: py3-identify-pyc

Precompiled Python bytecode for py3-identify

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago
alpine-v3.21: py3-identify-pyc

Precompiled Python bytecode for py3-identify

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago
alpine-v3.20: py3-identify-pyc

Precompiled Python bytecode for py3-identify

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago
alpine-v3.22: py3-identify

File identification library for Python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago
alpine-v3.20: py3-identify

File identification library for Python

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Dependent packages count: 0.0%
Average: 100%
Maintainers (1)
Last synced: 10 months ago

Dependencies

requirements-dev.txt pypi
  • covdefaults *
  • coverage *
  • pytest *
.github/workflows/main.yml actions
setup.py pypi