lupaxa-text-analyse 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ # OS
2
+ .DS_Store
3
+
4
+ # Cursor
5
+ .cursor/
6
+ .superpowers/
7
+ .worktrees/
8
+ cursor-docs
9
+
10
+ # Make
11
+ .makefiles/
12
+
13
+ # Python
14
+ .venv/
15
+ __pycache__/
16
+ .mypy_cache/
17
+ .ruff_cache/
18
+ .pytest_cache/
19
+ dist/
20
+ build/
21
+ *.egg-info/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) The Lupaxa Project
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.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.5
2
+ Name: lupaxa-text-analyse
3
+ Version: 0.1.0
4
+ Summary: Analyse prose for readability and source code for rough size and complexity metrics.
5
+ Project-URL: Homepage, https://github.com/lupaxa-developers-toolbox/text-analyse
6
+ Project-URL: Documentation, https://github.com/lupaxa-developers-toolbox/text-analyse
7
+ Project-URL: Repository, https://github.com/lupaxa-developers-toolbox/text-analyse
8
+ Project-URL: Issues, https://github.com/lupaxa-developers-toolbox/text-analyse/issues
9
+ Author: The Lupaxa Project
10
+ License: MIT License
11
+
12
+ Copyright (c) The Lupaxa Project
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ License-File: LICENCE
32
+ Keywords: analysis,cli,code,readability,text
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Environment :: Console
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Programming Language :: Python :: 3.14
44
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
45
+ Classifier: Topic :: Text Processing
46
+ Classifier: Topic :: Utilities
47
+ Requires-Python: >=3.10
48
+ Requires-Dist: beautifulsoup4>=4.12
49
+ Requires-Dist: httpx>=0.27
50
+ Requires-Dist: rich>=13.0
51
+ Provides-Extra: dev
52
+ Requires-Dist: bump-my-version>=1.2.0; extra == 'dev'
53
+ Requires-Dist: hatch>=1.12.0; extra == 'dev'
54
+ Requires-Dist: mypy>=1.12.0; extra == 'dev'
55
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
56
+ Requires-Dist: pytest>=8.0; extra == 'dev'
57
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
58
+ Provides-Extra: test
59
+ Requires-Dist: pytest-cov>=5.0; extra == 'test'
60
+ Requires-Dist: pytest>=8.0; extra == 'test'
61
+ Description-Content-Type: text/markdown
62
+
63
+ <p align="center">
64
+ <a href="https://github.com/lupaxa-developers-toolbox">
65
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/developers-toolbox/readme-logo.png" alt="Developers Toolbox" />
66
+ </a>
67
+ </p>
68
+
69
+ <h1 align="center">Text Analyse</h1>
70
+
71
+ Analyse prose for readability, and source code for rough size and
72
+ complexity metrics. The library returns one result object. The
73
+ `text-analyse` command prints that result as a table.
74
+
75
+ The PyPI name is `lupaxa-text-analyse`. The import path is
76
+ `lupaxa.text_analyse`. The console script is `text-analyse`. `lupaxa` is
77
+ a namespace package — there is no `lupaxa/__init__.py`.
78
+
79
+ Public names: `analyse`, `analyse_text`, `analyse_code`, `looks_like_code`,
80
+ `fetch_text`, `describe_flesch_score`, `reading_age_band`,
81
+ `TextAnalyseError`, `FetchError`, `__version__`, `get_version()`.
82
+
83
+ ## Install
84
+
85
+ ```bash
86
+ pip install lupaxa-text-analyse
87
+ ```
88
+
89
+ Requires Python 3.10 or newer, plus `httpx`, `beautifulsoup4`, and `rich`.
90
+
91
+ ## Library
92
+
93
+ ```python
94
+ from lupaxa.text_analyse import analyse, analyse_code, analyse_text, fetch_text
95
+
96
+ analyse("The cat sat on the mat.")
97
+ analyse(open("README.md", encoding="utf-8").read(), source="README.md")
98
+ analyse_code(open("script.py", encoding="utf-8").read())
99
+ fetch_text("https://example.com")
100
+ ```
101
+
102
+ `analyse` uses `mode="auto"` unless you pass `text` or `code`. Pass
103
+ `source` as the file name when you have one. A documentation suffix
104
+ selects text mode, and a Markdown file is scored after fenced code,
105
+ HTML tags, and link URLs are removed. Text results include the
106
+ reading-age band, the Flesch description, and a language judgement.
107
+ Pass `wpm` to change the reading-time estimate.
108
+
109
+ `fetch_text` follows redirects, sends a `text-analyse` user-agent, and
110
+ refuses bodies over 2 MB. HTML pages drop navigation, headers, footers,
111
+ and sidebars. The article's headings, paragraphs, and list items become
112
+ the text, with a blank line between them.
113
+
114
+ > **Note:** Readability scores are for continuous English prose. The
115
+ > syllable counter, sentence splitter, and code metrics are heuristics.
116
+ > Auto mode treats a sample as code when code symbols exceed 3% of the
117
+ > characters. Words such as "for" and "from" do not, on their own. An
118
+ > HTML page, or a Markdown, reStructuredText, or AsciiDoc file, is
119
+ > analysed as text. Markdown scores ignore fenced code, HTML, and link
120
+ > URLs. Pass `--mode code` to force code metrics.
121
+
122
+ ## CLI
123
+
124
+ The default format is a table. `--format text` prints the same figures
125
+ as aligned lines. `--format json` prints the result object.
126
+
127
+ ```bash
128
+ text-analyse article.txt
129
+ text-analyse --url https://example.com
130
+ text-analyse --min-flesch 60 README.md
131
+ text-analyse docs/ --check --min-flesch 60
132
+ text-analyse --mode code script.py
133
+ cat notes.txt | text-analyse --wpm 180 --reading-age-scheme us
134
+ text-analyse --version
135
+ ```
136
+
137
+ | Flag | Meaning |
138
+ | ---------------------- | ------------------------------------------------------- |
139
+ | `path` | Files or documentation directories. Stdin when omitted. |
140
+ | `--file`, `-f` | File path. Do not combine with `path` or `--url`. |
141
+ | `--url`, `-u` | Fetch a URL. HTML is read as the article. |
142
+ | `--format`, `-F` | `table` (default), `text`, or `json`. |
143
+ | `--mode`, `-m` | `auto` (default), `text`, or `code`. |
144
+ | `--wpm` | Reading speed for the time estimate (default 200). |
145
+ | `--min-flesch` | Fail when the Flesch Reading Ease score is lower. |
146
+ | `--max-grade` | Fail when the Flesch–Kincaid grade is higher. |
147
+ | `--check` | Print only files that fail a readability threshold. |
148
+ | `--reading-age-scheme` | `uk` (default) or `us`. |
149
+ | `--version` | Print `text-analyse x.y.z` and exit `0`. |
150
+
151
+ | Result | Exit |
152
+ | ------------------------------- | ---- |
153
+ | Report printed | `0` |
154
+ | Readability check failed | `1` |
155
+ | Empty input, bad path, or fetch | `1` |
156
+ | More than one input source | `1` |
157
+ | Readability check on code only | `2` |
158
+ | `--check` without a threshold | `2` |
159
+
160
+ A single file is one metrics table. It includes the mode, the language
161
+ judgement, and the reading time at the chosen speed. Several files, or a
162
+ directory, print one row per file. A directory is walked for Markdown,
163
+ reStructuredText, AsciiDoc, and plain-text files. `--check` prints only
164
+ the rows that miss a threshold. Code reports for one file are a single
165
+ table with the mode, the line counts, and the file-level complexity heuristic.
166
+
167
+ ## Development
168
+
169
+ ```bash
170
+ make init
171
+ make python-install-dev
172
+ make python-check
173
+ ```
174
+
175
+ <a href="https://github.com/the-lupaxa-project">
176
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
177
+ </a>
@@ -0,0 +1,115 @@
1
+ <p align="center">
2
+ <a href="https://github.com/lupaxa-developers-toolbox">
3
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/developers-toolbox/readme-logo.png" alt="Developers Toolbox" />
4
+ </a>
5
+ </p>
6
+
7
+ <h1 align="center">Text Analyse</h1>
8
+
9
+ Analyse prose for readability, and source code for rough size and
10
+ complexity metrics. The library returns one result object. The
11
+ `text-analyse` command prints that result as a table.
12
+
13
+ The PyPI name is `lupaxa-text-analyse`. The import path is
14
+ `lupaxa.text_analyse`. The console script is `text-analyse`. `lupaxa` is
15
+ a namespace package — there is no `lupaxa/__init__.py`.
16
+
17
+ Public names: `analyse`, `analyse_text`, `analyse_code`, `looks_like_code`,
18
+ `fetch_text`, `describe_flesch_score`, `reading_age_band`,
19
+ `TextAnalyseError`, `FetchError`, `__version__`, `get_version()`.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install lupaxa-text-analyse
25
+ ```
26
+
27
+ Requires Python 3.10 or newer, plus `httpx`, `beautifulsoup4`, and `rich`.
28
+
29
+ ## Library
30
+
31
+ ```python
32
+ from lupaxa.text_analyse import analyse, analyse_code, analyse_text, fetch_text
33
+
34
+ analyse("The cat sat on the mat.")
35
+ analyse(open("README.md", encoding="utf-8").read(), source="README.md")
36
+ analyse_code(open("script.py", encoding="utf-8").read())
37
+ fetch_text("https://example.com")
38
+ ```
39
+
40
+ `analyse` uses `mode="auto"` unless you pass `text` or `code`. Pass
41
+ `source` as the file name when you have one. A documentation suffix
42
+ selects text mode, and a Markdown file is scored after fenced code,
43
+ HTML tags, and link URLs are removed. Text results include the
44
+ reading-age band, the Flesch description, and a language judgement.
45
+ Pass `wpm` to change the reading-time estimate.
46
+
47
+ `fetch_text` follows redirects, sends a `text-analyse` user-agent, and
48
+ refuses bodies over 2 MB. HTML pages drop navigation, headers, footers,
49
+ and sidebars. The article's headings, paragraphs, and list items become
50
+ the text, with a blank line between them.
51
+
52
+ > **Note:** Readability scores are for continuous English prose. The
53
+ > syllable counter, sentence splitter, and code metrics are heuristics.
54
+ > Auto mode treats a sample as code when code symbols exceed 3% of the
55
+ > characters. Words such as "for" and "from" do not, on their own. An
56
+ > HTML page, or a Markdown, reStructuredText, or AsciiDoc file, is
57
+ > analysed as text. Markdown scores ignore fenced code, HTML, and link
58
+ > URLs. Pass `--mode code` to force code metrics.
59
+
60
+ ## CLI
61
+
62
+ The default format is a table. `--format text` prints the same figures
63
+ as aligned lines. `--format json` prints the result object.
64
+
65
+ ```bash
66
+ text-analyse article.txt
67
+ text-analyse --url https://example.com
68
+ text-analyse --min-flesch 60 README.md
69
+ text-analyse docs/ --check --min-flesch 60
70
+ text-analyse --mode code script.py
71
+ cat notes.txt | text-analyse --wpm 180 --reading-age-scheme us
72
+ text-analyse --version
73
+ ```
74
+
75
+ | Flag | Meaning |
76
+ | ---------------------- | ------------------------------------------------------- |
77
+ | `path` | Files or documentation directories. Stdin when omitted. |
78
+ | `--file`, `-f` | File path. Do not combine with `path` or `--url`. |
79
+ | `--url`, `-u` | Fetch a URL. HTML is read as the article. |
80
+ | `--format`, `-F` | `table` (default), `text`, or `json`. |
81
+ | `--mode`, `-m` | `auto` (default), `text`, or `code`. |
82
+ | `--wpm` | Reading speed for the time estimate (default 200). |
83
+ | `--min-flesch` | Fail when the Flesch Reading Ease score is lower. |
84
+ | `--max-grade` | Fail when the Flesch–Kincaid grade is higher. |
85
+ | `--check` | Print only files that fail a readability threshold. |
86
+ | `--reading-age-scheme` | `uk` (default) or `us`. |
87
+ | `--version` | Print `text-analyse x.y.z` and exit `0`. |
88
+
89
+ | Result | Exit |
90
+ | ------------------------------- | ---- |
91
+ | Report printed | `0` |
92
+ | Readability check failed | `1` |
93
+ | Empty input, bad path, or fetch | `1` |
94
+ | More than one input source | `1` |
95
+ | Readability check on code only | `2` |
96
+ | `--check` without a threshold | `2` |
97
+
98
+ A single file is one metrics table. It includes the mode, the language
99
+ judgement, and the reading time at the chosen speed. Several files, or a
100
+ directory, print one row per file. A directory is walked for Markdown,
101
+ reStructuredText, AsciiDoc, and plain-text files. `--check` prints only
102
+ the rows that miss a threshold. Code reports for one file are a single
103
+ table with the mode, the line counts, and the file-level complexity heuristic.
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ make init
109
+ make python-install-dev
110
+ make python-check
111
+ ```
112
+
113
+ <a href="https://github.com/the-lupaxa-project">
114
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
115
+ </a>
@@ -0,0 +1,23 @@
1
+ <p align="center">
2
+ <a href="https://github.com/lupaxa-developers-toolbox">
3
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/organisations/developers-toolbox/readme-logo.png" alt="Organisation Logo" />
4
+ </a>
5
+ </p>
6
+
7
+ <h1 align="center">Core Documentation</h1>
8
+
9
+ The following documents define the standards that apply across **The Lupaxa Project**:
10
+
11
+ | Document | Purpose |
12
+ | :------------------------------------ | :---------------------------------------------------------------- |
13
+ | [Code of Conduct](CODE_OF_CONDUCT.md) | Expected behaviour and reporting procedures. |
14
+ | [How to Contribute](CONTRIBUTING.md) | Development workflow, coding standards, and contribution process. |
15
+ | [Governance](GOVERNANCE.md) | Project governance, roles, and decision-making. |
16
+ | [Maintainers](MAINTAINERS.md) | Maintainer responsibilities and expectations. |
17
+ | [Projects Overview](PROJECTS.md) | Overview of organisations, repositories, and project structure. |
18
+ | [Security Policy](SECURITY.md) | Responsible disclosure and secure development practices. |
19
+ | [Support Guide](SUPPORT.md) | How to obtain help and support. |
20
+
21
+ <a href="https://github.com/the-lupaxa-project">
22
+ <img src="https://raw.githubusercontent.com/the-lupaxa-project/brand-assets/master/logos/components/footer-for-child-orgs.svg" alt="The Lupaxa Project Footer" width="100%" />
23
+ </a>
@@ -0,0 +1,103 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.18"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "lupaxa-text-analyse"
7
+ dynamic = ["version"]
8
+ description = "Analyse prose for readability and source code for rough size and complexity metrics."
9
+ readme = "README.md"
10
+ license = { file = "LICENCE" }
11
+ requires-python = ">=3.10"
12
+
13
+ authors = [
14
+ { name = "The Lupaxa Project" }
15
+ ]
16
+
17
+ keywords = ["text", "readability", "code", "cli", "analysis"]
18
+
19
+ dependencies = [
20
+ "beautifulsoup4>=4.12",
21
+ "httpx>=0.27",
22
+ "rich>=13.0",
23
+ ]
24
+
25
+ classifiers = [
26
+ "Development Status :: 4 - Beta",
27
+ "Environment :: Console",
28
+ "Intended Audience :: Developers",
29
+ "License :: OSI Approved :: MIT License",
30
+ "Operating System :: OS Independent",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: 3.14",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ "Topic :: Text Processing",
39
+ "Topic :: Utilities",
40
+ ]
41
+
42
+ [project.urls]
43
+ Homepage = "https://github.com/lupaxa-developers-toolbox/text-analyse"
44
+ Documentation = "https://github.com/lupaxa-developers-toolbox/text-analyse"
45
+ Repository = "https://github.com/lupaxa-developers-toolbox/text-analyse"
46
+ Issues = "https://github.com/lupaxa-developers-toolbox/text-analyse/issues"
47
+
48
+ [project.scripts]
49
+ text-analyse = "lupaxa.text_analyse.cli:main"
50
+
51
+ [project.optional-dependencies]
52
+ dev = [
53
+ "pytest>=8.0",
54
+ "pytest-cov>=5.0",
55
+ "ruff>=0.6.0",
56
+ "mypy>=1.12.0",
57
+ "hatch>=1.12.0",
58
+ "bump-my-version>=1.2.0",
59
+ ]
60
+ test = [
61
+ "pytest>=8.0",
62
+ "pytest-cov>=5.0",
63
+ ]
64
+
65
+ [tool.hatch.version]
66
+ path = "src/lupaxa/text_analyse/version.py"
67
+
68
+ [tool.hatch.build.targets.sdist]
69
+ include = [
70
+ "src/**",
71
+ "README.md",
72
+ "LICENCE",
73
+ ]
74
+
75
+ [tool.hatch.build.targets.wheel]
76
+ packages = ["src/lupaxa"]
77
+
78
+ [tool.ruff]
79
+ line-length = 100
80
+ target-version = "py310"
81
+
82
+ [tool.ruff.lint]
83
+ select = ["E", "F", "I", "B", "UP", "SIM"]
84
+
85
+ [tool.ruff.lint.isort]
86
+ known-first-party = ["lupaxa"]
87
+
88
+ [tool.ruff.format]
89
+ quote-style = "double"
90
+
91
+ [tool.mypy]
92
+ python_version = "3.10"
93
+ files = ["src", "tests"]
94
+ mypy_path = "src"
95
+ explicit_package_bases = true
96
+ namespace_packages = true
97
+ warn_unused_configs = true
98
+ ignore_missing_imports = true
99
+
100
+ [tool.pytest.ini_options]
101
+ addopts = "-ra -q --disable-warnings"
102
+ testpaths = ["tests"]
103
+ pythonpath = ["src"]
@@ -0,0 +1,29 @@
1
+ """lupaxa.text_analyse — readability scores and rough code metrics.
2
+
3
+ ``analyse(text)`` picks prose or code. ``analyse_text`` and ``analyse_code``
4
+ force a mode. ``fetch_text`` downloads a URL and extracts readable text.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from lupaxa.text_analyse.code import analyse_code
10
+ from lupaxa.text_analyse.core import analyse
11
+ from lupaxa.text_analyse.detect import looks_like_code
12
+ from lupaxa.text_analyse.exceptions import FetchError, TextAnalyseError
13
+ from lupaxa.text_analyse.fetch import fetch_text
14
+ from lupaxa.text_analyse.text import analyse_text, describe_flesch_score, reading_age_band
15
+ from lupaxa.text_analyse.version import __version__, get_version
16
+
17
+ __all__ = [
18
+ "FetchError",
19
+ "TextAnalyseError",
20
+ "__version__",
21
+ "analyse",
22
+ "analyse_code",
23
+ "analyse_text",
24
+ "describe_flesch_score",
25
+ "fetch_text",
26
+ "get_version",
27
+ "looks_like_code",
28
+ "reading_age_band",
29
+ ]
@@ -0,0 +1,8 @@
1
+ """Allow ``python -m lupaxa.text_analyse`` to run the CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from lupaxa.text_analyse.cli import main
6
+
7
+ if __name__ == "__main__":
8
+ raise SystemExit(main())