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 from an extension:

def get_lang(file_ext):
    for lang, data in data_languages.items():
        if file_ext in data['extensions']:
            return lang

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

Get language from a file path:

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

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')) # => None (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.3.tar.gz (9.6 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.3-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: data_languages-1.0.3.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for data_languages-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1c2acf9bf4c0b1dd44b2b17104360c5e0efe006aefdaa5a335a5a8b28e16252b
MD5 2ac9b61ede1e7559f5b69ba8ef8493cd
BLAKE2b-256 859fe67daf326c0309b274e17d1ceea4be1a542f74ca95756e0b98ea0401351c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for data_languages-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1ec4668f267b5b0ceb99104acc7a8f97e29b26dfe9e211e6b440d4a5f9a721a9
MD5 6032e1ec19e47357e5f85d23344c39e9
BLAKE2b-256 bcad155d9d2abaa9d5f1f42172dc9d566ea61dbc54df5c6a9908a85e6d5d2d35

See more details on using hashes here.

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