Class: QgsReadWriteContext

class qgis.core.QgsReadWriteContext

Bases: sip.wrapper

Constructor for QgsReadWriteContext.

QgsReadWriteContext(QgsReadWriteContext)

The class is used as a container of context for various read/write operations on other objects.

Methods

pathResolver

Returns path resolver for conversion between relative and absolute paths

projectTranslator

Returns the project translator

pushMessage

Append a message to the context

setPathResolver

Sets up path resolver for conversion between relative and absolute paths

setProjectTranslator

Sets the project translator.

setTransformContext

Sets data coordinate transform context to transformContext

takeMessages

Returns the stored messages and remove them

transformContext

Returns data provider coordinate transform context

class ReadWriteMessage(message: str, level: Qgis.MessageLevel = Qgis.Warning, categories: Iterable[str] = [])

Bases: sip.wrapper

Construct a container for QgsReadWriteContext error or warning messages

QgsReadWriteContext.ReadWriteMessage(QgsReadWriteContext.ReadWriteMessage)

Parameters
  • message (str) –

  • level (Qgis.MessageLevel = Qgis.Warning) –

  • categories (Iterable[str] = []) –

categories(self) → List[str]

Returns the stack of categories of the message

Return type

List[str]

level(self) → Qgis.MessageLevel

Returns the message level

Return type

Qgis.MessageLevel

message(self) → str

Returns the message string

Return type

str

enterCategory

alias of qgis.core.additions.readwritecontextentercategory.ReadWriteContextEnterCategory

pathResolver(self) → QgsPathResolver

Returns path resolver for conversion between relative and absolute paths

Return type

QgsPathResolver

projectTranslator(self) → QgsProjectTranslator

Returns the project translator

New in version 3.4.

Return type

QgsProjectTranslator

pushMessage(self, message: str, level: Qgis.MessageLevel = Qgis.Warning)

Append a message to the context

New in version 3.2.

Parameters
  • message (str) –

  • level (Qgis.MessageLevel = Qgis.Warning) –

setPathResolver(self, resolver: QgsPathResolver)

Sets up path resolver for conversion between relative and absolute paths

Parameters

resolver (QgsPathResolver) –

setProjectTranslator(self, projectTranslator: QgsProjectTranslator)

Sets the project translator. It’s usually the QgsProject where the function with the context is made and won’t be changed anymore.

New in version 3.4.

Parameters

projectTranslator (QgsProjectTranslator) –

setTransformContext(self, transformContext: QgsCoordinateTransformContext)

Sets data coordinate transform context to transformContext

New in version 3.8.

Parameters

transformContext (QgsCoordinateTransformContext) –

takeMessages(self) → List[QgsReadWriteContext.ReadWriteMessage]

Returns the stored messages and remove them

New in version 3.2.

Return type

List[QgsReadWriteContext.ReadWriteMessage]

transformContext(self) → QgsCoordinateTransformContext

Returns data provider coordinate transform context

New in version 3.8.

Return type

QgsCoordinateTransformContext