gdocrevisions API reference

Revisions

class gdocrevisions.revision.Revision(revision_raw)[source]

Bases: object

Revision class Corresponds to Revision resource type in Google API: https://developers.google.com/drive/v3/reference/revisions A Revision contains an Operation

apply(elements)[source]

Apply the revision to a list of elements

Arguments:
elements (list): usually the elements attribute of a Content instance
iter_operations
operation
operation_raw
operations

List of operations that make up this revision (MultiOperations are flattened into their base operations)

raw
revision_id
session_id
session_revision_index
time
to_dict()[source]
user_id

Operations

class gdocrevisions.operation.DeleteString(operation_raw, revision)[source]

Bases: gdocrevisions.operation.RangeOperation

Delete a range of string elements

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
class gdocrevisions.operation.DeleteStringSuggestion(operation_raw, revision)[source]

Bases: gdocrevisions.operation.RangeOperation

Delete a range of suggested string elements

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
class gdocrevisions.operation.InsertString(operation_raw, revision)[source]

Bases: gdocrevisions.operation.Operation

Operation subclass representing an “Insert String” operation New elements are inserted at position defined by start_index (1-indexed) e.g. InsertString with start=3 denotes that new elements will start at the 3rd position i.e. [‘a’,’b’,’new1’,’new2’,…,’c’,’d’,…]

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
raw
revision
start_index
string
type
class gdocrevisions.operation.InsertStringSuggestion(operation_raw, revision)[source]

Bases: gdocrevisions.operation.InsertString

Suggest the insertion of string elements

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
class gdocrevisions.operation.MarkStringForDeletion(operation_raw, revision)[source]

Bases: gdocrevisions.operation.RangeOperation

Suggest deletion of a range of suggested string elements

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
class gdocrevisions.operation.MultiOperation(operation_raw, revision)[source]

Bases: gdocrevisions.operation.Operation

Operation subclass representing a “Multiple Operation” operation Contains an array of Operation objects

apply(elements)[source]

Apply each of the operations comprising the MultiOperation

Arguments:
elements (list): list of Elements
iter_operations()[source]

Generator that iterates through base operations. Does a depth-first search of the operations tree, yielding leaf (non-Multioperation) nodes

operations
raw
revision
type
class gdocrevisions.operation.Operation(operation_raw, revision)[source]

Bases: object

Base Operation class Represents action(s) that occur as part of a revision

operation_raw is a dictionary of raw operation metadata

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
iter_operations()[source]
raw
revision
to_dict()[source]
type
class gdocrevisions.operation.RangeOperation(operation_raw, revision)[source]

Bases: gdocrevisions.operation.Operation

Generic subclass representing an operation that modifies elements within a particular range Range is defined by start and end indexes, and is 1-indexed and inclusive e.g. DeleteString with start=1 and end=3 means delete elements 1, 2 and 3 (1-indexed)

end_index
raw
revision
start_index
type
class gdocrevisions.operation.UnmarkStringForDeletion(operation_raw, revision)[source]

Bases: gdocrevisions.operation.RangeOperation

For string previously marked for deletion in a suggestion, unmark for deletion

apply(elements)[source]

Apply this operation to document content elements

Arguments:
elements (list): list of Elements
gdocrevisions.operation.operation_factory(operation_raw, revision)[source]

Factory method that returns Operation or subclass instance

Arguments:
operation_raw (dict): raw operation data revision (Revision): revision instance, which gets associated with any created Element objects

Document state and content elements

class gdocrevisions.document.Content[source]

Bases: object

Represents document content with a list of Element objects

apply(change)[source]

Apply some change (could be a revision or operation) to the content elements

Arguments:
change (Revision or Operation instance): object whose changes should be applied to the content instance
render()[source]
reset()[source]
class gdocrevisions.element.Character(char, revision, suggest=0)[source]

Bases: gdocrevisions.element.Element

Character element Represents a single character

char
render()[source]

Render this element, typically called by content.render()

revision

Alias for revision_insert attribute

revision_delete
revision_insert
suggest
class gdocrevisions.element.Element(revision, suggest=0)[source]

Bases: object

Base Element class. Is a list element in a document’s content attribute. Associated with a revision Suggest attribute denotes whether element is suggested for insertion (1), suggested for deletion (-1), or not part of a suggestion (0).

render()[source]
revision
suggest
class gdocrevisions.element.EndOfBody[source]

Bases: gdocrevisions.element.Element

Dummy element indicating end of document body Separates main content from footnote text