Skip to content

Commit 9896b24

Browse files
committed
Created computer-languages pkg
1 parent 0f93ce5 commit 9896b24

22 files changed

Lines changed: 1658 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ updates:
99
- package-ecosystem: pip
1010
directories:
1111
- /
12+
- /computer-languages
1213
- /data-languages
1314
- /find-project-root
1415
- /get-min-py

computer-languages/docs/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 🏛️ MIT License
2+
3+
**Copyright © 2026 [Adam Lui](https://github.com/adamlui)**
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

computer-languages/docs/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<a id="top"></a>
2+
3+
# ⊕ computer-languages
4+
5+
<a href="https://github.com/adamlui/python-utils/releases/tag/computer-languages-1.0.0">
6+
<img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.0-32fcee.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
7+
<a href="https://github.com/adamlui/python-utils/blob/main/computer-languages/docs/LICENSE.md">
8+
<img height=31 src="https://img.shields.io/badge/License-MIT-f99b27.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
9+
<a href="https://www.codefactor.io/repository/github/adamlui/python-utils">
10+
<img height=31 src="https://img.shields.io/codefactor/grade/github/adamlui/python-utils?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=a0fc55&style=for-the-badge"></a>
11+
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_python-utils">
12+
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_python-utils%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=fafc74"></a>
13+
14+
> ### _File extensions for computer languages._
15+
16+
It's just a [JSON file](https://github.com/adamlui/python-utils/blob/computer-languages-1.0.0/computer-languages/src/computer_languages/computer_languages.json), so you can use it in any environment. Sourced from GitHub's [Linguist](https://github.com/github-linguist/linguist) project (defines all 700+ languages known to GitHub). Data is updated via script and released via new package version.
17+
18+
## Installation
19+
20+
```bash
21+
pip install computer-languages
22+
```
23+
24+
## Usage
25+
26+
```py
27+
import computer_languages
28+
29+
py_lang_data = computer_languages['Python']
30+
31+
print(py_lang_data['type']) # => 'programming'
32+
print(py_lang_data['extensions']) # => ['.cgi', '.fcgi', '.gyp', ...]
33+
```
34+
35+
_Note: Most type checkers will falsely warn_ `computer_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`.
36+
37+
## Examples
38+
39+
List all extensions for a language:
40+
41+
```py
42+
js_exts = computer_languages['JavaScript']['extensions']
43+
44+
print(js_exts) # => ['._js', '.bones', '.cjs', '.es', ...]
45+
```
46+
47+
Get language from an extension:
48+
49+
```py
50+
def get_lang(file_ext):
51+
for lang, data in computer_languages.items():
52+
if file_ext in data['extensions']:
53+
return lang
54+
55+
print(get_lang('.rs')) # => 'Rust'
56+
```
57+
58+
Filter by language type:
59+
60+
```py
61+
markup_langs = [
62+
lang for lang, data in computer_languages.items()
63+
if data['type'] == 'markup'
64+
]
65+
66+
print(markup_langs) # => ['Antlers', 'API Blueprint', 'Astro', 'BibTeX', ...]
67+
print(f'{len(markup_langs)} markup languages') # -> '69 markup languages'
68+
```
69+
70+
## MIT License
71+
72+
Copyright © 2026 [Adam Lui](https://github.com/adamlui).
73+
74+
## Related
75+
76+
</> [markup-languages](https://github.com/adamlui/python-utils/tree/main/markup-languages/#readme) - File extensions for markup languages.
77+
<br>## [prose-languages](https://github.com/adamlui/python-utils/tree/main/prose-languages/#readme) - File extensions for prose languages.
78+
<br>{ } [data-languages](https://github.com/adamlui/python-utils/tree/main/data-languages/#readme) - File extensions for data languages.
79+
<br>#! [programming-languages](https://github.com/adamlui/python-utils/tree/main/programming-languages/#readme) - File extensions for programming languages.
80+
81+
#
82+
83+
<a href="#top">Back to top ↑</a>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 🛡️ Security Policy
2+
3+
If you find a vulnerability, please e-mail security@tidelift.com and a fix will be coordinated within 2 business days.

computer-languages/noxfile.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from pathlib import Path
2+
from types import SimpleNamespace as sn
3+
4+
import nox
5+
6+
pkg = sn(dir=Path(__file__).parent.name)
7+
pkg.name = pkg.dir.replace('-', '_')
8+
paths = sn(
9+
utils=sn(bump='utils/bump.py', clean='utils/clean.py', publish='utils/publish.sh', update='utils/update_langs.py'))
10+
11+
def session(func) : return nox.session(venv_backend='none', name=func.__name__.replace('_', '-'))(func)
12+
13+
# SESSIONS
14+
15+
@session
16+
def dev(session) : session.run('pip', 'install', '-e', '.')
17+
18+
@session
19+
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
20+
@session
21+
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
22+
23+
@session
24+
def update(session, *args) : session.run('py', paths.utils.update, *args)
25+
26+
@session
27+
def bump_patch(session, no_push=True):
28+
cmd = ['py', paths.utils.bump, '--patch']
29+
if no_push : cmd.append('--no-push')
30+
session.run(*cmd, *session.posargs)
31+
@session
32+
def bump_minor(session, no_push=True):
33+
cmd = ['py', paths.utils.bump, '--minor']
34+
if no_push : cmd.append('--no-push')
35+
session.run(*cmd, *session.posargs)
36+
@session
37+
def bump_feat(session, no_push=True):
38+
bump_minor(session, no_push)
39+
@session
40+
def bump_major(session, no_push=True):
41+
cmd = ['py', paths.utils.bump, '--major']
42+
if no_push : cmd.append('--no-push')
43+
session.run(*cmd, *session.posargs)
44+
45+
@session
46+
def build(session) : clean(session) ; session.run('py', '-m', 'build') ; print('Build complete!')
47+
@session
48+
def publish(session) : session.run('bash', paths.utils.publish, *session.posargs)
49+
50+
@session
51+
def deploy_patch(session) : bump_patch(session, no_push=False) ; build(session) ; publish(session)
52+
@session
53+
def deploy_minor(session) : bump_minor(session, no_push=False) ; build(session) ; publish(session)
54+
@session
55+
def deploy_feat(session) : deploy_minor(session)
56+
@session
57+
def deploy_major(session) : bump_major(session, no_push=False) ; build(session) ; publish(session)
58+
59+
@session
60+
def clean(session, *args) : session.run('py', paths.utils.clean, *args)

computer-languages/pyproject.toml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[build-system]
2+
requires = [
3+
"setuptools~=82.0.0",
4+
"wheel",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "computer-languages"
10+
version = "1.0.0"
11+
description = "File extensions for computer languages."
12+
authors = [
13+
{ name = "Adam Lui", email = "adam@kudoai.com" },
14+
]
15+
readme = "docs/README.md"
16+
license = "MIT"
17+
license-files = [
18+
"docs/LICENSE.md",
19+
]
20+
requires-python = ">=2.6,<4"
21+
keywords = [
22+
"asciidoc",
23+
"bash",
24+
"c",
25+
"c#",
26+
"c++",
27+
"code-languages",
28+
"computer-languages",
29+
"csv",
30+
"dart",
31+
"data-languages",
32+
"extensions",
33+
"file‑type-detection",
34+
"file-extensions",
35+
"filenames",
36+
"github",
37+
"go",
38+
"html",
39+
"java",
40+
"javascript",
41+
"json",
42+
"kotlin",
43+
"language-detection",
44+
"languages",
45+
"linguist",
46+
"markdown",
47+
"markup-languages",
48+
"php",
49+
"powershell",
50+
"programming-languages",
51+
"prose-languages",
52+
"python",
53+
"ruby",
54+
"rust",
55+
"shell",
56+
"sql",
57+
"swift",
58+
"syntax-highlighting",
59+
"toml",
60+
"typescript",
61+
"xml",
62+
"yaml",
63+
]
64+
classifiers = [
65+
"Development Status :: 5 - Production/Stable",
66+
"Intended Audience :: Developers",
67+
"Intended Audience :: Education",
68+
"Intended Audience :: Information Technology",
69+
"Intended Audience :: Science/Research",
70+
"Intended Audience :: System Administrators",
71+
"Natural Language :: English",
72+
"Operating System :: OS Independent",
73+
"Programming Language :: Python",
74+
"Programming Language :: Python :: 2",
75+
"Programming Language :: Python :: 2.6",
76+
"Programming Language :: Python :: 2.7",
77+
"Programming Language :: Python :: 3",
78+
"Programming Language :: Python :: 3.8",
79+
"Programming Language :: Python :: 3.9",
80+
"Programming Language :: Python :: 3.10",
81+
"Programming Language :: Python :: 3.11",
82+
"Programming Language :: Python :: 3.12",
83+
"Programming Language :: Python :: 3.13",
84+
"Programming Language :: Python :: 3.14",
85+
"Programming Language :: Python :: 3.15",
86+
"Topic :: Database",
87+
"Topic :: Documentation",
88+
"Topic :: Education",
89+
"Topic :: Internet",
90+
"Topic :: Internet :: WWW/HTTP",
91+
"Topic :: Scientific/Engineering",
92+
"Topic :: Scientific/Engineering :: Information Analysis",
93+
"Topic :: Software Development",
94+
"Topic :: Software Development :: Libraries",
95+
"Topic :: Software Development :: Libraries :: Python Modules",
96+
"Topic :: Text Processing",
97+
"Topic :: Text Processing :: General",
98+
"Topic :: Text Processing :: Linguistic",
99+
"Topic :: Text Processing :: Markup",
100+
"Topic :: Utilities",
101+
]
102+
103+
[project.urls]
104+
Changelog = "https://github.com/adamlui/python-utils/releases/tag/computer-languages-1.0.0"
105+
Documentation = "https://github.com/adamlui/python-utils/tree/main/computer-languages/docs"
106+
Funding = "https://github.com/sponsors/adamlui"
107+
Homepage = "https://github.com/adamlui/python-utils/tree/main/computer-languages/#readme"
108+
Issues = "https://github.com/adamlui/python-utils/issues"
109+
"PyPI Stats" = "https://pepy.tech/projects/computer-languages"
110+
Releases = "https://github.com/adamlui/python-utils/releases"
111+
Repository = "https://github.com/adamlui/python-utils"
112+
113+
[project.optional-dependencies]
114+
dev = [
115+
"nox>=2026.2.9",
116+
"tomli~=2.4.0",
117+
"tomli-w~=1.2.0",
118+
]
119+
120+
[tool.setuptools.packages.find]
121+
where = [
122+
"src",
123+
]
124+
125+
[tool.setuptools.package-data]
126+
computer_languages = [
127+
"computer_languages.json",
128+
]

computer-languages/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal = 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import json, os, sys
2+
3+
with open(os.path.join(os.path.dirname(__file__), 'computer_languages.json')) as file:
4+
computer_languages = json.load(file)
5+
6+
sys.modules[__name__] = computer_languages

0 commit comments

Comments
 (0)