Skip to content

Commit 6d46e86

Browse files
author
Steve Canny
committed
reorg: extract docx.parts subpackage
1 parent 10e93e2 commit 6d46e86

File tree

15 files changed

+44
-32
lines changed

15 files changed

+44
-32
lines changed

docx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from docx.opc.constants import CONTENT_TYPE as CT
1111
from docx.opc.package import PartFactory
1212

13-
from docx.parts import _Document
13+
from docx.parts.document import _Document
1414

1515
PartFactory.part_type_for[CT.WML_DOCUMENT_MAIN] = _Document
1616

docx/oxml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ValidationError(Exception):
3232
register_custom_element_class('pic:pic', CT_Picture)
3333
register_custom_element_class('wp:inline', CT_Inline)
3434

35-
from docx.oxml.parts import CT_Body, CT_Document
35+
from docx.oxml.parts.document import CT_Body, CT_Document
3636
register_custom_element_class('w:body', CT_Body)
3737
register_custom_element_class('w:document', CT_Document)
3838

docx/oxml/parts/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# encoding: utf-8
22

33
"""
4-
Custom element classes that correspond to OPC parts like <w:document>.
4+
Custom element classes that correspond to the document part, e.g.
5+
<w:document>.
56
"""
67

78
from docx.oxml.shared import OxmlBaseElement, qn

docx/parts/__init__.py

Whitespace-only changes.

docx/parts.py renamed to docx/parts/document.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@ def tables(self):
119119
return [Table(tbl) for tbl in self._body.tbl_lst]
120120

121121

122-
class Image(Part):
123-
"""
124-
An image part. Corresponds to the target part of a relationship with type
125-
RELATIONSHIP_TYPE.IMAGE.
126-
"""
127-
128-
129122
class InlineShape(object):
130123
"""
131124
Proxy for an ``<wp:inline>`` element, representing the container for an

docx/parts/image.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# encoding: utf-8
2+
3+
"""
4+
The proxy class for an image part, and related objects.
5+
"""
6+
7+
from __future__ import absolute_import, print_function, unicode_literals
8+
9+
from docx.opc.package import Part
10+
11+
12+
class Image(Part):
13+
"""
14+
An image part. Corresponds to the target part of a relationship with type
15+
RELATIONSHIP_TYPE.IMAGE.
16+
"""

features/steps/shape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from docx import Document
1414
from docx.enum.shape import WD_INLINE_SHAPE
15-
from docx.parts import InlineShape, InlineShapes
15+
from docx.parts.document import InlineShape, InlineShapes
1616

1717
from .helpers import test_docx, test_file_path
1818

tests/oxml/parts/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
Test suite for the docx.oxml.parts module.
55
"""
66

7-
from docx.oxml.parts import CT_Body
7+
from docx.oxml.parts.document import CT_Body
88
from docx.oxml.text import CT_P
99

10-
from .unitdata.parts import a_body, a_document
11-
from .unitdata.text import a_p, a_sectPr
10+
from .unitdata.document import a_body, a_document
11+
from ..unitdata.text import a_p, a_sectPr
1212

1313

1414
class DescribeCT_Body(object):

0 commit comments

Comments
 (0)