URL: https://github.com/freeipa/freeipa/pull/275
Author: martbab
 Title: #275: Enhance __repr__ method of Principal
Action: opened

PR body:
"""
`__repr__` now returns more descriptive string containing the actual principal
name while keeping the ability to reconstruct the object from it.

This makes principal names visible in debug logs, easing troubleshooting a
bit.

https://fedorahosted.org/freeipa/ticket/6505
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/275/head:pr275
git checkout pr275
From 7f4f4bc4854f9558ea598bd274980fd248e870b9 Mon Sep 17 00:00:00 2001
From: Martin Babinsky <mbabi...@redhat.com>
Date: Mon, 28 Nov 2016 10:22:26 +0100
Subject: [PATCH] Enhance __repr__ method of Principal

`__repr__` now returns more descriptive string containing the actual principal
name while keeping the ability to reconstruct the object from it.

This makes principal names visible in debug logs, easing troubleshooting a
bit.

https://fedorahosted.org/freeipa/ticket/6505
---
 ipapython/kerberos.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ipapython/kerberos.py b/ipapython/kerberos.py
index a8ebc04..e2020bf 100644
--- a/ipapython/kerberos.py
+++ b/ipapython/kerberos.py
@@ -181,3 +181,7 @@ def __str__(self):
             principal_string = u'@'.join([principal_string, realm])
 
         return principal_string
+
+    def __repr__(self):
+        return "{}.{}('{}')".format(
+            self.__module__, self.__class__.__name__, self.__str__())
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to