From f579b7eb1b1dd8e95df922f108a5daf275c0e1e5 Mon Sep 17 00:00:00 2001 From: Yann Rouillard Date: Fri, 31 May 2013 22:32:51 +0200 Subject: [PATCH] more succint code for describer_ver_flags and describe_syminfo_flags --- elftools/elf/descriptions.py | 39 ++++++++++++++---------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/elftools/elf/descriptions.py b/elftools/elf/descriptions.py index f760dfb..0fd5877 100644 --- a/elftools/elf/descriptions.py +++ b/elftools/elf/descriptions.py @@ -85,35 +85,26 @@ def describe_dyn_tag(x): def describe_syminfo_flags(x): - s = '' - for flag in ( - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_CAP, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECT, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_FILTER, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_AUXILIARY, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECTBIND, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_COPY, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_LAZYLOAD, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_NOEXTDIRECT, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_INTERPOSE, - SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DEFERRED): - s += _DESCR_SYMINFO_FLAGS[flag] if (x & flag) else '' - return s + return ''.join(_DESCR_SYMINFO_FLAGS[flag] for flag in ( + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_CAP, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECT, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_FILTER, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_AUXILIARY, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DIRECTBIND, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_COPY, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_LAZYLOAD, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_NOEXTDIRECT, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_INTERPOSE, + SUNW_SYMINFO_FLAGS.SYMINFO_FLG_DEFERRED) if x & flag) def describe_symbol_boundto(x): return _DESCR_SYMINFO_BOUNDTO.get(x, '%3s' % x) def describe_ver_flags(x): - s = '' - for flag in ( - VER_FLAGS.VER_FLG_WEAK, - VER_FLAGS.VER_FLG_BASE, - VER_FLAGS.VER_FLG_INFO): - if x & flag: - if s: - s += ' | ' - s += _DESCR_VER_FLAGS[flag] - return s + return ' | '.join(_DESCR_VER_FLAGS[flag] for flag in ( + VER_FLAGS.VER_FLG_WEAK, + VER_FLAGS.VER_FLG_BASE, + VER_FLAGS.VER_FLG_INFO) if x & flag) #------------------------------------------------------------------------------- _unknown = '' -- 2.30.2