Original code copyright (C) 2009-2022 Rudolf Cardinal (

This file is part of cardinal_pythonlib.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Tool to scan rescued Microsoft Office OpenXML files (produced by the “” tool in this kit; q.v.) and detect bad (corrupted) ones.

cardinal_pythonlib.openxml.find_bad_openxml.gen_from_stdin() Generator[str, None, None][source]

Yields stripped lines from stdin.

cardinal_pythonlib.openxml.find_bad_openxml.is_openxml_good(filename: str) bool[source]

Determines whether an OpenXML file appears to be good (not corrupted).

cardinal_pythonlib.openxml.find_bad_openxml.main() None[source]

Command-line handler for the find_bad_openxml tool. Use the --help option for help.

cardinal_pythonlib.openxml.find_bad_openxml.process_openxml_file(filename: str, print_good: bool, delete_if_bad: bool) None[source]

Prints the filename of, or deletes, an OpenXML file depending on whether it is corrupt or not.

  • filename – filename to check

  • print_good – if True, then prints the filename if the file appears good.

  • delete_if_bad – if True, then deletes the file if the file appears corrupt.