gdocrevisions API reference¶
Revisions¶
- 
class 
gdocrevisions.revision.Revision(revision_raw)[source]¶ Bases:
objectRevision 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¶ 
- 
user_id¶ 
- 
 
Operations¶
- 
class 
gdocrevisions.operation.DeleteString(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.RangeOperationDelete a range of string elements
- 
class 
gdocrevisions.operation.DeleteStringSuggestion(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.RangeOperationDelete a range of suggested string elements
- 
class 
gdocrevisions.operation.InsertString(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.OperationOperation 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.InsertStringSuggest the insertion of string elements
- 
class 
gdocrevisions.operation.MarkStringForDeletion(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.RangeOperationSuggest deletion of a range of suggested string elements
- 
class 
gdocrevisions.operation.MultiOperation(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.OperationOperation 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:
objectBase 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
 
- 
raw¶ 
- 
revision¶ 
- 
type¶ 
- 
 
- 
class 
gdocrevisions.operation.RangeOperation(operation_raw, revision)[source]¶ Bases:
gdocrevisions.operation.OperationGeneric 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.RangeOperationFor string previously marked for deletion in a suggestion, unmark for deletion
Document state and content elements¶
- 
class 
gdocrevisions.document.Content[source]¶ Bases:
objectRepresents document content with a list of Element objects
- 
class 
gdocrevisions.element.Character(char, revision, suggest=0)[source]¶ Bases:
gdocrevisions.element.ElementCharacter element Represents a single character
- 
char¶ 
- 
revision¶ Alias for revision_insert attribute
- 
revision_delete¶ 
- 
revision_insert¶ 
- 
suggest¶ 
- 
 
- 
class 
gdocrevisions.element.Element(revision, suggest=0)[source]¶ Bases:
objectBase 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).
- 
revision¶ 
- 
suggest¶ 
- 
 
- 
class 
gdocrevisions.element.EndOfBody[source]¶ Bases:
gdocrevisions.element.ElementDummy element indicating end of document body Separates main content from footnote text