Skip to main content

File extensions for data languages.

Project description

> data-languages

File extensions for data languages.

It's just a JSON file, so you can use it in any environment. Sourced from GitHub's Linguist project (defines all 145 data languages known to GitHub). Data is updated via script and released via new package version.

Installation

pip install data-languages

Usage

import data_languages

json_lang_data = data_languages['JSON']

print(json_lang_data['extensions']) # => ['.4DForm', '.4DProject', '.avsc', ...]

Note: Most type checkers will falsely warn data_languages is not subscriptable because they are incapable of analyzing runtime behavior (where the module is replaced w/ a dictionary for cleaner, direct access). You can safely suppress such warnings using # type: ignore.


Examples

Get language(s) from an extension:

def get_lang(file_ext):
    lang_matches = [
        lang for lang, data in data_languages.items()
            if file_ext in data['extensions']
    ]
    return lang_matches[0] if len(lang_matches) == 1 else lang_matches

print(get_lang('.ical')) # => iCalendar

Get language(s) from a file path:

def get_lang_from_path(filepath):
    from pathlib import Path
    file_ext = Path(filepath).suffix
    lang_matches = [
        lang for lang, data in data_languages.items()
            if file_ext in data['extensions']
    ]
    return lang_matches[0] if len(matches) == 1 else lang_matches

print(get_lang_from_path('steam.vdf')) # => Valve Data Format
print(get_lang_from_path('Sublime.sublime-snippet')) # => XML
print(get_lang_from_path('README.md')) # => [] (use prose-languages pkg)

MIT License

Copyright © 2026 Adam Lui


Related

</> markup-languages - File extensions for markup languages.
🇨🇳 non-latin-locales - ISO 639-1 (2-letter) codes for non-Latin locales.
#! programming-languages - File extensions for programming languages.

More Python utilities / Discuss / Report bug / Report vulnerability / Back to top ↑

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

data_languages-1.0.4.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

data_languages-1.0.4-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file data_languages-1.0.4.tar.gz.

File metadata

  • Download URL: data_languages-1.0.4.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for data_languages-1.0.4.tar.gz
Algorithm Hash digest
SHA256 0f17c883db17d505eb74cb24b605e13728aaa9120512892a50cc92c87cc91f61
MD5 70aae8a72b395e1c1d718f22b6481bde
BLAKE2b-256 8ecf35ab0f539272fd8e4e35305225ce811aa35d2856ad263e88ad2ba7a8efec

See more details on using hashes here.

Provenance

The following attestation bundles were made for data_languages-1.0.4.tar.gz:

Publisher: publish-to-pypi-on-new-tag.yml on adamlui/python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file data_languages-1.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for data_languages-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a9065f53ecb60e3bab331a87316b1a7f373bc5a38e964d284bd2d5d2741e659c
MD5 77db114663cb55202d114424f40bafec
BLAKE2b-256 2a9361cd393880af5de511a22b6c9d779cc7e2626779dd70c46c89ed59b31c54

See more details on using hashes here.

Provenance

The following attestation bundles were made for data_languages-1.0.4-py2.py3-none-any.whl:

Publisher: publish-to-pypi-on-new-tag.yml on adamlui/python-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page