Files
ComicRack_Scripts/List Book Properties/DebugProps.py

46 lines
1.4 KiB
Python

import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System")
from System.Windows.Forms import MessageBox
from System.IO import Path, File, StreamWriter
# ==============================================================================
# @Name Debug: List Book Properties
# @Hook Books
# @Key debug-props
# ==============================================================================
def ListBookProperties(books):
if not books:
MessageBox.Show("No books selected!")
return
b = books[0] # Just use the first book
# Get all properties using .NET reflection
props = []
for prop in b.GetType().GetProperties():
print(prop.Name,prop.GetValue(b, None))
try:
val = prop.GetValue(b, None)
props.append("%s = %s" % (prop.Name, val))
except:
props.append("%s = (error reading)" % prop.Name)
# Also get methods
methods = []
for method in b.GetType().GetMethods():
methods.append(method.Name)
# Write to file since MessageBox can't show all
output_path = Path.Combine(Path.GetDirectoryName(__file__), "book_properties.txt")
with open(output_path, 'w') as f:
f.write("=== PROPERTIES ===\n")
for p in sorted(props):
f.write(p + "\n")
f.write("\n=== METHODS ===\n")
for m in sorted(set(methods)):
f.write(m + "\n")
MessageBox.Show("Properties written to:\n" + output_path)