Allow mixing single objects and lists in bundles
...in bundle constructor Related: #429.pull/1/head
parent
c49703803c
commit
806389117f
|
@ -26,10 +26,14 @@ class Bundle(_STIXBase20):
|
|||
def __init__(self, *args, **kwargs):
|
||||
# Add any positional arguments to the 'objects' kwarg.
|
||||
if args:
|
||||
if isinstance(args[0], list):
|
||||
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
|
||||
obj_list = []
|
||||
for arg in args:
|
||||
if isinstance(arg, list):
|
||||
obj_list = obj_list + arg
|
||||
else:
|
||||
kwargs['objects'] = list(args) + kwargs.get('objects', [])
|
||||
obj_list.append(arg)
|
||||
|
||||
kwargs['objects'] = obj_list + kwargs.get('objects', [])
|
||||
|
||||
self._allow_custom = kwargs.get('allow_custom', False)
|
||||
self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False)
|
||||
|
|
|
@ -23,10 +23,14 @@ class Bundle(_STIXBase21):
|
|||
def __init__(self, *args, **kwargs):
|
||||
# Add any positional arguments to the 'objects' kwarg.
|
||||
if args:
|
||||
if isinstance(args[0], list):
|
||||
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
|
||||
obj_list = []
|
||||
for arg in args:
|
||||
if isinstance(arg, list):
|
||||
obj_list = obj_list + arg
|
||||
else:
|
||||
kwargs['objects'] = list(args) + kwargs.get('objects', [])
|
||||
obj_list.append(arg)
|
||||
|
||||
kwargs['objects'] = obj_list + kwargs.get('objects', [])
|
||||
|
||||
self._allow_custom = kwargs.get('allow_custom', False)
|
||||
self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False)
|
||||
|
|
Loading…
Reference in New Issue