summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-01-09 03:06:40 +0100
committerGitHub <noreply@github.com>2022-01-09 03:06:40 +0100
commitbdc19b162ca75c4a2eac70f3f9814ab31de97f7c (patch)
treec70282a8a15c9040692fed634051090c6d2cd706 /gitlab
parentac812727c26c9bde4ee5c1115029f2ff4ab1964b (diff)
parentd69ba0479a4537bbc7a53f342661c1984382f939 (diff)
downloadgitlab-bdc19b162ca75c4a2eac70f3f9814ab31de97f7c.tar.gz
Merge pull request #1812 from python-gitlab/jlvillal/pprint
chore: add `pprint()` and `pformat()` methods to RESTObject
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 50f09c5..6a6e992 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import importlib
+import pprint
import textwrap
from types import ModuleType
from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type
@@ -147,6 +148,14 @@ class RESTObject(object):
data.update(self._updated_attrs)
return f"{type(self)} => {data}"
+ def pformat(self) -> str:
+ data = self._attrs.copy()
+ data.update(self._updated_attrs)
+ return f"{type(self)} => \n{pprint.pformat(data)}"
+
+ def pprint(self) -> None:
+ print(self.pformat())
+
def __repr__(self) -> str:
if self._id_attr:
return f"<{self.__class__.__name__} {self._id_attr}:{self.get_id()}>"