Merge pull request #430 from oasis-open/bundle-objs-and-lists
Allow mixing single objects and lists in bundle constructorpull/1/head
commit
bb82beeec1
|
@ -26,10 +26,14 @@ class Bundle(_STIXBase20):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# Add any positional arguments to the 'objects' kwarg.
|
# Add any positional arguments to the 'objects' kwarg.
|
||||||
if args:
|
if args:
|
||||||
if isinstance(args[0], list):
|
obj_list = []
|
||||||
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
|
for arg in args:
|
||||||
|
if isinstance(arg, list):
|
||||||
|
obj_list = obj_list + arg
|
||||||
else:
|
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._allow_custom = kwargs.get('allow_custom', False)
|
||||||
self._properties['objects'].contained.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):
|
def __init__(self, *args, **kwargs):
|
||||||
# Add any positional arguments to the 'objects' kwarg.
|
# Add any positional arguments to the 'objects' kwarg.
|
||||||
if args:
|
if args:
|
||||||
if isinstance(args[0], list):
|
obj_list = []
|
||||||
kwargs['objects'] = args[0] + list(args[1:]) + kwargs.get('objects', [])
|
for arg in args:
|
||||||
|
if isinstance(arg, list):
|
||||||
|
obj_list = obj_list + arg
|
||||||
else:
|
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._allow_custom = kwargs.get('allow_custom', False)
|
||||||
self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False)
|
self._properties['objects'].contained.allow_custom = kwargs.get('allow_custom', False)
|
||||||
|
|
Loading…
Reference in New Issue