<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert_docx_to_text( filename: str = None, blob: bytes = None, config: TextProcessingConfig = _DEFAULT_CONFIG) -> str: """ Converts a DOCX file to text. Pass either a filename or a binary object. Args: filename: filename to process blob: binary ``bytes`` object to process config: :class:`TextProcessingConfig` control object Returns: text contents Notes: - Old ``docx`` (https://pypi.python.org/pypi/python-docx) has been superseded (see https://github.com/mikemaccana/python-docx). - ``docx.opendocx(file)`` uses :class:`zipfile.ZipFile`, which can take either a filename or a file-like object (https://docs.python.org/2/library/zipfile.html). - Method was: .. code-block:: python with get_filelikeobject(filename, blob) as fp: document = docx.opendocx(fp) paratextlist = docx.getdocumenttext(document) return '\n\n'.join(paratextlist) - Newer ``docx`` is python-docx - https://pypi.python.org/pypi/python-docx - https://python-docx.readthedocs.org/en/latest/ - http://stackoverflow.com/questions/25228106 However, it uses ``lxml``, which has C dependencies, so it doesn't always install properly on e.g. bare Windows machines. PERFORMANCE of my method: - nice table formatting - but tables grouped at end, not in sensible places - can iterate via ``doc.paragraphs`` and ``doc.tables`` but not in true document order, it seems - others have noted this too: - https://github.com/python-openxml/python-docx/issues/40 - https://github.com/deanmalmgren/textract/pull/92 - ``docx2txt`` is at https://pypi.python.org/pypi/docx2txt/0.6; this is pure Python. Its command-line function appears to be for Python 2 only (2016-04-21: crashes under Python 3; is due to an encoding bug). However, it seems fine as a library. It doesn't handle in-memory blobs properly, though, so we need to extend it. PERFORMANCE OF ITS ``process()`` function: - all text comes out - table text is in a sensible place - table formatting is lost. - Other manual methods (not yet implemented):
 http://etienned.github.io/posts/extract-text-from-word-docx-simply/. Looks like it won't deal with header stuff (etc.) that ``docx2txt`` handles. - Upshot: we need a DIY version. - See also this "compile lots of techniques" libraries, which has C dependencies: http://textract.readthedocs.org/en/latest/ """


    if True:
        text = ''
        with get_filelikeobject(filename, blob) as fp:
            for xml in gen_xml_files_from_docx(fp):
                text += docx_text_from_xml(xml, config)
        return text