Skip to content

Commit

Permalink
pep8 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
DominiqueDevinci committed Oct 21, 2019
1 parent 769cda4 commit adf450f
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions swig/openscap_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,27 @@ def remove(self, item):
litem = self.iterator.next()
if (type(item) == str and type(litem) == str and litem == item) or \
("instance" in item.__dict__ and litem.instance == item.instance):

self.iterator.remove()



'''
Warning, list.remove(self, item) will fail because python yield
a new reference at each loop. So wee need to loop again into the python list,
get the new reference and remove it. Demo:
print(item.instance)
print(litem.instance)
print(litem.instance == item.instance)
RETURNS:
print(litem.instance == item.instance)
RETURNS:
<Swig Object of type 'struct xccdf_refine_value *' at 0x7ff85ed73bd0>
<Swig Object of type 'struct xccdf_refine_value *' at 0x7ff85ed73c90>
True
'''

for i in self[:]:
if "instance" in item.__dict__ and i.instance == item.instance:
if "instance" in item.__dict__ and i.instance == item.instance:
list.remove(self, i)

except NameError:
Expand All @@ -124,8 +123,6 @@ def generate(self, iterator):

while iterator.has_more():
list.append(self, iterator.next())



def append(self, item, n=1):
"""This function is not allowed. Please use appropriate function from library."""
Expand Down

0 comments on commit adf450f

Please sign in to comment.