1010
1111import os
1212
13- from docx .enum .section import WD_SECTION
1413from docx .opc .constants import CONTENT_TYPE as CT
1514from docx .package import Package
1615
1716
18- def DocumentNew (docx = None ):
17+ def Document (docx = None ):
1918 """
2019 Return a |Document| object loaded from *docx*, where *docx* can be
2120 either a path to a ``.docx`` file (a string) or a file-like object. If
@@ -36,65 +35,3 @@ def _default_docx_path():
3635 """
3736 _thisdir = os .path .split (__file__ )[0 ]
3837 return os .path .join (_thisdir , 'templates' , 'default.docx' )
39-
40-
41- class Document (object ):
42- """
43- Return a |Document| instance loaded from *docx*, where *docx* can be
44- either a path to a ``.docx`` file (a string) or a file-like object. If
45- *docx* is missing or ``None``, the built-in default document "template"
46- is loaded.
47- """
48- def __init__ (self , docx = None ):
49- self ._document = document = DocumentNew (docx )
50- self ._document_part = document ._part
51- self ._package = document ._part .package
52-
53- def add_heading (self , text = '' , level = 1 ):
54- return self ._document .add_heading (text , level )
55-
56- def add_page_break (self ):
57- return self ._document .add_page_break ()
58-
59- def add_paragraph (self , text = '' , style = None ):
60- return self ._document .add_paragraph (text , style )
61-
62- def add_picture (self , image_descriptor , width = None , height = None ):
63- return self ._document .add_picture (image_descriptor , width , height )
64-
65- def add_section (self , start_type = WD_SECTION .NEW_PAGE ):
66- return self ._document .add_section (start_type )
67-
68- def add_table (self , rows , cols , style = 'Light Shading Accent 1' ):
69- return self ._document .add_table (rows , cols , style )
70-
71- @property
72- def core_properties (self ):
73- return self ._document .core_properties
74-
75- @property
76- def inline_shapes (self ):
77- return self ._document .inline_shapes
78-
79- @property
80- def paragraphs (self ):
81- return self ._document .paragraphs
82-
83- @property
84- def part (self ):
85- return self ._document .part
86-
87- def save (self , path_or_stream ):
88- self ._document .save (path_or_stream )
89-
90- @property
91- def sections (self ):
92- return self ._document .sections
93-
94- @property
95- def styles (self ):
96- return self ._document .styles
97-
98- @property
99- def tables (self ):
100- return self ._document .tables
0 commit comments