def get_instance(cls, arguments={}): inventory = None if 'inventory' in arguments: assert len(arguments['inventory']) == 1, "You may not have more than one inventory!" for key, value in arguments['inventory'].iteritems(): storage = cls.storage_mapping[key] inventory = storage(**value) return cls(inventory=inventory)
def get_instance(cls, arguments=None): arguments = arguments or {} inventory = None if 'inventory' in arguments: assert len(arguments['inventory']) == 1, "You may not have more than one inventory!" key, value = arguments['inventory'].items()[0] storage = cls.storage_mapping[key] inventory = storage(**value) return cls(inventory=inventory)