[apparmor] [patch] common.py: add recursive_print()

Christian Boltz apparmor at cboltz.de
Thu Feb 27 20:04:01 UTC 2014


Hello,

Am Donnerstag, 27. Februar 2014 schrieb Jamie Strandboge:
> On 02/26/2014 06:48 PM, Christian Boltz wrote:
> > this patch adds recursive_print() to common.py.
> > 
> > It prints a data structure in an easily readable output and is quite
> > useful[1] for debugging. However, I don't recommend to call it in
> > production code ;-)
> 
> Is pprint not an option?

Not really - I gave it a short test, but it resulted in a very long line.
Here's the head -c1000 of pprint'ing "aa", the hasher that stores all
profiles:

defaultdict(<function hasher at 0x1e9d320>, {u'/usr/lib/Adobe/Reader9/Reader/intellinux/bin/acroread': defaultdict(<function hasher at 0x1e9d320>, {u'/usr/lib/Adobe/Reader9/Reader/intellinux/bin/acroread': defaultdict(<function hasher at 0x1e9d320>, {'deny': defaultdict(<function hasher at 0x1e9d320>, {'path': defaultdict(<function hasher at 0x1e9d320>, {u'/dev/shm/pulse-shm-*': defaultdict(<function hasher at 0x1e9d320>, {'audit': set([]), 'mode': set(['::w', 'w'])}), u'/home/cb/.thumbnails/**': defaultdict(<function hasher at 0x1e9d320>, {'audit': set([]), 'mode': set(['r', '::r'])}), u'/home/cb/.pulse/': defaultdict(<function hasher at 0x1e9d320>, {'audit': set([]), 'mode': set(['::w', 'r', '::r', 'w'])}), u'/etc/fstab': defaultdict(<function hasher at 0x1e9d320>, {'audit': set([]), 'mode': set(['r', '::r'])}), u'/home/cb/.pulse-cookie': defaultdict(<function hasher at 0x1e9d320>, {'audit': set([]), 'mode': set(['::w', 'k', '::r', 'r', '::k', 'w'])})})}), 

That's not very readable IMHO ;-)

(If there's an option to add newlines at the right[tm] place and I just 
didn't find it, please tell me ;-)


Regards,

Christian Boltz
-- 
Der Schaden von privat benutzten Raubkopien entsteht absurderweise genau
der Konkurenz: Solange die Leute lieber ihre Raubkopie von Windows,
Office oder Photoshop benutzen, bekommen halt Linux, OpenOffice oder
Gimp keine Marktanteile.   [Mirko Streckenbach in d.r.s.c.a]




More information about the AppArmor mailing list