|
1 | 1 | # encoding: utf-8 |
2 | 2 |
|
3 | | -""" |
4 | | -Section-related custom element classes. |
5 | | -""" |
| 3 | +"""Section-related custom element classes""" |
6 | 4 |
|
7 | | -from __future__ import absolute_import, print_function |
| 5 | +from __future__ import absolute_import, division, print_function, unicode_literals |
8 | 6 |
|
9 | 7 | from copy import deepcopy |
10 | 8 |
|
11 | | -from ..enum.section import WD_ORIENTATION, WD_SECTION_START |
12 | | -from .simpletypes import ST_SignedTwipsMeasure, ST_TwipsMeasure |
13 | | -from .xmlchemy import BaseOxmlElement, OptionalAttribute, ZeroOrOne |
| 9 | +from docx.enum.section import WD_ORIENTATION, WD_SECTION_START |
| 10 | +from docx.oxml.simpletypes import ST_SignedTwipsMeasure, ST_TwipsMeasure |
| 11 | +from docx.oxml.xmlchemy import BaseOxmlElement, OptionalAttribute, ZeroOrOne |
14 | 12 |
|
15 | 13 |
|
16 | 14 | class CT_PageMar(BaseOxmlElement): |
@@ -38,25 +36,18 @@ class CT_PageSz(BaseOxmlElement): |
38 | 36 |
|
39 | 37 |
|
40 | 38 | class CT_SectPr(BaseOxmlElement): |
41 | | - """ |
42 | | - ``<w:sectPr>`` element, the container element for section properties. |
43 | | - """ |
44 | | - __child_sequence__ = ( |
45 | | - 'w:footnotePr', 'w:endnotePr', 'w:type', 'w:pgSz', 'w:pgMar', |
46 | | - 'w:paperSrc', 'w:pgBorders', 'w:lnNumType', 'w:pgNumType', 'w:cols', |
47 | | - 'w:formProt', 'w:vAlign', 'w:noEndnote', 'w:titlePg', |
48 | | - 'w:textDirection', 'w:bidi', 'w:rtlGutter', 'w:docGrid', |
49 | | - 'w:printerSettings', 'w:sectPrChange', |
| 39 | + """`w:sectPr` element, the container element for section properties""" |
| 40 | + |
| 41 | + _tag_seq = ( |
| 42 | + 'w:footnotePr', 'w:endnotePr', 'w:type', 'w:pgSz', 'w:pgMar', 'w:paperSrc', |
| 43 | + 'w:pgBorders', 'w:lnNumType', 'w:pgNumType', 'w:cols', 'w:formProt', 'w:vAlign', |
| 44 | + 'w:noEndnote', 'w:titlePg', 'w:textDirection', 'w:bidi', 'w:rtlGutter', |
| 45 | + 'w:docGrid', 'w:printerSettings', 'w:sectPrChange', |
50 | 46 | ) |
51 | | - type = ZeroOrOne('w:type', successors=( |
52 | | - __child_sequence__[__child_sequence__.index('w:type')+1:] |
53 | | - )) |
54 | | - pgSz = ZeroOrOne('w:pgSz', successors=( |
55 | | - __child_sequence__[__child_sequence__.index('w:pgSz')+1:] |
56 | | - )) |
57 | | - pgMar = ZeroOrOne('w:pgMar', successors=( |
58 | | - __child_sequence__[__child_sequence__.index('w:pgMar')+1:] |
59 | | - )) |
| 47 | + type = ZeroOrOne("w:type", successors=_tag_seq[3:]) |
| 48 | + pgSz = ZeroOrOne("w:pgSz", successors=_tag_seq[4:]) |
| 49 | + pgMar = ZeroOrOne("w:pgMar", successors=_tag_seq[5:]) |
| 50 | + del _tag_seq |
60 | 51 |
|
61 | 52 | @property |
62 | 53 | def bottom_margin(self): |
|
0 commit comments