(filename: str)
| 87 | |
| 88 | |
| 89 | def ppt_validate(filename: str): |
| 90 | with tempfile.TemporaryDirectory() as temp_dir: |
| 91 | config = Config(rundir=temp_dir, debug=False) |
| 92 | try: |
| 93 | presentation = Presentation.from_file(filename, config) |
| 94 | except Exception as e: |
| 95 | return False |
| 96 | num_images = len(os.listdir(config.IMAGE_DIR)) |
| 97 | if num_images > 3 * len(presentation) or num_images == 0: |
| 98 | return False |
| 99 | if len(presentation) < 8 or len(presentation) > 64: |
| 100 | return False |
| 101 | if len(presentation.error_history) > len(presentation) / 2: |
| 102 | return False |
| 103 | layout_count = defaultdict(int) |
| 104 | |
| 105 | for slide in presentation.slides: |
| 106 | layout_count[slide.slide_layout_name] += 1 |
| 107 | if sum(layout_count.values()) / len(layout_count) < 2: |
| 108 | return False |
| 109 | return True |
| 110 | |
| 111 | |
| 112 | def pdf_validate(filename: str): |
no test coverage detected