helpish 0.2.0__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: helpish
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: List English words by length — handy for writing Pilish.
5
5
  Requires-Dist: textual>=8.2.8
6
6
  Requires-Dist: wordfreq>=3.1.1
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "helpish"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "List English words by length — handy for writing Pilish."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -0,0 +1,7 @@
1
+ """helpish: list English words by length, handy for writing Pilish."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from helpish.app import main
6
+
7
+ __all__ = ["main"]
@@ -1,29 +1,14 @@
1
- """helpish: list English words by length, handy for writing Pilish."""
1
+ """Textual app that lists English words by length."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from collections import defaultdict
6
- from importlib.resources import files
7
- from pathlib import Path
8
-
9
5
  from textual import on
10
6
  from textual.app import App, ComposeResult
11
7
  from textual.containers import Horizontal, VerticalScroll
12
8
  from textual.widgets import Footer, Header, Input, Label, Static
13
9
  from wordfreq import zipf_frequency
14
10
 
15
- WORDS_FILE = Path(str(files("helpish") / "words_alpha.txt"))
16
-
17
-
18
- def load_words_by_length(path: Path) -> dict[int, list[str]]:
19
- """Read the word list once and bucket every word by its length."""
20
- buckets: dict[int, list[str]] = defaultdict(list)
21
- with path.open(encoding="utf-8") as handle:
22
- for line in handle:
23
- word = line.strip()
24
- if word:
25
- buckets[len(word)].append(word)
26
- return buckets
11
+ from helpish.words import WORDS_FILE, load_words_by_length
27
12
 
28
13
 
29
14
  class WordLengthApp(App[None]):
@@ -129,8 +114,5 @@ class WordLengthApp(App[None]):
129
114
 
130
115
 
131
116
  def main() -> None:
117
+ """Run the app."""
132
118
  WordLengthApp().run()
133
-
134
-
135
- if __name__ == "__main__":
136
- main()
@@ -0,0 +1,20 @@
1
+ """Load and bucket the bundled English word list."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections import defaultdict
6
+ from importlib.resources import files
7
+ from pathlib import Path
8
+
9
+ WORDS_FILE = Path(str(files("helpish") / "words_alpha.txt"))
10
+
11
+
12
+ def load_words_by_length(path: Path) -> dict[int, list[str]]:
13
+ """Read the word list once and bucket every word by its length."""
14
+ buckets: dict[int, list[str]] = defaultdict(list)
15
+ with path.open(encoding="utf-8") as handle:
16
+ for line in handle:
17
+ word = line.strip()
18
+ if word:
19
+ buckets[len(word)].append(word)
20
+ return buckets
File without changes