Coverage for C:\Program Files\QGIS 3.10\apps\qgis-ltr\python\qgis\core\additions\readwritecontextentercategory.py: 38%
13 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-10 14:40 +0900
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-10 14:40 +0900
1# -*- coding: utf-8 -*-
3"""
4***************************************************************************
5 readwritecontextentercategory.py
6 ---------------------
7 Date : May 2018
8 Copyright : (C) 2018 by Denis Rouzaud
9 Email : denis@opengis.ch
10***************************************************************************
11* *
12* This program is free software; you can redistribute it and/or modify *
13* it under the terms of the GNU General Public License as published by *
14* the Free Software Foundation; either version 2 of the License, or *
15* (at your option) any later version. *
16* *
17***************************************************************************
18"""
21class ReadWriteContextEnterCategory():
22 """
23 Push a category to the stack
25 .. code-block:: python
27 context = QgsReadWriteContext()
28 with QgsReadWriteContext.enterCategory(context, category, details):
29 # do something
31 .. versionadded:: 3.2
32 """
34 def __init__(self, context, category_name, details=None):
35 self.context = context
36 self.category_name = category_name
37 self.details = details
38 self.popper = None
40 def __enter__(self):
41 self.popper = self.context._enterCategory(self.category_name, self.details)
42 return self.context
44 def __exit__(self, ex_type, ex_value, traceback):
45 del self.popper
46 return True