def _get_community(path): for p in path['attrs']: if p['type'] == BGP_ATTR_TYPE_COMMUNITIES: return [community_str(c) for c in p['communities']] return None