update
This commit is contained in:
@@ -2,6 +2,7 @@ import sys
|
||||
import tkinter as tk
|
||||
from tkinter import ttk
|
||||
|
||||
|
||||
def on_treeview_heading_click(column, tree):
|
||||
data = [(tree.set(child, column), child) for child in tree.get_children("")]
|
||||
reverse = (column == tree.heading(column)["text"]) and not column.startswith("_")
|
||||
@@ -42,3 +43,7 @@ tree.tag_configure("selected", background="#ccc")
|
||||
for col in tree["columns"]:
|
||||
tree.heading(col, text=col, anchor=tk.W, command=lambda col=col: on_treeview_heading_click(col, tree))
|
||||
root.mainloop()
|
||||
# Call the on_treeview_heading_click function when a column heading is clicked
|
||||
for col in tree["columns"]:
|
||||
tree.heading(col, text=col, anchor=tk.W, command=lambda col=col: on_treeview_heading_click(col, tree))
|
||||
root.mainloop()
|
||||
@@ -0,0 +1,14 @@
|
||||
import sys
|
||||
|
||||
# Iterate through the modules in sys.modules
|
||||
for module_name, module in sys.modules.items():
|
||||
# Check if the module has a loader attribute
|
||||
if hasattr(module, '__loader__'):
|
||||
loader = module.__loader__
|
||||
# Determine the type of loader
|
||||
if type(loader).__name__ == 'SourceFileLoader':
|
||||
print(f"Module '{module_name}' has a source loader.")
|
||||
elif type(loader).__name__ == 'BuiltinImporter':
|
||||
print(f"Module '{module_name}' has a built-in loader.")
|
||||
elif type(loader).__name__ == 'ExtensionFileLoader':
|
||||
print(f"Module '{module_name}' has an extension loader.")
|
||||
@@ -0,0 +1,12 @@
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
executables = [Executable('module-inspector.py')]
|
||||
|
||||
setup(
|
||||
name='wow',
|
||||
version='1.0',
|
||||
description='Module-inspector Application',
|
||||
executables=executables
|
||||
)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from sys import getsizeof
|
||||
def get_bytecode_size(module_name):
|
||||
"""Get the size of the cached .pyc bytecode file for a module."""
|
||||
spec = importlib.util.find_spec(module_name)
|
||||
if spec and spec.origin.endswith('.py'):
|
||||
if spec and spec.origin and spec.origin.endswith('.py'):
|
||||
pyc_file = importlib.util.cache_from_source(spec.origin)
|
||||
if os.path.exists(pyc_file):
|
||||
return os.path.getsize(pyc_file)
|
||||
@@ -19,7 +19,7 @@ def get_bytecode_size(module_name):
|
||||
def get_dso_size(module_name):
|
||||
"""Get the size of the DSO (Dynamic Shared Object) module file for a module."""
|
||||
spec = importlib.util.find_spec(module_name)
|
||||
if spec and spec.origin.endswith(('.so', '.dll')):
|
||||
if spec and spec.origin and spec.origin.endswith(('.so', '.dll')):
|
||||
return os.path.getsize(spec.origin)
|
||||
return 0
|
||||
|
||||
@@ -51,7 +51,7 @@ def generate_module_report():
|
||||
# Generate histogram of module directory names
|
||||
dir_histogram = defaultdict(int)
|
||||
for module_name in sys.modules:
|
||||
module_file = sys.modules[module_name].__file__
|
||||
module_file = getattr(sys.modules[module_name], '__file__', None)
|
||||
if module_file:
|
||||
module_dir = os.path.dirname(module_file)
|
||||
dir_histogram[module_dir] += 1
|
||||
@@ -64,9 +64,11 @@ def generate_module_report():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Set __spec__ attribute for the main module
|
||||
if not hasattr(sys.modules['__main__'], '__spec__'):
|
||||
sys.modules['__main__'].__spec__ = importlib.util.spec_from_file_location('__main__', __file__)
|
||||
|
||||
__spec__ = importlib.util.spec_from_file_location('__main__', __file__)
|
||||
report = generate_module_report()
|
||||
print(report)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user