mukimov 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.
mukimov-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mukimov
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.
mukimov-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: mukimov
3
+ Version: 0.1.0
4
+ Summary: Tiny cross-platform password prompt that echoes * for each character
5
+ Author: mukimov
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mukimov/mukimov
8
+ Keywords: password,getpass,stars,prompt,cli
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Topic :: Security
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: license-file
18
+
19
+ # mukimov
20
+
21
+ Tiny cross-platform Python library: password prompt that shows `*` for each typed character — like `getpass()`, but with visual feedback.
22
+
23
+ ```python
24
+ from mukimov import stars
25
+
26
+ password = stars("Password: ")
27
+ print(password)
28
+ ```
29
+
30
+ Terminal:
31
+
32
+ ```text
33
+ Password: ********
34
+ ```
35
+
36
+ `password` contains the real text (`"12345678"`), only `*` are shown on screen.
37
+
38
+ ## Features
39
+
40
+ - Only standard library, zero dependencies
41
+ - Windows (`msvcrt`) + Linux/macOS (`termios`/`tty`)
42
+ - Each character is immediately replaced with `*`
43
+ - Backspace correctly deletes the last `*`
44
+ - Enter finishes input
45
+ - Real password is never printed
46
+ - Ctrl+C → `KeyboardInterrupt`, Ctrl+D on empty input → `EOFError`
47
+ - Falls back to `getpass` (no echo) when stdin is not a TTY (pipes, IDE, CI)
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install .
53
+ ```
54
+
55
+ For development:
56
+
57
+ ```bash
58
+ pip install -e .[test] # or: pip install -e . && pip install pytest
59
+ pytest -q
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ from mukimov import stars
66
+
67
+ username = input("Username: ")
68
+ password = stars("Password: ")
69
+
70
+ print(username)
71
+ ```
72
+
73
+ ```text
74
+ Username: mukimov
75
+ Password: ********
76
+ ```
77
+
78
+ Custom mask character:
79
+
80
+ ```python
81
+ password = stars("Password: ", mask="#")
82
+ ```
83
+
84
+ ## Build & publish to PyPI
85
+
86
+ ```bash
87
+ python -m pip install --upgrade build twine
88
+ python -m build
89
+ python -m twine check dist/*
90
+ python -m twine upload dist/*
91
+ ```
92
+
93
+ Test PyPI first:
94
+
95
+ ```bash
96
+ python -m twine upload --repository testpypi dist/*
97
+ pip install --index-url https://test.pypi.org/simple/ mukimov
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT
@@ -0,0 +1,84 @@
1
+ # mukimov
2
+
3
+ Tiny cross-platform Python library: password prompt that shows `*` for each typed character — like `getpass()`, but with visual feedback.
4
+
5
+ ```python
6
+ from mukimov import stars
7
+
8
+ password = stars("Password: ")
9
+ print(password)
10
+ ```
11
+
12
+ Terminal:
13
+
14
+ ```text
15
+ Password: ********
16
+ ```
17
+
18
+ `password` contains the real text (`"12345678"`), only `*` are shown on screen.
19
+
20
+ ## Features
21
+
22
+ - Only standard library, zero dependencies
23
+ - Windows (`msvcrt`) + Linux/macOS (`termios`/`tty`)
24
+ - Each character is immediately replaced with `*`
25
+ - Backspace correctly deletes the last `*`
26
+ - Enter finishes input
27
+ - Real password is never printed
28
+ - Ctrl+C → `KeyboardInterrupt`, Ctrl+D on empty input → `EOFError`
29
+ - Falls back to `getpass` (no echo) when stdin is not a TTY (pipes, IDE, CI)
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install .
35
+ ```
36
+
37
+ For development:
38
+
39
+ ```bash
40
+ pip install -e .[test] # or: pip install -e . && pip install pytest
41
+ pytest -q
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ```python
47
+ from mukimov import stars
48
+
49
+ username = input("Username: ")
50
+ password = stars("Password: ")
51
+
52
+ print(username)
53
+ ```
54
+
55
+ ```text
56
+ Username: mukimov
57
+ Password: ********
58
+ ```
59
+
60
+ Custom mask character:
61
+
62
+ ```python
63
+ password = stars("Password: ", mask="#")
64
+ ```
65
+
66
+ ## Build & publish to PyPI
67
+
68
+ ```bash
69
+ python -m pip install --upgrade build twine
70
+ python -m build
71
+ python -m twine check dist/*
72
+ python -m twine upload dist/*
73
+ ```
74
+
75
+ Test PyPI first:
76
+
77
+ ```bash
78
+ python -m twine upload --repository testpypi dist/*
79
+ pip install --index-url https://test.pypi.org/simple/ mukimov
80
+ ```
81
+
82
+ ## License
83
+
84
+ MIT
@@ -0,0 +1,6 @@
1
+ """mukimov — tiny cross-platform ``stars()`` password prompt."""
2
+
3
+ from .stars import stars
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["stars"]
@@ -0,0 +1,201 @@
1
+ """Core implementation of ``mukimov.stars``.
2
+
3
+ Cross-platform password prompt that echoes ``*`` for every typed character.
4
+ Standard library only.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import sys
10
+
11
+ __all__ = ["stars"]
12
+
13
+ ENTER_KEYS = ("\r", "\n")
14
+ BACKSPACE_KEYS = ("\x08", "\x7f")
15
+ INTERRUPT_KEY = "\x03" # Ctrl+C
16
+ EOF_KEY = "\x04" # Ctrl+D
17
+
18
+
19
+ def _process_keystrokes(keys) -> str:
20
+ """Pure, testable core logic: apply keys to a buffer.
21
+
22
+ - Normal printable char -> append.
23
+ - Backspace (``\\x08`` / ``\\x7f``) -> pop last char if any.
24
+ - Enter (``\\r`` / ``\\n``) -> stop and return result.
25
+ - Ctrl+C (``\\x03``) -> raise ``KeyboardInterrupt``.
26
+ - Ctrl+D (``\\x04``) on empty buffer -> raise ``EOFError``.
27
+ - Other control chars (ord < 32) -> ignored.
28
+ """
29
+ buf: list[str] = []
30
+ for key in keys:
31
+ if key in ENTER_KEYS:
32
+ break
33
+ if key in BACKSPACE_KEYS:
34
+ if buf:
35
+ buf.pop()
36
+ continue
37
+ if key == INTERRUPT_KEY:
38
+ raise KeyboardInterrupt
39
+ if key == EOF_KEY:
40
+ if not buf:
41
+ raise EOFError
42
+ continue
43
+ if len(key) != 1:
44
+ continue
45
+ if key in ("\x00", "\xe0", "\x1b"):
46
+ # Windows arrow/function-key prefixes and ESC: ignore.
47
+ continue
48
+ if ord(key) < 32:
49
+ # Ignore other control chars.
50
+ continue
51
+ buf.append(key)
52
+ return "".join(buf)
53
+
54
+
55
+ def _validate_mask(mask: str) -> str:
56
+ if not isinstance(mask, str):
57
+ raise TypeError("mask must be str")
58
+ if len(mask) != 1:
59
+ raise ValueError("mask must be a single character, e.g. '*'")
60
+ return mask
61
+
62
+
63
+ def stars(prompt: str = "Password: ", mask: str = "*") -> str:
64
+ """Read a password, echoing ``mask`` for each character.
65
+
66
+ Example:
67
+ >>> from mukimov import stars
68
+ >>> password = stars("Password: ")
69
+ Password: ********
70
+
71
+ Behaviour:
72
+ * Every typed character is immediately shown as ``mask``.
73
+ * Backspace removes the last ``mask`` symbol and char from result.
74
+ * Enter finishes input and prints a newline.
75
+ * The real password is never written to the terminal.
76
+ * Ctrl+C raises ``KeyboardInterrupt``, Ctrl+D on empty input
77
+ raises ``EOFError`` (like ``input()`` / ``getpass()``).
78
+
79
+ Falls back to :func:`getpass.getpass` (no echo) when stdin is not
80
+ a TTY (pipes, IDE consoles, CI).
81
+ """
82
+ _validate_mask(mask)
83
+ if not isinstance(prompt, str):
84
+ raise TypeError("prompt must be str")
85
+
86
+ if not sys.stdin.isatty():
87
+ import getpass
88
+
89
+ return getpass.getpass(prompt)
90
+
91
+ if sys.platform.startswith("win"):
92
+ return _stars_windows(prompt, mask)
93
+ return _stars_unix(prompt, mask)
94
+
95
+
96
+ def _stars_windows(prompt: str, mask: str) -> str:
97
+ import msvcrt
98
+
99
+ sys.stdout.write(prompt)
100
+ sys.stdout.flush()
101
+
102
+ buf: list[str] = []
103
+ # getwch handles Unicode correctly; fallback to getch for old Pythons.
104
+ getwch = getattr(msvcrt, "getwch", None)
105
+
106
+ def read_key() -> str:
107
+ if getwch is not None:
108
+ return getwch() # type: ignore[no-any-return]
109
+ ch = msvcrt.getch()
110
+ try:
111
+ return ch.decode("utf-8")
112
+ except UnicodeDecodeError:
113
+ return ch.decode("utf-8", errors="ignore")
114
+
115
+ try:
116
+ while True:
117
+ key = read_key()
118
+ # Arrow / function keys come as two codes: prefix + scan code.
119
+ if key in ("\x00", "\xe0"):
120
+ read_key() # discard scan code
121
+ continue
122
+ if key in ENTER_KEYS:
123
+ sys.stdout.write("\n")
124
+ sys.stdout.flush()
125
+ break
126
+ if key in BACKSPACE_KEYS:
127
+ if buf:
128
+ buf.pop()
129
+ sys.stdout.write("\b \b")
130
+ sys.stdout.flush()
131
+ continue
132
+ if key == INTERRUPT_KEY:
133
+ sys.stdout.write("\n")
134
+ sys.stdout.flush()
135
+ raise KeyboardInterrupt
136
+ if key == EOF_KEY:
137
+ if not buf:
138
+ sys.stdout.write("\n")
139
+ sys.stdout.flush()
140
+ raise EOFError
141
+ continue
142
+ if len(key) != 1 or ord(key) < 32:
143
+ continue
144
+ buf.append(key)
145
+ sys.stdout.write(mask)
146
+ sys.stdout.flush()
147
+ except KeyboardInterrupt:
148
+ # Let callers handle it; newline already printed.
149
+ raise
150
+ return "".join(buf)
151
+
152
+
153
+ def _stars_unix(prompt: str, mask: str) -> str:
154
+ import termios
155
+ import tty
156
+
157
+ fd = sys.stdin.fileno()
158
+ sys.stdout.write(prompt)
159
+ sys.stdout.flush()
160
+
161
+ old_settings = termios.tcgetattr(fd)
162
+ buf: list[str] = []
163
+ try:
164
+ tty.setraw(fd)
165
+ while True:
166
+ key = sys.stdin.read(1)
167
+ if not key:
168
+ # EOF (pipe closed unexpectedly).
169
+ raise EOFError
170
+ if key in ENTER_KEYS:
171
+ sys.stdout.write("\n")
172
+ sys.stdout.flush()
173
+ break
174
+ if key in BACKSPACE_KEYS:
175
+ if buf:
176
+ buf.pop()
177
+ sys.stdout.write("\b \b")
178
+ sys.stdout.flush()
179
+ continue
180
+ if key == INTERRUPT_KEY:
181
+ raise KeyboardInterrupt
182
+ if key == EOF_KEY:
183
+ if not buf:
184
+ raise EOFError
185
+ continue
186
+ if key == "\x1b":
187
+ # Escape sequence (arrows, Home/End...): consume rest.
188
+ # Most are 2 more chars like "[A". Read them non-blocking-ish.
189
+ sys.stdin.read(2)
190
+ continue
191
+ if len(key) != 1 or ord(key) < 32:
192
+ continue
193
+ buf.append(key)
194
+ sys.stdout.write(mask)
195
+ sys.stdout.flush()
196
+ finally:
197
+ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
198
+ # setraw disables echo/newline handling; ensure cursor on next line
199
+ # if we exited via exception before printing "\n".
200
+ sys.stdout.flush()
201
+ return "".join(buf)
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: mukimov
3
+ Version: 0.1.0
4
+ Summary: Tiny cross-platform password prompt that echoes * for each character
5
+ Author: mukimov
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/mukimov/mukimov
8
+ Keywords: password,getpass,stars,prompt,cli
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
12
+ Classifier: Topic :: Security
13
+ Classifier: Typing :: Typed
14
+ Requires-Python: >=3.8
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Dynamic: license-file
18
+
19
+ # mukimov
20
+
21
+ Tiny cross-platform Python library: password prompt that shows `*` for each typed character — like `getpass()`, but with visual feedback.
22
+
23
+ ```python
24
+ from mukimov import stars
25
+
26
+ password = stars("Password: ")
27
+ print(password)
28
+ ```
29
+
30
+ Terminal:
31
+
32
+ ```text
33
+ Password: ********
34
+ ```
35
+
36
+ `password` contains the real text (`"12345678"`), only `*` are shown on screen.
37
+
38
+ ## Features
39
+
40
+ - Only standard library, zero dependencies
41
+ - Windows (`msvcrt`) + Linux/macOS (`termios`/`tty`)
42
+ - Each character is immediately replaced with `*`
43
+ - Backspace correctly deletes the last `*`
44
+ - Enter finishes input
45
+ - Real password is never printed
46
+ - Ctrl+C → `KeyboardInterrupt`, Ctrl+D on empty input → `EOFError`
47
+ - Falls back to `getpass` (no echo) when stdin is not a TTY (pipes, IDE, CI)
48
+
49
+ ## Install
50
+
51
+ ```bash
52
+ pip install .
53
+ ```
54
+
55
+ For development:
56
+
57
+ ```bash
58
+ pip install -e .[test] # or: pip install -e . && pip install pytest
59
+ pytest -q
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ```python
65
+ from mukimov import stars
66
+
67
+ username = input("Username: ")
68
+ password = stars("Password: ")
69
+
70
+ print(username)
71
+ ```
72
+
73
+ ```text
74
+ Username: mukimov
75
+ Password: ********
76
+ ```
77
+
78
+ Custom mask character:
79
+
80
+ ```python
81
+ password = stars("Password: ", mask="#")
82
+ ```
83
+
84
+ ## Build & publish to PyPI
85
+
86
+ ```bash
87
+ python -m pip install --upgrade build twine
88
+ python -m build
89
+ python -m twine check dist/*
90
+ python -m twine upload dist/*
91
+ ```
92
+
93
+ Test PyPI first:
94
+
95
+ ```bash
96
+ python -m twine upload --repository testpypi dist/*
97
+ pip install --index-url https://test.pypi.org/simple/ mukimov
98
+ ```
99
+
100
+ ## License
101
+
102
+ MIT
@@ -0,0 +1,10 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ mukimov/__init__.py
5
+ mukimov/stars.py
6
+ mukimov.egg-info/PKG-INFO
7
+ mukimov.egg-info/SOURCES.txt
8
+ mukimov.egg-info/dependency_links.txt
9
+ mukimov.egg-info/top_level.txt
10
+ tests/test_stars.py
@@ -0,0 +1 @@
1
+ mukimov
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "mukimov"
7
+ version = "0.1.0"
8
+ description = "Tiny cross-platform password prompt that echoes * for each character"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "mukimov" }]
13
+ keywords = ["password", "getpass", "stars", "prompt", "cli"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "Operating System :: OS Independent",
17
+ "Topic :: Software Development :: Libraries :: Python Modules",
18
+ "Topic :: Security",
19
+ "Typing :: Typed",
20
+ ]
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/mukimov/mukimov"
24
+
25
+ [tool.setuptools.packages.find]
26
+ include = ["mukimov*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ """Tests for mukimov core logic (no real terminal needed)."""
2
+
3
+ import unittest
4
+
5
+ from mukimov import stars
6
+ from mukimov.stars import _process_keystrokes, _validate_mask
7
+
8
+
9
+ class TestProcessKeystrokes(unittest.TestCase):
10
+ def test_simple_input_enter(self):
11
+ self.assertEqual(_process_keystrokes(list("12345678") + ["\r"]), "12345678")
12
+ self.assertEqual(_process_keystrokes(list("abc") + ["\n"]), "abc")
13
+
14
+ def test_backspace_bs(self):
15
+ self.assertEqual(_process_keystrokes(["a", "b", "\x08", "c", "\r"]), "ac")
16
+
17
+ def test_backspace_del(self):
18
+ self.assertEqual(_process_keystrokes(["a", "b", "\x7f", "c", "\r"]), "ac")
19
+
20
+ def test_backspace_on_empty_ignored(self):
21
+ self.assertEqual(_process_keystrokes(["\x08", "\x7f", "a", "\r"]), "a")
22
+
23
+ def test_multiple_backspaces(self):
24
+ self.assertEqual(_process_keystrokes(list("abcd") + ["\x08", "\x08", "\r"]), "ab")
25
+
26
+ def test_ctrl_c_raises(self):
27
+ with self.assertRaises(KeyboardInterrupt):
28
+ _process_keystrokes(["a", "\x03"])
29
+
30
+ def test_ctrl_d_on_empty_raises_eof(self):
31
+ with self.assertRaises(EOFError):
32
+ _process_keystrokes(["\x04"])
33
+
34
+ def test_ctrl_d_with_content_ignored(self):
35
+ self.assertEqual(_process_keystrokes(["a", "\x04", "b", "\r"]), "ab")
36
+
37
+ def test_control_chars_ignored(self):
38
+ self.assertEqual(_process_keystrokes(["a", "\x00", "\xe0", "\x1b", "b", "\r"]), "ab")
39
+
40
+ def test_unicode(self):
41
+ self.assertEqual(_process_keystrokes(list("пароль") + ["\r"]), "пароль")
42
+
43
+
44
+ class TestApi(unittest.TestCase):
45
+ def test_stars_importable_and_callable(self):
46
+ self.assertTrue(callable(stars))
47
+
48
+ def test_validate_mask_ok(self):
49
+ self.assertEqual(_validate_mask("*"), "*")
50
+ self.assertEqual(_validate_mask("#"), "#")
51
+
52
+ def test_validate_mask_bad(self):
53
+ with self.assertRaises(ValueError):
54
+ _validate_mask("**")
55
+ with self.assertRaises(ValueError):
56
+ _validate_mask("")
57
+ with self.assertRaises(TypeError):
58
+ _validate_mask(123) # type: ignore[arg-type]
59
+
60
+
61
+ if __name__ == "__main__":
62
+ unittest.main()