Install & Compatibility
Where this runs
tested against v0.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CompoundFileEntity
✓ from compoundfiles import CompoundFileEntity
✗ from compoundfiles import CompoundFile
This quickstart demonstrates how to open an OLE Compound Document, list its root entries (streams and storages), and attempt to read content from a common stream like 'WordDocument'. It requires a path to an existing OLE file to function properly.
import os
from compoundfiles import CompoundFile
# IMPORTANT: Replace 'path/to/your/ole_document.doc' with the actual path
# to an OLE Compound Document (e.g., old .doc, .xls, .ppt files).
# This library is for reading existing OLE files.
# A sample OLE file (e.g., an old .doc) is required for this example to run meaningfully.
file_path = os.environ.get('OLE_FILE_PATH', './example.doc') # Placeholder for agent
if not os.path.exists(file_path):
print(f"Warning: OLE file not found at '{file_path}'. Please provide a valid path.")
print("Example usage requires an actual OLE Compound Document file.")
print("You can provide it via OLE_FILE_PATH environment variable or replace the hardcoded path.")
else:
try:
with CompoundFile(file_path) as cf:
print(f"Successfully opened OLE Compound Document: {file_path}")
print("\nRoot entries:")
for entry in cf.listdir('/'):
print(f"- {entry}")
# Example: Try to read a specific stream if it exists
# 'WordDocument' is a common stream name in OLE Word documents.
if 'WordDocument' in cf.listdir('/'):
with cf.open('WordDocument') as stream:
# Read a portion of the stream (actual content is often binary/complex)
content = stream.read(50)
print(f"\nContent of '/WordDocument' stream (first 50 bytes): {content!r}")
else:
print("\nNo 'WordDocument' stream found. Listing other common streams if available...")
for common_stream in ['Workbook', 'PowerPoint Document', 'Contents']: # Add other common stream names
if common_stream in cf.listdir('/'):
print(f"Found stream: '{common_stream}'")
except Exception as e:
print(f"\nError processing OLE file '{file_path}': {e}")
print("Ensure the file is a valid OLE Compound Document and not corrupted.")
Upgrade
Version history
0.3latest on PyPI · released Sep 1, 2014
Audit
Dependencies
No dependency data recorded yet.