Main entry point for command-line usage.
()
| 48 | |
| 49 | |
| 50 | def main(): |
| 51 | """Main entry point for command-line usage.""" |
| 52 | parser = argparse.ArgumentParser( |
| 53 | description="Extract text inventory from PowerPoint with proper GroupShape support.", |
| 54 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 55 | epilog=""" |
| 56 | Examples: |
| 57 | python inventory.py presentation.pptx inventory.json |
| 58 | Extracts text inventory with correct absolute positions for grouped shapes |
| 59 | |
| 60 | python inventory.py presentation.pptx inventory.json --issues-only |
| 61 | Extracts only text shapes that have overflow or overlap issues |
| 62 | |
| 63 | The output JSON includes: |
| 64 | - All text content organized by slide and shape |
| 65 | - Correct absolute positions for shapes in groups |
| 66 | - Visual position and size in inches |
| 67 | - Paragraph properties and formatting |
| 68 | - Issue detection: text overflow and shape overlaps |
| 69 | """, |
| 70 | ) |
| 71 | |
| 72 | parser.add_argument("input", help="Input PowerPoint file (.pptx)") |
| 73 | parser.add_argument("output", help="Output JSON file for inventory") |
| 74 | parser.add_argument( |
| 75 | "--issues-only", |
| 76 | action="store_true", |
| 77 | help="Include only text shapes that have overflow or overlap issues", |
| 78 | ) |
| 79 | |
| 80 | args = parser.parse_args() |
| 81 | |
| 82 | input_path = Path(args.input) |
| 83 | if not input_path.exists(): |
| 84 | print(f"Error: Input file not found: {args.input}") |
| 85 | sys.exit(1) |
| 86 | |
| 87 | if not input_path.suffix.lower() == ".pptx": |
| 88 | print("Error: Input must be a PowerPoint file (.pptx)") |
| 89 | sys.exit(1) |
| 90 | |
| 91 | try: |
| 92 | print(f"Extracting text inventory from: {args.input}") |
| 93 | if args.issues_only: |
| 94 | print( |
| 95 | "Filtering to include only text shapes with issues (overflow/overlap)" |
| 96 | ) |
| 97 | inventory = extract_text_inventory(input_path, issues_only=args.issues_only) |
| 98 | |
| 99 | output_path = Path(args.output) |
| 100 | output_path.parent.mkdir(parents=True, exist_ok=True) |
| 101 | save_inventory(inventory, output_path) |
| 102 | |
| 103 | print(f"Output saved to: {args.output}") |
| 104 | |
| 105 | # Report statistics |
| 106 | total_slides = len(inventory) |
| 107 | total_shapes = sum(len(shapes) for shapes in inventory.values()) |
no test coverage detected