def directions(cls, directionsType, source, destination, utterance=None): '''Create a :class:`.SiriObject` to display directions between two locations. * directionsType -- The type of directions to provide * source -- The source location * destination -- The destination location * utterance -- The utterance to speak ''' # @todo: Allow source and destination to be passed as # Locations, OR MapItems, and convert the Locations # to MapItems accordingly. mapPoints = Views.create(Views.MapPoints, source=source, destination=destination, directionsType=directionsType) commands = [mapPoints] resultCallback = Commands.create(Commands.ResultCallback, commands=commands) callbacks = [resultCallback] views = [] # Add the utternace to the views, if an utterance is given if utterance is not None: views.append(utterance) addViews = Views.create(Views.AddViews, callbacks=callbacks, views=views) # Note: Adding the ace id makes the map points work properly addViews.setAceId() commands = [addViews] resultCallback = Commands.create(Commands.ResultCallback, commands=commands) callbacks = [resultCallback] completed = Requests.create(Requests.RequestCompleted, callbacks=callbacks) return completed
def create(cls, actionType, *args, **kwargs): '''Return a specific Action wrapped in a SendCommands object so it can be sent to Siri as a command. * actionType -- The type of Action to create * args -- The arguments * kwargs -- The keyword arguments ''' sendCommand = None # Create the action object if it is found actionClass = Actions.__TypeMap.get(actionType) if actionClass is not None: action = actionClass(*args, **kwargs) sendCommand = Commands.create(Commands.SendCommands, [action]) return sendCommand