D-Difficulty 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,282 @@
1
+ """
2
+ D - Difficulty
3
+ ==============
4
+
5
+ Librería Python de un solo archivo, EXTREMADAMENTE difícil de usar.
6
+ No hay documentación. No hay ayuda. Solo existe D.
7
+
8
+ >>> import D
9
+ >>> D.???
10
+
11
+ Suerte.
12
+ """
13
+
14
+ import base64 as _b64
15
+ import zlib as _z
16
+ import hashlib as _hl
17
+ import sys as _sys
18
+
19
+ __all__ = ['D', '__version__']
20
+
21
+
22
+ # ---------------------------------------------------------------------------
23
+ # Codificación (para que nada sea legible a simple vista)
24
+ # ---------------------------------------------------------------------------
25
+
26
+ def _e(s: str) -> str:
27
+ return _b64.b85encode(_z.compress(s.encode('utf-8'))).decode('ascii')
28
+
29
+
30
+ def _d(s: str) -> str:
31
+ return _z.decompress(_b64.b85decode(s.encode('ascii'))).decode('utf-8')
32
+
33
+
34
+ __version__ = "0.1." + str(len(_e("difficulty")) % 100)
35
+
36
+
37
+ if _sys.version_info < (3, 7):
38
+ raise RuntimeError(_d(_e("Python 3.7+ required")))
39
+
40
+
41
+ # ---------------------------------------------------------------------------
42
+ # Estado global (sí, mutable, sí, oculto)
43
+ # ---------------------------------------------------------------------------
44
+
45
+ class _S:
46
+ level = 1
47
+ calls = 0
48
+ unlocked = False
49
+ attempts = 0
50
+ _pw = _d(_e("open sesame")) # <- pista escondida
51
+
52
+ @classmethod
53
+ def bump(cls):
54
+ cls.calls += 1
55
+
56
+ @classmethod
57
+ def reset(cls):
58
+ cls.level = 1
59
+ cls.calls = 0
60
+ cls.unlocked = False
61
+ cls.attempts = 0
62
+
63
+
64
+ # ---------------------------------------------------------------------------
65
+ # Symbol: cada atributo desconocido de D devuelve uno de estos
66
+ # ---------------------------------------------------------------------------
67
+
68
+ class _Symbol:
69
+ __slots__ = ('_path',)
70
+
71
+ def __init__(self, path):
72
+ self._path = path
73
+
74
+ def __call__(self, *a, **k):
75
+ return _dispatch(self._path, a, k)
76
+
77
+ def __getattr__(self, name):
78
+ if name.startswith('__') and name.endswith('__'):
79
+ raise AttributeError(name)
80
+ return _Symbol(f"{self._path}.{name}")
81
+
82
+ def __getitem__(self, key):
83
+ return _dispatch(self._path + '@get', (key,), {})
84
+
85
+ def __repr__(self):
86
+ return f"<D/{self._path}>"
87
+
88
+ def __bool__(self):
89
+ return True
90
+
91
+ def __or__(self, other):
92
+ return _Symbol(f"({self._path} | {other!r})")
93
+
94
+ def __and__(self, other):
95
+ return _Symbol(f"({self._path} & {other!r})")
96
+
97
+ def __hash__(self):
98
+ return hash(self._path)
99
+
100
+
101
+ # ---------------------------------------------------------------------------
102
+ # Resultado "encriptado" (nivel 5)
103
+ # ---------------------------------------------------------------------------
104
+
105
+ class _Encoded:
106
+ __slots__ = ('_v',)
107
+
108
+ def __init__(self, v):
109
+ self._v = v
110
+
111
+ def get(self):
112
+ return self._v
113
+
114
+ def __repr__(self):
115
+ h = _hl.md5(str(self._v).encode()).hexdigest()[:8]
116
+ return f"<_Encoded #{h}>"
117
+
118
+ def __int__(self):
119
+ return int(self._v)
120
+
121
+ def __str__(self):
122
+ return str(self._v)
123
+
124
+
125
+ # ---------------------------------------------------------------------------
126
+ # Operaciones aritméticas "normales" (según el nivel)
127
+ # ---------------------------------------------------------------------------
128
+
129
+ def _reverse_int(n):
130
+ if n == 0:
131
+ return 0
132
+ sign = -1 if n < 0 else 1
133
+ s = str(abs(n))[::-1]
134
+ return sign * int(s)
135
+
136
+
137
+ def _op_add(args, kwargs, lvl):
138
+ if lvl == 1:
139
+ return sum(args) if args else 0
140
+ if lvl == 2:
141
+ if set(kwargs) == {'a', 'b'} and not args:
142
+ return kwargs['a'] + kwargs['b']
143
+ raise TypeError("add() en nivel 2 exige kwargs a=, b=")
144
+ if lvl == 3:
145
+ r = sum(args) if args else 0
146
+ return _reverse_int(r) if isinstance(r, int) else r
147
+ if lvl == 4:
148
+ if not _S.unlocked:
149
+ raise PermissionError("locked. usa D.unlock(pw)")
150
+ return sum(args) if args else 0
151
+ if lvl == 5:
152
+ if not _S.unlocked:
153
+ raise PermissionError("locked. usa D.unlock(pw)")
154
+ return _Encoded(sum(args) if args else 0)
155
+ return sum(args) if args else 0
156
+
157
+
158
+ def _op_sub(args, kwargs, lvl):
159
+ if lvl == 1 and len(args) == 2:
160
+ return args[0] - args[1]
161
+ return args[0] - args[1] if len(args) == 2 else 0
162
+
163
+
164
+ def _op_mul(args, kwargs, lvl):
165
+ r = 1
166
+ for a in args:
167
+ r *= a
168
+ return r
169
+
170
+
171
+ def _op_pow(args, kwargs, lvl):
172
+ return args[0] ** args[1] if len(args) == 2 else 0
173
+
174
+
175
+ # ---------------------------------------------------------------------------
176
+ # Dispatcher: el corazón de todo
177
+ # ---------------------------------------------------------------------------
178
+
179
+ def _dispatch(name, args, kwargs):
180
+ _S.bump()
181
+ lvl = _S.level
182
+
183
+ if name == 'hello':
184
+ return _d(_e("hello, world"))
185
+
186
+ if name == 'add':
187
+ return _op_add(args, kwargs, lvl)
188
+ if name == 'sub':
189
+ return _op_sub(args, kwargs, lvl)
190
+ if name == 'mul':
191
+ return _op_mul(args, kwargs, lvl)
192
+ if name == 'pow':
193
+ return _op_pow(args, kwargs, lvl)
194
+
195
+ if name == 'state':
196
+ return {
197
+ 'level': _S.level,
198
+ 'calls': _S.calls,
199
+ 'unlocked': _S.unlocked,
200
+ 'attempts': _S.attempts,
201
+ }
202
+
203
+ if name == 'level':
204
+ if not args:
205
+ return _S.level
206
+ try:
207
+ n = int(args[0])
208
+ except Exception:
209
+ return False
210
+ if 1 <= n <= 5:
211
+ _S.level = n
212
+ return True
213
+ return False
214
+
215
+ if name == 'unlock':
216
+ _S.attempts += 1
217
+ if args and args[0] == _S._pw:
218
+ _S.unlocked = True
219
+ return True
220
+ return False
221
+
222
+ if name == 'secret':
223
+ if _S.unlocked:
224
+ return _d(_e("the cake is a lie"))
225
+ return "locked"
226
+
227
+ if name == 'reset':
228
+ _S.reset()
229
+ return True
230
+
231
+ if name == 'puzzle':
232
+ return _d(_e(
233
+ "Niveles 4 y 5 estan bloqueados. "
234
+ "Para desbloquear, llama D.unlock(pw). "
235
+ "La contrasena esta escondida en el codigo fuente. "
236
+ "Pista: son dos palabras, minusculas, separadas por espacio."
237
+ ))
238
+
239
+ if name == 'help':
240
+ return "No."
241
+
242
+ if name == 'reveal':
243
+ return _d(_e("Revelado: nada. La dificultad es el punto."))
244
+
245
+ return _Symbol(name)
246
+
247
+
248
+ # ---------------------------------------------------------------------------
249
+ # D
250
+ # ---------------------------------------------------------------------------
251
+
252
+ class _DMeta(type):
253
+ def __getattr__(cls, name):
254
+ if name.startswith('_'):
255
+ raise AttributeError(name)
256
+ return _Symbol(name)
257
+
258
+ def __repr__(cls):
259
+ return "<module D: Difficulty>"
260
+
261
+ def __call__(cls, *a, **k):
262
+ return _Symbol("()")
263
+
264
+
265
+ class D(metaclass=_DMeta):
266
+ """El único. Suerte."""
267
+
268
+
269
+ # ---------------------------------------------------------------------------
270
+ # __getattr__ a nivel de módulo (PEP 562) - para confusión máxima
271
+ # ---------------------------------------------------------------------------
272
+
273
+ def __getattr__(name):
274
+ if name.startswith('__'):
275
+ raise AttributeError(name)
276
+ return getattr(D, name)
277
+
278
+
279
+ def __dir__():
280
+ return ['D', '__version__', 'hello', 'add', 'sub', 'mul', 'pow',
281
+ 'level', 'unlock', 'secret', 'state', 'reset', 'puzzle',
282
+ 'reveal', 'help']
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: D-Difficulty
3
+ Version: 0.1.0
4
+ Summary: D — Difficulty. Una librería EXTREMADAMENTE difícil. Sin docs. Sin piedad.
5
+ Author-email: Anónimo <nadie@example.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://example.com/D
8
+ Project-URL: Source, https://example.com/D.git
9
+ Project-URL: Bug Tracker, https://example.com/D/issues
10
+ Keywords: difficulty,puzzle,obfuscation,d,sadico
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Classifier: Topic :: Games/Entertainment :: Puzzle Games
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ Provides-Extra: test
22
+ Requires-Dist: pytest>=7; extra == "test"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7; extra == "dev"
25
+ Requires-Dist: build; extra == "dev"
26
+ Requires-Dist: twine; extra == "dev"
27
+
28
+ # D — Difficulty
29
+
30
+ Una librería de Python intencionalmente difícil de usar. Sin piedad. 🧩
31
+
32
+ **D-Difficulty** es un pequeño proyecto de experimentación y humor para jugar con una API misteriosa: atributos dinámicos, niveles de dificultad, operaciones aritméticas y secretos por desbloquear.
33
+
34
+ ## Instalación
35
+
36
+ ```bash
37
+ python -m pip install D-Difficulty
38
+ ```
39
+
40
+ ## Ejemplo
41
+
42
+ ```python
43
+ import D
44
+
45
+ print(D.hello())
46
+ print(D.add(2, 3))
47
+ print(D.state())
48
+ ```
49
+
50
+ La API cambia según el nivel de dificultad:
51
+
52
+ ```python
53
+ import D
54
+
55
+ D.level(2)
56
+ print(D.add(a=2, b=3))
57
+ ```
58
+
59
+ Explora el código fuente para descubrir el resto. La dificultad es parte del chiste. 😉
60
+
61
+ ## Requisitos
62
+
63
+ - Python 3.7 o superior.
64
+
65
+ ## Licencia
66
+
67
+ MIT. Consulta el archivo `LICENSE` del repositorio para los términos completos.
68
+
69
+ ## Proyecto
70
+
71
+ Repositorio: https://github.com/programador777lolxddd-dot/D---Difilculty-
@@ -0,0 +1,8 @@
1
+ D.py
2
+ README.md
3
+ pyproject.toml
4
+ D_Difficulty.egg-info/PKG-INFO
5
+ D_Difficulty.egg-info/SOURCES.txt
6
+ D_Difficulty.egg-info/dependency_links.txt
7
+ D_Difficulty.egg-info/requires.txt
8
+ D_Difficulty.egg-info/top_level.txt
@@ -0,0 +1,8 @@
1
+
2
+ [dev]
3
+ pytest>=7
4
+ build
5
+ twine
6
+
7
+ [test]
8
+ pytest>=7
@@ -0,0 +1,71 @@
1
+ Metadata-Version: 2.4
2
+ Name: D-Difficulty
3
+ Version: 0.1.0
4
+ Summary: D — Difficulty. Una librería EXTREMADAMENTE difícil. Sin docs. Sin piedad.
5
+ Author-email: Anónimo <nadie@example.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://example.com/D
8
+ Project-URL: Source, https://example.com/D.git
9
+ Project-URL: Bug Tracker, https://example.com/D/issues
10
+ Keywords: difficulty,puzzle,obfuscation,d,sadico
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Classifier: Topic :: Games/Entertainment :: Puzzle Games
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.7
20
+ Description-Content-Type: text/markdown
21
+ Provides-Extra: test
22
+ Requires-Dist: pytest>=7; extra == "test"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7; extra == "dev"
25
+ Requires-Dist: build; extra == "dev"
26
+ Requires-Dist: twine; extra == "dev"
27
+
28
+ # D — Difficulty
29
+
30
+ Una librería de Python intencionalmente difícil de usar. Sin piedad. 🧩
31
+
32
+ **D-Difficulty** es un pequeño proyecto de experimentación y humor para jugar con una API misteriosa: atributos dinámicos, niveles de dificultad, operaciones aritméticas y secretos por desbloquear.
33
+
34
+ ## Instalación
35
+
36
+ ```bash
37
+ python -m pip install D-Difficulty
38
+ ```
39
+
40
+ ## Ejemplo
41
+
42
+ ```python
43
+ import D
44
+
45
+ print(D.hello())
46
+ print(D.add(2, 3))
47
+ print(D.state())
48
+ ```
49
+
50
+ La API cambia según el nivel de dificultad:
51
+
52
+ ```python
53
+ import D
54
+
55
+ D.level(2)
56
+ print(D.add(a=2, b=3))
57
+ ```
58
+
59
+ Explora el código fuente para descubrir el resto. La dificultad es parte del chiste. 😉
60
+
61
+ ## Requisitos
62
+
63
+ - Python 3.7 o superior.
64
+
65
+ ## Licencia
66
+
67
+ MIT. Consulta el archivo `LICENSE` del repositorio para los términos completos.
68
+
69
+ ## Proyecto
70
+
71
+ Repositorio: https://github.com/programador777lolxddd-dot/D---Difilculty-
@@ -0,0 +1,44 @@
1
+ # D — Difficulty
2
+
3
+ Una librería de Python intencionalmente difícil de usar. Sin piedad. 🧩
4
+
5
+ **D-Difficulty** es un pequeño proyecto de experimentación y humor para jugar con una API misteriosa: atributos dinámicos, niveles de dificultad, operaciones aritméticas y secretos por desbloquear.
6
+
7
+ ## Instalación
8
+
9
+ ```bash
10
+ python -m pip install D-Difficulty
11
+ ```
12
+
13
+ ## Ejemplo
14
+
15
+ ```python
16
+ import D
17
+
18
+ print(D.hello())
19
+ print(D.add(2, 3))
20
+ print(D.state())
21
+ ```
22
+
23
+ La API cambia según el nivel de dificultad:
24
+
25
+ ```python
26
+ import D
27
+
28
+ D.level(2)
29
+ print(D.add(a=2, b=3))
30
+ ```
31
+
32
+ Explora el código fuente para descubrir el resto. La dificultad es parte del chiste. 😉
33
+
34
+ ## Requisitos
35
+
36
+ - Python 3.7 o superior.
37
+
38
+ ## Licencia
39
+
40
+ MIT. Consulta el archivo `LICENSE` del repositorio para los términos completos.
41
+
42
+ ## Proyecto
43
+
44
+ Repositorio: https://github.com/programador777lolxddd-dot/D---Difilculty-
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ # ---------------------------------------------------------------------------
6
+ # Metadatos del proyecto
7
+ # ---------------------------------------------------------------------------
8
+ [project]
9
+ name = "D-Difficulty"
10
+ version = "0.1.0" # ← sincronízalo con __version__ si quieres
11
+ description = "D — Difficulty. Una librería EXTREMADAMENTE difícil. Sin docs. Sin piedad."
12
+ readme = "README.md"
13
+ requires-python = ">=3.7"
14
+ license = { text = "MIT" }
15
+ authors = [{ name = "Anónimo", email = "nadie@example.com" }]
16
+ keywords = ["difficulty", "puzzle", "obfuscation", "d", "sadico"]
17
+ classifiers = [
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Operating System :: OS Independent",
22
+ "Topic :: Software Development :: Libraries",
23
+ "Topic :: Games/Entertainment :: Puzzle Games",
24
+ "Intended Audience :: Developers",
25
+ "Typing :: Typed",
26
+ ]
27
+
28
+ # Sin dependencias. La dificultad es toda tuya.
29
+ dependencies = []
30
+
31
+ [project.optional-dependencies]
32
+ # Aunque no las uses, están aquí para confundir.
33
+ test = ["pytest>=7"]
34
+ dev = ["pytest>=7", "build", "twine"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://example.com/D"
38
+ Source = "https://example.com/D.git"
39
+ "Bug Tracker" = "https://example.com/D/issues"
40
+ # Nota: no hay documentación a propósito.
41
+
42
+ # ---------------------------------------------------------------------------
43
+ # Configuración de setuptools: empaquetar D.py como módulo único
44
+ # ---------------------------------------------------------------------------
45
+ [tool.setuptools]
46
+ py-modules = ["D"] # ← esto es lo que mete D.py en el wheel
47
+ include-package-data = true
48
+
49
+ [tool.setuptools.package-data]
50
+ # nada: es un solo .py
51
+
52
+ # ---------------------------------------------------------------------------
53
+ # Opcional: chequeo de tipos
54
+ # ---------------------------------------------------------------------------
55
+ [tool.mypy]
56
+ python_version = "3.7"
57
+ ignore_missing_imports = true
58
+ # D no se puede tipar. Ni lo intentes.
59
+
60
+ # ---------------------------------------------------------------------------
61
+ # Opcional: pytest (aunque D.help() devuelve "No.")
62
+ # ---------------------------------------------------------------------------
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["tests"]
65
+ addopts = "-q"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+