mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
Add str() for policy_handles.
Pair programmed with Jelmer
This commit is contained in:
parent
6f60a6e71a
commit
f128bfd449
@ -115,7 +115,16 @@ static PyObject *py_policy_handle_repr(PyObject *py_self)
|
|||||||
{
|
{
|
||||||
struct policy_handle *self = py_talloc_get_ptr(py_self);
|
struct policy_handle *self = py_talloc_get_ptr(py_self);
|
||||||
char *uuid_str = GUID_string(NULL, &self->uuid);
|
char *uuid_str = GUID_string(NULL, &self->uuid);
|
||||||
PyObject *ret = PyString_FromFormat("policy_handle('%s', %d)", uuid_str, self->handle_type);
|
PyObject *ret = PyString_FromFormat("policy_handle(%d, '%s')", self->handle_type, uuid_str);
|
||||||
|
talloc_free(uuid_str);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *py_policy_handle_str(PyObject *py_self)
|
||||||
|
{
|
||||||
|
struct policy_handle *self = py_talloc_get_ptr(py_self);
|
||||||
|
char *uuid_str = GUID_string(NULL, &self->uuid);
|
||||||
|
PyObject *ret = PyString_FromFormat("%d, %s", self->handle_type, uuid_str);
|
||||||
talloc_free(uuid_str);
|
talloc_free(uuid_str);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -124,6 +133,7 @@ static void py_policy_handle_patch(PyTypeObject *type)
|
|||||||
{
|
{
|
||||||
type->tp_init = py_policy_handle_init;
|
type->tp_init = py_policy_handle_init;
|
||||||
type->tp_repr = py_policy_handle_repr;
|
type->tp_repr = py_policy_handle_repr;
|
||||||
|
type->tp_str = py_policy_handle_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PY_POLICY_HANDLE_PATCH py_policy_handle_patch
|
#define PY_POLICY_HANDLE_PATCH py_policy_handle_patch
|
||||||
|
@ -24,6 +24,7 @@ text1 = "76f53846-a7c2-476a-ae2c-20e2b80d7b34"
|
|||||||
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
|
text2 = "344edffa-330a-4b39-b96e-2c34da52e8b1"
|
||||||
|
|
||||||
class GUIDTests(unittest.TestCase):
|
class GUIDTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_str(self):
|
def test_str(self):
|
||||||
guid = misc.GUID(text1)
|
guid = misc.GUID(text1)
|
||||||
self.assertEquals(text1, str(guid))
|
self.assertEquals(text1, str(guid))
|
||||||
@ -55,5 +56,9 @@ class PolicyHandleTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_repr(self):
|
def test_repr(self):
|
||||||
x = misc.policy_handle(text1, 42)
|
x = misc.policy_handle(text1, 42)
|
||||||
self.assertEquals("policy_handle('%s', %d)" % (text1, 42), repr(x))
|
self.assertEquals("policy_handle(%d, '%s')" % (42, text1), repr(x))
|
||||||
|
|
||||||
|
def test_str(self):
|
||||||
|
x = misc.policy_handle(text1, 42)
|
||||||
|
self.assertEquals("%d, %s" % (42, text1), str(x))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user