Merged
Conversation
While this may not work in all cases, it is less ugly than arbitrarily boosting the id value as suggested. A general-case fix will have to wait for access to headers and footers. It definitely reduces the likelihood of a collision.
* Also take care of a pesky warning from pytest when getting style by id.
Python 2.6 seems to be no longer supported on travis.ci so we're letting it drop here. We're retaining testing on 2.6 in tox for now though.
In preparation for moving to Python Black for standardized code layout, get the custom element mappings closer to Black style layout.
To access header and footer parts, Section will need the document part and the source for that will be its Sections parent proxy. Add document_part as construction parameter for Sections and modify tests to suit.
* Modernize section unit test fixtures while in there.
This is essentially migrated "up" from DocumentPart, which now subclasses BaseStoryPart.
Also extract Package.get_or_add_image_part() to avoid BaseStoryPart and others having to know about ImageParts.
Add some namespace-prefix mappings that arise for the first time in headers.
Add scenarios for Section.different_first_page_header_footer.
In preparation for adding even-page and first-page header and footer properties, pass the WD_HEADER_FOOTER_INDEX member identifying the header or footer type (primary, first, even) to _Header and _Footer on construction. This will allow each of these classes to serve for all three header/footer types.
The implementation of `Document.add_section()` "clones" the previously last `w:sectPr` element to produce the `w:sectPr` for the new section. This has the effect of duplicating the header and footer references along with the rIds used to link them to their header or footer part. There have been no reports that this causes a problem, but in any case the correct behavior is to add a new section without any header or footer definitions, such that the new section "inherits" all header/footer definitions (and header/footer parts are not "reused"). Add code to remove all `w:headerReference` and `w:footerReference` elements from a "cloned" `w:sectPr` element when adding a section.
Maintaining the default document template as a directory allows its individual parts (XML files) to be curated like code, with line-changes tracked by Git. Extract the default template to a directory and load that directory as the default when no template document is specified to the `Document()` constructor. Also add Header and Footer styles.
Also some pending documentation updates and some Black changes.
JasonRJFleischer
approved these changes
Dec 26, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (e.g. "Related to ...", "Closes ...", etc.)
Code review checklist
core/tests/test_python-docxare updated and passing