Skip to content

Commit

Permalink
avoid dups
Browse files Browse the repository at this point in the history
  • Loading branch information
leifj committed Sep 10, 2019
1 parent dd89b64 commit bbdf245
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/pyff/samlmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,13 @@ def _resolve(m, l_fn):
else:
return l_fn(m)

resolved_entities = set()
resolved_entities = dict() # a set won't do since __compare__ doesn't use @entityID
for member in entities:
for entity in _resolve(member, lookup_fn):
resolved_entities.add(entity)

return resolved_entities
entity_id = entity.get('entityID', None)
if entity is not None and entity_id is not None:

This comment has been minimized.

Copy link
@c00kiemon5ter

c00kiemon5ter Sep 10, 2019

Member
  • entity will never be None here, as above we're treating it as a dict(); if it ever is None, the previous line will fail first.
  • is there an actual case where an entity_id is missing?
  • I think what we should be checking for is thruethiness
if entity and entity_id:

This comment has been minimized.

Copy link
@leifj

leifj Sep 10, 2019

Author Contributor

There are definitely cases in the wild with no entityID

resolved_entities[entity_id] = entity
return resolved_entities.values()


def entitiesdescriptor(entities,
Expand Down Expand Up @@ -360,12 +361,10 @@ def entitiesdescriptor(entities,
attrs['validUntil'] = valid_until
t = etree.Element("{%s}EntitiesDescriptor" % NS['md'], **attrs)
for entity in entities:
entity_id = entity.get('entityID', None)
if (entity is not None) and (entity_id is not None):
ent_insert = entity
if copy:
ent_insert = deepcopy(ent_insert)
t.append(ent_insert)
ent_insert = entity
if copy:
ent_insert = deepcopy(ent_insert)
t.append(ent_insert)

if config.devel_write_xml_to_file:
import os
Expand Down

0 comments on commit bbdf245

Please sign in to comment.