groups property
RevisionCollection.groups property
Collection of revision groups.
@property
def groups(self) -> aspose.words.RevisionGroupCollection:
...
Examples
Shows how to work with a document’s collection of revisions.
doc = aw.Document(file_name=MY_DIR + 'Revisions.docx')
revisions = doc.revisions
# This collection itself has a collection of revision groups.
# Each group is a sequence of adjacent revisions.
group_count = sum((1 for _ in revisions.groups))
print(f'{group_count} revision groups:')
# Iterate over the collection of groups and print the text that the revision concerns.
for group in revisions.groups:
print(f'\tGroup type "{group.revision_type}", ' + f'author: {group.author}, contents: [{group.text.strip()}]')
# Each Run that a revision affects gets a corresponding Revision object.
# The revisions' collection is considerably larger than the condensed form we printed above,
# depending on how many Runs we have segmented the document into during Microsoft Word editing.
revision_count = sum((1 for _ in revisions))
print(f'\n{revision_count} revisions:')
for revision in revisions:
# A StyleDefinitionChange strictly affects styles and not document nodes. This means the "ParentStyle" property will always be in use, while the ParentNode will always be null.
# Since all other changes affect nodes, ParentNode will conversely be in use, and ParentStyle will be null.
if revision.revision_type == aw.RevisionType.STYLE_DEFINITION_CHANGE:
print(f'\tRevision type "{revision.revision_type}", ' + f'author: {revision.author}, style: [{revision.parent_style.name}]')
else:
print(f'\tRevision type "{revision.revision_type}", ' + f'author: {revision.author}, contents: [{revision.parent_node.get_text().strip()}]')
# Reject all revisions via the collection, reverting the document to its original form.
revisions.reject_all()
self.assertEqual(0, sum((1 for _ in revisions)))
See Also
- module aspose.words
- class RevisionCollection