From b8ccc6c99600a77c221b5a5125e7f4d9064cd512 Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Thu, 12 Jun 2008 14:47:16 +0000 Subject: [PATCH] define __repr__() for MovementGroup class to visualise the structure. [example] (Pdb) my_root_group <RootMovementGroup object at 0xa67a44c _group_list = [ <OrderMovementGroup object at 0xa67af8c _group_list = [ <DateMovementGroup object at 0xa67a0ec _group_list = [ <PathMovementGroup object at 0xa67a64c _group_list = [ <SectionPathMovementGroup object at 0xa67ab2c _group_list = [ <PriceCurrencyMovementGroup object at 0xa67a10c _group_list = [ <DecisionPathMovementGroup object at 0xa67accc _group_list = [ <AdministrationPathMovementGroup object at 0xa67a3cc _group_list = [ <ResourceMovementGroup object at 0xa67abcc _group_list = [ <BaseVariantMovementGroup object at 0xa67a20c _group_list = [ <CausalityAssignmentMovementGroup object at 0xa67acec _group_list = [ <VariantMovementGroup object at 0xa67acac _group_list = [ <CausalityAssignmentMovementGroup object at 0xa6a830c _movement_list = [<SimulationMovement at /erp5/portal_simulation/1/1>], _last_line_class_name = 'AdministrationPathMovementGroup', _separate_method_name_list = ['calculateAveragePrice', 'calculateAddQuantity'], _group_list = []>]>]>]>]>]>]>]>]>]>]>]>]> git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21546 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/MovementGroup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/product/ERP5/MovementGroup.py b/product/ERP5/MovementGroup.py index 45e48f4dcf..10f704f8ef 100644 --- a/product/ERP5/MovementGroup.py +++ b/product/ERP5/MovementGroup.py @@ -208,6 +208,19 @@ class RootMovementGroup: new_movement.setQuantityMethod("getAddQuantity") return new_movement, None + def __repr__(self): + repr_str = '<%s object at 0x%x\n' % (self.__class__.__name__, id(self)) + if self._movement_list: + repr_str += ' _movement_list = %r,\n' % self._movement_list + if self._group_list: + repr_str += ' _group_list = [\n%s]>' % ( + '\n'.join([' %s' % x for x in (',\n'.join([repr(i) for i in self._group_list])).split('\n')])) + else: + repr_str += ' _last_line_class_name = %r,\n' % self._last_line_class_name + repr_str += ' _separate_method_name_list = %r,\n' % self._separate_method_name_list + repr_str += ' _group_list = []>' + return repr_str + allow_class(RootMovementGroup) class OrderMovementGroup(RootMovementGroup): -- 2.30.9