pytwine.core.Chunk

class pytwine.core.Chunk(chunkType: str, contents: str, number: int, startLineNum: int)[source]

Bases: NamedTuple

A chunk of document – either a code block, or non-code block.

Best to construct them using one of the subclasses DocChunk or CodeChunk.

chunkType

“doc” or “code”

Type

str

contents

string contents of the chunk

Type

str

number

doc or code chunk position number in the document (i.e. 0 through to number-of-doc-chunks - 1), mutatis mutandis for code chunks.

Type

int

startLineNum

line number (starting from 1) the chunk was found at.

Type

int

__init__()

Methods

__init__()

count(value, /)

Return number of occurrences of value.

index(value[, start, stop])

Return first index of value.

Attributes

chunkType

Alias for field number 0

contents

Alias for field number 1

number

Alias for field number 2

startLineNum

Alias for field number 3

chunkType: str

Alias for field number 0

contents: str

Alias for field number 1

count(value, /)

Return number of occurrences of value.

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

number: int

Alias for field number 2

startLineNum: int

Alias for field number 3