U
    cqeŒ  ã                   @  sX   d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
 dddœd	d
„Zdd„ ZdS )zŸDirectly exposed API functions and classes, :func:`Document` for now.

Provides a syntactically more convenient API for interacting with the OpcPackage graph.
é    )ÚannotationsN)ÚIO)ÚCONTENT_TYPE)ÚPackagezstr | IO[bytes] | None)Údocxc                 C  sF   | dkrt ƒ n| } t | ¡j}|jtjkr@d}t|| |jf ƒ‚|jS )zîReturn a |Document| object loaded from `docx`, where `docx` can be either a path
    to a ``.docx`` file (a string) or a file-like object.

    If `docx` is missing or ``None``, the built-in default document "template" is
    loaded.
    Nz2file '%s' is not a Word file, content type is '%s')	Ú_default_docx_pathr   ÚopenZmain_document_partÚcontent_typeÚCTZWML_DOCUMENT_MAINÚ
ValueErrorÚdocument)r   Zdocument_partÚtmpl© r   ú,/tmp/pip-unpacked-wheel-gx5hpqp3/docx/api.pyÚDocument   s    r   c                  C  s    t j t¡d } t j | dd¡S )z6Return the path to the built-in default .docx package.r   Z	templateszdefault.docx)ÚosÚpathÚsplitÚ__file__Újoin)Z_thisdirr   r   r   r      s    r   )N)Ú__doc__Ú
__future__r   r   Útypingr   Zdocx.opc.constantsr   r
   Zdocx.packager   r   r   r   r   r   r   Ú<module>   s   