librecoding 0.1.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.5
2
2
  Name: librecoding
3
- Version: 0.1.0
3
+ Version: 0.3.0
4
4
  Summary: Free and open-source coding library
5
5
  Author: ar
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "librecoding"
7
- version = "0.1.0"
7
+ version = "0.3.0"
8
8
  description = "Free and open-source coding library"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1,43 @@
1
+ """librecoding - модуль, который можно вызвать как функцию."""
2
+
3
+ import sys
4
+ from types import ModuleType
5
+
6
+ from .core import greet
7
+
8
+ __version__ = "0.3.0"
9
+
10
+ BANNER = "Привет, мир! (из librecoding)"
11
+ PROMPT = "Нажми Enter, чтобы закрыть..."
12
+
13
+
14
+ def hello() -> str:
15
+ """Явный способ попросить приветствие."""
16
+ print(BANNER)
17
+ return BANNER
18
+
19
+
20
+ def pause(prompt: str = PROMPT) -> None:
21
+ """Ждёт Enter, чтобы терминал не закрылся сразу."""
22
+ if not sys.stdin.isatty():
23
+ return
24
+ try:
25
+ input(prompt)
26
+ except (EOFError, KeyboardInterrupt):
27
+ print()
28
+
29
+
30
+ class _LibreCodingModule(ModuleType):
31
+ """Модуль, который ведёт себя как функция: librecoding()."""
32
+
33
+ def __call__(self, obj=None, *args, **kwargs):
34
+ print(BANNER)
35
+ if callable(obj) and not args and not kwargs:
36
+ return obj
37
+ pause()
38
+ return BANNER
39
+
40
+
41
+ sys.modules[__name__].__class__ = _LibreCodingModule
42
+
43
+ __all__ = ["greet", "hello", "pause", "BANNER"]
@@ -0,0 +1,5 @@
1
+ def greet(name: str = "мир") -> str:
2
+ """Печатает и возвращает приветствие."""
3
+ msg = f"Привет, {name}!"
4
+ print(msg)
5
+ return msg
@@ -1,3 +0,0 @@
1
- from .core import greet
2
- __all__ = ["greet"]
3
- __version__ = "0.1.0"
@@ -1,2 +0,0 @@
1
- def greet(name: str) -> str:
2
- return f"Привет, {name}!"
File without changes