modxpy 1.24.1__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.
modxpy-1.24.1/PKG-INFO ADDED
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.4
2
+ Name: modxpy
3
+ Version: 1.24.1
4
+ Summary: ModX — The Python Module Universe at Your Fingertips
5
+ Home-page: https://github.com/yourusername/modx
6
+ Author: Austin Wang
7
+ Author-email: austinw87654@gmail.com
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: home-page
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ # ModX
19
+
20
+ ModX — The Python Module Universe at Your Fingertips.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install modx
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ import modx
32
+
33
+ modx.import_all()
34
+ modx.imported()
35
+ ```
@@ -0,0 +1,18 @@
1
+ # ModX
2
+
3
+ ModX — The Python Module Universe at Your Fingertips.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install modx
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ import modx
15
+
16
+ modx.import_all()
17
+ modx.imported()
18
+ ```
@@ -0,0 +1,2 @@
1
+ # You can paste your modx.py contents here or import from modx.py
2
+ from .modx import *
@@ -0,0 +1,299 @@
1
+ '''modx.py: A module whose functions have to do with other modules.
2
+ For example: importall(), a
3
+ function used to import every single source-based module
4
+ (except for some modules, because it's popular like math, sys, etc.)
5
+ in Python that is supported on computer, does not print
6
+ out dialogue nor pop out a link when imported, and not required to be
7
+ downloaded seperatly with Python (such as Pygame, downloaded in Terminal).
8
+
9
+ Modules ios_support, pty, this, sre_compile, sre_parse,
10
+ sre_constants, tty and antigravity are left out,
11
+ due to ios_support not supporting computers,
12
+ pty and tty importing a non-existing module (termios),
13
+ sre_compile, sre_constants and sre_parse printing warnings,
14
+ this printing out "The Zen of Python" poem,
15
+ and antigravity popping out a web browser link.
16
+
17
+ Permission to use this module is granted to anyone wanting to use it,
18
+ under the following conditions: 1.) Any copies of this module must be clearly
19
+ marked as so. 2.) The original of this module must not be misrepresented;
20
+ you cannot claim this module is yours.
21
+
22
+ Note: for imported(), module idlelib will not show up as it is pre-imported
23
+ as soon as this module is run, leading to problems and bugs, thus idlelib
24
+ is not shown in imported().
25
+
26
+ Created by: Austin Wang. Created at: September 19, 2025. Version: 1.24.1'''
27
+
28
+ import sys, importlib, pkgutil, random
29
+
30
+ # Record what modules were loaded at the time modx itself was imported
31
+ _initial_modules = set(sys.modules.keys())
32
+ import builtins
33
+
34
+ # Capture original __import__ BEFORE overriding
35
+ _original_import = builtins.__import__
36
+
37
+ # Track modules imported manually by the user after ModX loaded
38
+ _user_imports = set()
39
+
40
+ def _tracking_import(name, globals=None, locals=None, fromlist=(), level=0):
41
+ """
42
+ Non-public function: wrapper around Python's import to record user imports,
43
+ even if the module was already loaded.
44
+ """
45
+ # Use the *original* import function to avoid recursion
46
+ mod = _original_import(name, globals, locals, fromlist, level)
47
+ top_name = name.split('.')[0]
48
+ if not name.startswith('idlelib'):
49
+ _user_imports.add(top_name)
50
+ return mod
51
+
52
+ # Install the hook immediately when ModX is imported
53
+ builtins.__import__ = _tracking_import
54
+
55
+ _imported_by_modx = set()
56
+ # Track modules at the last imported() call
57
+ _last_imported_snapshot = set(_initial_modules)
58
+
59
+
60
+ modules = [
61
+ 'collections', 'sys', 'asyncio', 'concurrent', 'ctypes', 'dbm', 'email',
62
+ 'encodings', 'ensurepip', 'html', 'http', 'idlelib', 'importlib', 'json', 'logging',
63
+ 'multiprocessing', 'pathlib', 'pydoc_data', 're', 'sqlite3',
64
+ 'sysconfig', 'test', 'tkinter', 'tomllib', 'turtledemo', 'unittest', 'urllib',
65
+ 'venv', 'wsgiref', 'xml', 'xmlrpc', 'zipfile', 'zoneinfo', '_aix_support',
66
+ '_android_support', '_pyrepl', '_apple_support', '_collections_abc', '_colorize',
67
+ '_compat_pickle', '_compression', '_markupbase', '_opcode_metadata', '_osx_support',
68
+ '_py_abc', '_pydatetime', '_pydecimal', '_pyio', '_pylong', '_sitebuiltins', '_strptime',
69
+ '_threading_local', '_weakrefset', 'abc', 'argparse', 'ast', 'base64', 'bdb',
70
+ 'bisect', 'bz2', 'calendar', 'cmd', 'codecs', 'codeop', 'colorsys', 'compileall', 'configparser',
71
+ 'contextlib', 'contextvars', 'copy', 'copyreg', 'cProfile', 'csv', 'dataclasses', 'datetime',
72
+ 'decimal', 'difflib', 'dis', 'doctest', 'enum', 'filecmp', 'fileinput', 'fnmatch', 'fractions',
73
+ 'ftplib', 'functools', 'genericpath', 'getopt', 'getpass', 'gettext', 'glob', 'graphlib',
74
+ 'gzip', 'hashlib', 'heapq', 'hmac', 'imaplib', 'inspect', 'io', 'ipaddress', 'keyword', 'linecache',
75
+ 'locale', 'lzma', 'math', 'mailbox', 'mimetypes', 'modulefinder', 'netrc', 'ntpath', 'nturl2path',
76
+ 'numbers', 'opcode', 'operator', 'optparse', 'os', 'pdb', 'pickle', 'pickletools', 'pkgutil',
77
+ 'platform', 'plistlib', 'poplib', 'posixpath', 'pprint', 'profile', 'pstats', 'py_compile',
78
+ 'pyclbr', 'pydoc', 'queue', 'quopri', 'random', 'reprlib', 'rlcompleter', 'runpy', 'sched', 'secrets',
79
+ 'selectors', 'shelve', 'shlex', 'shutil', 'signal', 'site', 'smtplib', 'socket', 'socketserver',
80
+ 'ssl', 'stat', 'statistics', 'string', 'stringprep',
81
+ 'struct', 'subprocess', 'symtable', 'tabnanny', 'tarfile', 'tempfile', 'textwrap',
82
+ 'threading', 'timeit', 'token', 'tokenize', 'trace', 'traceback', 'tracemalloc', 'turtle',
83
+ 'types', 'typing', 'uuid', 'warnings', 'wave', 'weakref', 'webbrowser', 'zipapp', 'zipimport',
84
+ '__future__', '__hello__', '__phello__', "atexit", "mmap"
85
+ ]
86
+
87
+
88
+ def import_all():
89
+ """Import about every module in Python
90
+ that is given when downloading Python."""
91
+ for m in modules:
92
+ try:
93
+ globals()[m] = importlib.import_module(m)
94
+ _imported_by_modx.add(m.split('.')[0])
95
+ except Exception:
96
+ pass
97
+
98
+ def list_importall():
99
+ """Return the list of modules that import_all() will """
100
+ return modules
101
+
102
+ def modules_loaded():
103
+ """Shows how many modules are currently loaded in sys.modules."""
104
+ return len(sys.modules)
105
+
106
+ def import_random(n):
107
+ """Import n random stdlib modules and track them."""
108
+ chosen = random.sample(modules, min(n, len(modules)))
109
+ for m in chosen:
110
+ try:
111
+ globals()[m] = importlib.import_module(m)
112
+ _imported_by_modx.add(m.split('.')[0]) # track top-level name
113
+ except Exception:
114
+ pass
115
+ return chosen
116
+
117
+ def import_external():
118
+ """Import all installed third-party
119
+ modules (anything not in stdlib list)."""
120
+ stdlib_set = set(modules) | set(sys.builtin_module_names)
121
+ for finder, name, ispkg in pkgutil.iter_modules():
122
+ if name not in stdlib_set:
123
+ try:
124
+ globals()[name] = importlib.import_module(name)
125
+ _imported_by_modx.add(name.split('.')[0])
126
+ except Exception:
127
+ pass
128
+
129
+ def import_screen():
130
+ """Import common screen/GUI/game
131
+ modules if available."""
132
+ screen_modules = ['pygame', 'pyglet', 'arcade', 'tkinter', 'turtle']
133
+ for m in screen_modules:
134
+ try:
135
+ globals()[m] = importlib.import_module(m)
136
+ _imported_by_modx.add(m.split('.')[0])
137
+ except ImportError:
138
+ pass
139
+
140
+ def imported():
141
+ """
142
+ Show all modules imported since ModX loaded:
143
+ imported by user, modx or modules imported
144
+ by other imported modules. This counts imports
145
+ even if the module was already loaded before ModX started.
146
+ """
147
+ # Union of user imports and ModX imports
148
+ all_new = _user_imports | _imported_by_modx
149
+
150
+ all_new_sorted = sorted(all_new)
151
+ print("Modules imported after ModX load (user, ModX and dependencies):")
152
+ for name in all_new_sorted:
153
+ print("-", name)
154
+ print(f"\nTotal modules imported after ModX load: {len(all_new_sorted)}")
155
+
156
+ def modximported():
157
+ """
158
+ Show only the modules imported via ModX functions
159
+ (import_all, import_random, import_external, import_screen),
160
+ plus a total count.
161
+ """
162
+ top_level_sorted = sorted(_imported_by_modx)
163
+ print("Modules imported via ModX:")
164
+ for name in top_level_sorted:
165
+ print("-", name)
166
+ print(f"\nTotal modules imported via ModX: {len(top_level_sorted)}")
167
+
168
+ def import_letter(letter):
169
+ """
170
+ Import every standard library module from the ModX 'modules' list
171
+ whose name starts with the given letter (case-insensitive).
172
+
173
+ Example:
174
+ import_letter('t') # imports turtle, tkinter, tarfile, etc.
175
+ """
176
+ letter = letter.lower()
177
+ imported_list = []
178
+
179
+ for m in modules:
180
+ if m.lower().startswith(letter):
181
+ try:
182
+ globals()[m] = importlib.import_module(m)
183
+ _imported_by_modx.add(m.split('.')[0]) # track it
184
+ imported_list.append(m)
185
+ except Exception:
186
+ pass # skip modules that can't be imported
187
+
188
+ return imported_list
189
+
190
+ def search_modules(keyword):
191
+ """
192
+ Search for modules whose names or docstrings contain the keyword.
193
+ """
194
+ keyword = keyword.lower()
195
+ matches = []
196
+ for m in modules:
197
+ if keyword in m.lower():
198
+ matches.append(m)
199
+ else:
200
+ try:
201
+ mod = importlib.import_module(m)
202
+ if mod.__doc__ and keyword in mod.__doc__.lower():
203
+ matches.append(m)
204
+ except Exception:
205
+ pass
206
+ return matches
207
+
208
+
209
+ def info(module_name):
210
+ """
211
+ Show basic info about a module: file path, built-in status, docstring.
212
+ """
213
+ import sys, inspect
214
+ if module_name in sys.modules:
215
+ mod = sys.modules[module_name]
216
+ else:
217
+ try:
218
+ mod = importlib.import_module(module_name)
219
+ except ImportError:
220
+ print(f"Module '{module_name}' not found.")
221
+ return
222
+ path = getattr(mod, '__file__', '(built-in)')
223
+ doc = (inspect.getdoc(mod) or '').splitlines()[0:3]
224
+ print(f"Module: {module_name}")
225
+ print(f"Path: {path}")
226
+ print("Docstring:")
227
+ for line in doc:
228
+ print(line)
229
+
230
+
231
+
232
+ def modxhelp():
233
+ """
234
+ Show full ModX help including all functions and example usage.
235
+ """
236
+ help_text = """
237
+ ModX — The Python Module Universe
238
+ =================================
239
+
240
+ Functions:
241
+ ----------
242
+
243
+ import_all()
244
+ Import almost every standard library module at once.
245
+ Example: modx.import_all()
246
+
247
+ import_external()
248
+ Import all installed third-party modules.
249
+ Example: modx.import_external()
250
+
251
+ import_screen()
252
+ Import common screen/GUI/game modules if available (pygame, turtle, tkinter, etc.).
253
+ Example: modx.import_screen()
254
+
255
+ import_letter(letter)
256
+ Import every standard library module starting with a given letter.
257
+ Example: modx.import_letter('t')
258
+
259
+ import_random(n)
260
+ Import n random standard library modules.
261
+ Example: modx.import_random(5)
262
+
263
+ list_importall()
264
+ Return a list of modules that import_all() would load.
265
+ Example: modx.list_importall()
266
+
267
+ modules_loaded()
268
+ Show how many top-level modules are currently loaded.
269
+ Example: modx.modules_loaded()
270
+
271
+ imported()
272
+ Show ALL modules currently loaded in Python (top-level only).
273
+ Example: modx.imported()
274
+
275
+ modximported()
276
+ Show only the modules imported via ModX functions.
277
+ Example: modx.modximported()
278
+
279
+ info(module_name)
280
+ Show information (path + docstring snippet) about a module.
281
+ Example: modx.info('random')
282
+
283
+ search_modules(keyword)
284
+ Search the stdlib modules list for names or docstrings containing a keyword.
285
+ Example: modx.search_modules('html')
286
+
287
+ modxhelp()
288
+ Show this help screen.
289
+ Example: modx.modxhelp()
290
+
291
+ Tips:
292
+ -----
293
+ - Use imported() to see *everything* loaded after Python started.
294
+ - Use modximported() to see only what ModX loaded.
295
+ - You can combine functions, e.g. modx.import_all() then modx.imported().
296
+ """
297
+ print(help_text)
298
+
299
+ print('ModX loaded')
@@ -0,0 +1,35 @@
1
+ Metadata-Version: 2.4
2
+ Name: modxpy
3
+ Version: 1.24.1
4
+ Summary: ModX — The Python Module Universe at Your Fingertips
5
+ Home-page: https://github.com/yourusername/modx
6
+ Author: Austin Wang
7
+ Author-email: austinw87654@gmail.com
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Dynamic: author
11
+ Dynamic: author-email
12
+ Dynamic: description
13
+ Dynamic: description-content-type
14
+ Dynamic: home-page
15
+ Dynamic: requires-python
16
+ Dynamic: summary
17
+
18
+ # ModX
19
+
20
+ ModX — The Python Module Universe at Your Fingertips.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install modx
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```python
31
+ import modx
32
+
33
+ modx.import_all()
34
+ modx.imported()
35
+ ```
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ modx/__init__.py
4
+ modx/modx.py
5
+ modxpy.egg-info/PKG-INFO
6
+ modxpy.egg-info/SOURCES.txt
7
+ modxpy.egg-info/dependency_links.txt
8
+ modxpy.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ modx
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
modxpy-1.24.1/setup.py ADDED
@@ -0,0 +1,15 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='modxpy',
5
+ version='1.24.1',
6
+ description='ModX — The Python Module Universe at Your Fingertips',
7
+ long_description=open('README.md', encoding='utf-8').read(),
8
+ long_description_content_type='text/markdown',
9
+ author='Austin Wang',
10
+ author_email='austinw87654@gmail.com',
11
+ url='https://github.com/yourusername/modx', # optional
12
+ packages=find_packages(),
13
+ include_package_data=True,
14
+ python_requires='>=3.8',
15
+ )