repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
rytilahti/python-songpal
songpal/device.py
Device.set_bluetooth_settings
async def set_bluetooth_settings(self, target: str, value: str) -> None: """Set bluetooth settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setBluetoothSettings"](params)
python
async def set_bluetooth_settings(self, target: str, value: str) -> None: """Set bluetooth settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setBluetoothSettings"](params)
[ "async", "def", "set_bluetooth_settings", "(", "self", ",", "target", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "params", "=", "{", "\"settings\"", ":", "[", "{", "\"target\"", ":", "target", ",", "\"value\"", ":", "value", "}", "]"...
Set bluetooth settings.
[ "Set", "bluetooth", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L295-L298
rytilahti/python-songpal
songpal/device.py
Device.set_custom_eq
async def set_custom_eq(self, target: str, value: str) -> None: """Set custom EQ settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setCustomEqualizerSettings"](params)
python
async def set_custom_eq(self, target: str, value: str) -> None: """Set custom EQ settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setCustomEqualizerSettings"](params)
[ "async", "def", "set_custom_eq", "(", "self", ",", "target", ":", "str", ",", "value", ":", "str", ")", "->", "None", ":", "params", "=", "{", "\"settings\"", ":", "[", "{", "\"target\"", ":", "target", ",", "\"value\"", ":", "value", "}", "]", "}", ...
Set custom EQ settings.
[ "Set", "custom", "EQ", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L304-L307
rytilahti/python-songpal
songpal/device.py
Device.get_supported_playback_functions
async def get_supported_playback_functions( self, uri="" ) -> List[SupportedFunctions]: """Return list of inputs and their supported functions.""" return [ SupportedFunctions.make(**x) for x in await self.services["avContent"]["getSupportedPlaybackFunction"]( ...
python
async def get_supported_playback_functions( self, uri="" ) -> List[SupportedFunctions]: """Return list of inputs and their supported functions.""" return [ SupportedFunctions.make(**x) for x in await self.services["avContent"]["getSupportedPlaybackFunction"]( ...
[ "async", "def", "get_supported_playback_functions", "(", "self", ",", "uri", "=", "\"\"", ")", "->", "List", "[", "SupportedFunctions", "]", ":", "return", "[", "SupportedFunctions", ".", "make", "(", "*", "*", "x", ")", "for", "x", "in", "await", "self", ...
Return list of inputs and their supported functions.
[ "Return", "list", "of", "inputs", "and", "their", "supported", "functions", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L309-L318
rytilahti/python-songpal
songpal/device.py
Device.get_playback_settings
async def get_playback_settings(self) -> List[Setting]: """Get playback settings such as shuffle and repeat.""" return [ Setting.make(**x) for x in await self.services["avContent"]["getPlaybackModeSettings"]({}) ]
python
async def get_playback_settings(self) -> List[Setting]: """Get playback settings such as shuffle and repeat.""" return [ Setting.make(**x) for x in await self.services["avContent"]["getPlaybackModeSettings"]({}) ]
[ "async", "def", "get_playback_settings", "(", "self", ")", "->", "List", "[", "Setting", "]", ":", "return", "[", "Setting", ".", "make", "(", "*", "*", "x", ")", "for", "x", "in", "await", "self", ".", "services", "[", "\"avContent\"", "]", "[", "\"...
Get playback settings such as shuffle and repeat.
[ "Get", "playback", "settings", "such", "as", "shuffle", "and", "repeat", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L320-L325
rytilahti/python-songpal
songpal/device.py
Device.set_playback_settings
async def set_playback_settings(self, target, value) -> None: """Set playback settings such a shuffle and repeat.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setPlaybackModeSettings"](params)
python
async def set_playback_settings(self, target, value) -> None: """Set playback settings such a shuffle and repeat.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["avContent"]["setPlaybackModeSettings"](params)
[ "async", "def", "set_playback_settings", "(", "self", ",", "target", ",", "value", ")", "->", "None", ":", "params", "=", "{", "\"settings\"", ":", "[", "{", "\"target\"", ":", "target", ",", "\"value\"", ":", "value", "}", "]", "}", "return", "await", ...
Set playback settings such a shuffle and repeat.
[ "Set", "playback", "settings", "such", "a", "shuffle", "and", "repeat", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L327-L330
rytilahti/python-songpal
songpal/device.py
Device.get_schemes
async def get_schemes(self) -> List[Scheme]: """Return supported uri schemes.""" return [ Scheme.make(**x) for x in await self.services["avContent"]["getSchemeList"]() ]
python
async def get_schemes(self) -> List[Scheme]: """Return supported uri schemes.""" return [ Scheme.make(**x) for x in await self.services["avContent"]["getSchemeList"]() ]
[ "async", "def", "get_schemes", "(", "self", ")", "->", "List", "[", "Scheme", "]", ":", "return", "[", "Scheme", ".", "make", "(", "*", "*", "x", ")", "for", "x", "in", "await", "self", ".", "services", "[", "\"avContent\"", "]", "[", "\"getSchemeLis...
Return supported uri schemes.
[ "Return", "supported", "uri", "schemes", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L332-L337
rytilahti/python-songpal
songpal/device.py
Device.get_source_list
async def get_source_list(self, scheme: str = "") -> List[Source]: """Return available sources for playback.""" res = await self.services["avContent"]["getSourceList"](scheme=scheme) return [Source.make(**x) for x in res]
python
async def get_source_list(self, scheme: str = "") -> List[Source]: """Return available sources for playback.""" res = await self.services["avContent"]["getSourceList"](scheme=scheme) return [Source.make(**x) for x in res]
[ "async", "def", "get_source_list", "(", "self", ",", "scheme", ":", "str", "=", "\"\"", ")", "->", "List", "[", "Source", "]", ":", "res", "=", "await", "self", ".", "services", "[", "\"avContent\"", "]", "[", "\"getSourceList\"", "]", "(", "scheme", "...
Return available sources for playback.
[ "Return", "available", "sources", "for", "playback", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L339-L342
rytilahti/python-songpal
songpal/device.py
Device.get_content_count
async def get_content_count(self, source: str): """Return file listing for source.""" params = {"uri": source, "type": None, "target": "all", "view": "flat"} return ContentInfo.make( **await self.services["avContent"]["getContentCount"](params) )
python
async def get_content_count(self, source: str): """Return file listing for source.""" params = {"uri": source, "type": None, "target": "all", "view": "flat"} return ContentInfo.make( **await self.services["avContent"]["getContentCount"](params) )
[ "async", "def", "get_content_count", "(", "self", ",", "source", ":", "str", ")", ":", "params", "=", "{", "\"uri\"", ":", "source", ",", "\"type\"", ":", "None", ",", "\"target\"", ":", "\"all\"", ",", "\"view\"", ":", "\"flat\"", "}", "return", "Conten...
Return file listing for source.
[ "Return", "file", "listing", "for", "source", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L344-L349
rytilahti/python-songpal
songpal/device.py
Device.get_contents
async def get_contents(self, uri) -> List[Content]: """Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects. """ contents = [ Content.make(**x) for x in await self.services["avContent"]["g...
python
async def get_contents(self, uri) -> List[Content]: """Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects. """ contents = [ Content.make(**x) for x in await self.services["avContent"]["g...
[ "async", "def", "get_contents", "(", "self", ",", "uri", ")", "->", "List", "[", "Content", "]", ":", "contents", "=", "[", "Content", ".", "make", "(", "*", "*", "x", ")", "for", "x", "in", "await", "self", ".", "services", "[", "\"avContent\"", "...
Request content listing recursively for the given URI. :param uri: URI for the source. :return: List of Content objects.
[ "Request", "content", "listing", "recursively", "for", "the", "given", "URI", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L351-L371
rytilahti/python-songpal
songpal/device.py
Device.get_volume_information
async def get_volume_information(self) -> List[Volume]: """Get the volume information.""" res = await self.services["audio"]["getVolumeInformation"]({}) volume_info = [Volume.make(services=self.services, **x) for x in res] if len(volume_info) < 1: logging.warning("Unable to g...
python
async def get_volume_information(self) -> List[Volume]: """Get the volume information.""" res = await self.services["audio"]["getVolumeInformation"]({}) volume_info = [Volume.make(services=self.services, **x) for x in res] if len(volume_info) < 1: logging.warning("Unable to g...
[ "async", "def", "get_volume_information", "(", "self", ")", "->", "List", "[", "Volume", "]", ":", "res", "=", "await", "self", ".", "services", "[", "\"audio\"", "]", "[", "\"getVolumeInformation\"", "]", "(", "{", "}", ")", "volume_info", "=", "[", "Vo...
Get the volume information.
[ "Get", "the", "volume", "information", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L373-L381
rytilahti/python-songpal
songpal/device.py
Device.get_sound_settings
async def get_sound_settings(self, target="") -> List[Setting]: """Get the current sound settings. :param str target: settings target, defaults to all. """ res = await self.services["audio"]["getSoundSettings"]({"target": target}) return [Setting.make(**x) for x in res]
python
async def get_sound_settings(self, target="") -> List[Setting]: """Get the current sound settings. :param str target: settings target, defaults to all. """ res = await self.services["audio"]["getSoundSettings"]({"target": target}) return [Setting.make(**x) for x in res]
[ "async", "def", "get_sound_settings", "(", "self", ",", "target", "=", "\"\"", ")", "->", "List", "[", "Setting", "]", ":", "res", "=", "await", "self", ".", "services", "[", "\"audio\"", "]", "[", "\"getSoundSettings\"", "]", "(", "{", "\"target\"", ":"...
Get the current sound settings. :param str target: settings target, defaults to all.
[ "Get", "the", "current", "sound", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L383-L389
rytilahti/python-songpal
songpal/device.py
Device.get_soundfield
async def get_soundfield(self) -> List[Setting]: """Get the current sound field settings.""" res = await self.services["audio"]["getSoundSettings"]({"target": "soundField"}) return Setting.make(**res[0])
python
async def get_soundfield(self) -> List[Setting]: """Get the current sound field settings.""" res = await self.services["audio"]["getSoundSettings"]({"target": "soundField"}) return Setting.make(**res[0])
[ "async", "def", "get_soundfield", "(", "self", ")", "->", "List", "[", "Setting", "]", ":", "res", "=", "await", "self", ".", "services", "[", "\"audio\"", "]", "[", "\"getSoundSettings\"", "]", "(", "{", "\"target\"", ":", "\"soundField\"", "}", ")", "r...
Get the current sound field settings.
[ "Get", "the", "current", "sound", "field", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L391-L394
rytilahti/python-songpal
songpal/device.py
Device.set_sound_settings
async def set_sound_settings(self, target: str, value: str): """Change a sound setting.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSoundSettings"](params)
python
async def set_sound_settings(self, target: str, value: str): """Change a sound setting.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSoundSettings"](params)
[ "async", "def", "set_sound_settings", "(", "self", ",", "target", ":", "str", ",", "value", ":", "str", ")", ":", "params", "=", "{", "\"settings\"", ":", "[", "{", "\"target\"", ":", "target", ",", "\"value\"", ":", "value", "}", "]", "}", "return", ...
Change a sound setting.
[ "Change", "a", "sound", "setting", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L400-L403
rytilahti/python-songpal
songpal/device.py
Device.get_speaker_settings
async def get_speaker_settings(self) -> List[Setting]: """Return speaker settings.""" speaker_settings = await self.services["audio"]["getSpeakerSettings"]({}) return [Setting.make(**x) for x in speaker_settings]
python
async def get_speaker_settings(self) -> List[Setting]: """Return speaker settings.""" speaker_settings = await self.services["audio"]["getSpeakerSettings"]({}) return [Setting.make(**x) for x in speaker_settings]
[ "async", "def", "get_speaker_settings", "(", "self", ")", "->", "List", "[", "Setting", "]", ":", "speaker_settings", "=", "await", "self", ".", "services", "[", "\"audio\"", "]", "[", "\"getSpeakerSettings\"", "]", "(", "{", "}", ")", "return", "[", "Sett...
Return speaker settings.
[ "Return", "speaker", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L405-L408
rytilahti/python-songpal
songpal/device.py
Device.set_speaker_settings
async def set_speaker_settings(self, target: str, value: str): """Set speaker settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSpeakerSettings"](params)
python
async def set_speaker_settings(self, target: str, value: str): """Set speaker settings.""" params = {"settings": [{"target": target, "value": value}]} return await self.services["audio"]["setSpeakerSettings"](params)
[ "async", "def", "set_speaker_settings", "(", "self", ",", "target", ":", "str", ",", "value", ":", "str", ")", ":", "params", "=", "{", "\"settings\"", ":", "[", "{", "\"target\"", ":", "target", ",", "\"value\"", ":", "value", "}", "]", "}", "return",...
Set speaker settings.
[ "Set", "speaker", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L410-L413
rytilahti/python-songpal
songpal/device.py
Device.listen_notifications
async def listen_notifications(self, fallback_callback=None): """Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to. """ tasks = [] async def handle_notification(notification): if type(notificatio...
python
async def listen_notifications(self, fallback_callback=None): """Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to. """ tasks = [] async def handle_notification(notification): if type(notificatio...
[ "async", "def", "listen_notifications", "(", "self", ",", "fallback_callback", "=", "None", ")", ":", "tasks", "=", "[", "]", "async", "def", "handle_notification", "(", "notification", ")", ":", "if", "type", "(", "notification", ")", "not", "in", "self", ...
Listen for notifications from the device forever. Use :func:on_notification: to register what notifications to listen to.
[ "Listen", "for", "notifications", "from", "the", "device", "forever", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L438-L469
rytilahti/python-songpal
songpal/device.py
Device.stop_listen_notifications
async def stop_listen_notifications(self): """Stop listening on notifications.""" _LOGGER.debug("Stopping listening for notifications..") for serv in self.services.values(): await serv.stop_listen_notifications() return True
python
async def stop_listen_notifications(self): """Stop listening on notifications.""" _LOGGER.debug("Stopping listening for notifications..") for serv in self.services.values(): await serv.stop_listen_notifications() return True
[ "async", "def", "stop_listen_notifications", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Stopping listening for notifications..\"", ")", "for", "serv", "in", "self", ".", "services", ".", "values", "(", ")", ":", "await", "serv", ".", "stop_listen_no...
Stop listening on notifications.
[ "Stop", "listening", "on", "notifications", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L471-L477
rytilahti/python-songpal
songpal/device.py
Device.get_notifications
async def get_notifications(self) -> List[Notification]: """Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects """ ...
python
async def get_notifications(self) -> List[Notification]: """Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects """ ...
[ "async", "def", "get_notifications", "(", "self", ")", "->", "List", "[", "Notification", "]", ":", "notifications", "=", "[", "]", "for", "serv", "in", "self", ".", "services", ":", "for", "notification", "in", "self", ".", "services", "[", "serv", "]",...
Get available notifications, which can then be subscribed to. Call :func:activate: to enable notifications, and :func:listen_notifications: to loop forever for notifications. :return: List of Notification objects
[ "Get", "available", "notifications", "which", "can", "then", "be", "subscribed", "to", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L479-L491
rytilahti/python-songpal
songpal/device.py
Device.raw_command
async def raw_command(self, service: str, method: str, params: Any): """Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. ...
python
async def raw_command(self, service: str, method: str, params: Any): """Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. ...
[ "async", "def", "raw_command", "(", "self", ",", "service", ":", "str", ",", "method", ":", "str", ",", "params", ":", "Any", ")", ":", "_LOGGER", ".", "info", "(", "\"Calling %s.%s(%s)\"", ",", "service", ",", "method", ",", "params", ")", "return", "...
Call an arbitrary method with given parameters. This is useful for debugging and trying out commands before implementing them properly. :param service: Service, use list(self.services) to get a list of availables. :param method: Method to call. :param params: Parameters as a pyt...
[ "Call", "an", "arbitrary", "method", "with", "given", "parameters", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/device.py#L493-L504
rytilahti/python-songpal
songpal/group.py
GroupControl.connect
async def connect(self): requester = AiohttpRequester() factory = UpnpFactory(requester) device = await factory.async_create_device(self.url) self.service = device.service('urn:schemas-sony-com:service:Group:1') if not self.service: _LOGGER.error("Unable to find grou...
python
async def connect(self): requester = AiohttpRequester() factory = UpnpFactory(requester) device = await factory.async_create_device(self.url) self.service = device.service('urn:schemas-sony-com:service:Group:1') if not self.service: _LOGGER.error("Unable to find grou...
[ "async", "def", "connect", "(", "self", ")", ":", "requester", "=", "AiohttpRequester", "(", ")", "factory", "=", "UpnpFactory", "(", "requester", ")", "device", "=", "await", "factory", ".", "async_create_device", "(", "self", ".", "url", ")", "self", "."...
Available actions INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetDeviceInfo)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetState)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_GetStateM)> ([]) INFO:songpal.upnpctl:Action: <UpnpService.Action(X_SetGroupNam...
[ "Available", "actions" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L83-L124
rytilahti/python-songpal
songpal/group.py
GroupControl.call
async def call(self, action, **kwargs): """Make an action call with given kwargs.""" act = self.service.action(action) _LOGGER.info("Calling %s with %s", action, kwargs) res = await act.async_call(**kwargs) _LOGGER.info(" Result: %s" % res) return res
python
async def call(self, action, **kwargs): """Make an action call with given kwargs.""" act = self.service.action(action) _LOGGER.info("Calling %s with %s", action, kwargs) res = await act.async_call(**kwargs) _LOGGER.info(" Result: %s" % res) return res
[ "async", "def", "call", "(", "self", ",", "action", ",", "*", "*", "kwargs", ")", ":", "act", "=", "self", ".", "service", ".", "action", "(", "action", ")", "_LOGGER", ".", "info", "(", "\"Calling %s with %s\"", ",", "action", ",", "kwargs", ")", "r...
Make an action call with given kwargs.
[ "Make", "an", "action", "call", "with", "given", "kwargs", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L125-L133
rytilahti/python-songpal
songpal/group.py
GroupControl.info
async def info(self): """Return device info.""" """ {'MasterCapability': 9, 'TransportPort': 3975} """ act = self.service.action("X_GetDeviceInfo") res = await act.async_call() return res
python
async def info(self): """Return device info.""" """ {'MasterCapability': 9, 'TransportPort': 3975} """ act = self.service.action("X_GetDeviceInfo") res = await act.async_call() return res
[ "async", "def", "info", "(", "self", ")", ":", "\"\"\"\n {'MasterCapability': 9, 'TransportPort': 3975}\n \"\"\"", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_GetDeviceInfo\"", ")", "res", "=", "await", "act", ".", "async_call", "(", "...
Return device info.
[ "Return", "device", "info", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L136-L143
rytilahti/python-songpal
songpal/group.py
GroupControl.state
async def state(self) -> GroupState: """Return the current group state""" act = self.service.action("X_GetState") res = await act.async_call() return GroupState.make(**res)
python
async def state(self) -> GroupState: """Return the current group state""" act = self.service.action("X_GetState") res = await act.async_call() return GroupState.make(**res)
[ "async", "def", "state", "(", "self", ")", "->", "GroupState", ":", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_GetState\"", ")", "res", "=", "await", "act", ".", "async_call", "(", ")", "return", "GroupState", ".", "make", "(", "*", ...
Return the current group state
[ "Return", "the", "current", "group", "state" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L145-L149
rytilahti/python-songpal
songpal/group.py
GroupControl.get_group_memory
async def get_group_memory(self): """Return group memory.""" # Returns an XML with groupMemoryList act = self.service.action("X_GetAllGroupMemory") res = await act.async_call() return res
python
async def get_group_memory(self): """Return group memory.""" # Returns an XML with groupMemoryList act = self.service.action("X_GetAllGroupMemory") res = await act.async_call() return res
[ "async", "def", "get_group_memory", "(", "self", ")", ":", "# Returns an XML with groupMemoryList", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_GetAllGroupMemory\"", ")", "res", "=", "await", "act", ".", "async_call", "(", ")", "return", "res" ]
Return group memory.
[ "Return", "group", "memory", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L157-L162
rytilahti/python-songpal
songpal/group.py
GroupControl.update_group_memory
async def update_group_memory(self, memory_id, mode, name, slaves, codectype=0x0040, bitrate=0x0003): """Update existing memory? Can be used to create new ones, too?""" act = self.service.action("X_UpdateGroupMemory") res = await act.async_call(MemoryID=memory_id, ...
python
async def update_group_memory(self, memory_id, mode, name, slaves, codectype=0x0040, bitrate=0x0003): """Update existing memory? Can be used to create new ones, too?""" act = self.service.action("X_UpdateGroupMemory") res = await act.async_call(MemoryID=memory_id, ...
[ "async", "def", "update_group_memory", "(", "self", ",", "memory_id", ",", "mode", ",", "name", ",", "slaves", ",", "codectype", "=", "0x0040", ",", "bitrate", "=", "0x0003", ")", ":", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_UpdateGr...
Update existing memory? Can be used to create new ones, too?
[ "Update", "existing", "memory?", "Can", "be", "used", "to", "create", "new", "ones", "too?" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L164-L174
rytilahti/python-songpal
songpal/group.py
GroupControl.delete_group_memory
async def delete_group_memory(self, memory_id): """Delete group memory.""" act = self.service.action("X_DeleteGroupMemory") res = await act.async_call(MemoryID=memory_id)
python
async def delete_group_memory(self, memory_id): """Delete group memory.""" act = self.service.action("X_DeleteGroupMemory") res = await act.async_call(MemoryID=memory_id)
[ "async", "def", "delete_group_memory", "(", "self", ",", "memory_id", ")", ":", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_DeleteGroupMemory\"", ")", "res", "=", "await", "act", ".", "async_call", "(", "MemoryID", "=", "memory_id", ")" ]
Delete group memory.
[ "Delete", "group", "memory", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L176-L179
rytilahti/python-songpal
songpal/group.py
GroupControl.get_codec
async def get_codec(self): """Get codec settings.""" act = self.service.action("X_GetCodec") res = await act.async_call() return res
python
async def get_codec(self): """Get codec settings.""" act = self.service.action("X_GetCodec") res = await act.async_call() return res
[ "async", "def", "get_codec", "(", "self", ")", ":", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_GetCodec\"", ")", "res", "=", "await", "act", ".", "async_call", "(", ")", "return", "res" ]
Get codec settings.
[ "Get", "codec", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L181-L185
rytilahti/python-songpal
songpal/group.py
GroupControl.set_codec
async def set_codec(self, codectype=0x0040, bitrate=0x0003): """Set codec settings.""" act = self.service.action("X_SetCodec") res = await act.async_call(CodecType=codectype, CodecBitrate=bitrate) return res
python
async def set_codec(self, codectype=0x0040, bitrate=0x0003): """Set codec settings.""" act = self.service.action("X_SetCodec") res = await act.async_call(CodecType=codectype, CodecBitrate=bitrate) return res
[ "async", "def", "set_codec", "(", "self", ",", "codectype", "=", "0x0040", ",", "bitrate", "=", "0x0003", ")", ":", "act", "=", "self", ".", "service", ".", "action", "(", "\"X_SetCodec\"", ")", "res", "=", "await", "act", ".", "async_call", "(", "Code...
Set codec settings.
[ "Set", "codec", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L187-L191
rytilahti/python-songpal
songpal/group.py
GroupControl.abort
async def abort(self): """Abort current group session.""" state = await self.state() res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID) return res
python
async def abort(self): """Abort current group session.""" state = await self.state() res = await self.call("X_Abort", MasterSessionID=state.MasterSessionID) return res
[ "async", "def", "abort", "(", "self", ")", ":", "state", "=", "await", "self", ".", "state", "(", ")", "res", "=", "await", "self", ".", "call", "(", "\"X_Abort\"", ",", "MasterSessionID", "=", "state", ".", "MasterSessionID", ")", "return", "res" ]
Abort current group session.
[ "Abort", "current", "group", "session", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L193-L197
rytilahti/python-songpal
songpal/group.py
GroupControl.stop
async def stop(self): """Stop playback?""" state = await self.state() res = await self.call("X_Stop", MasterSessionID=state.MasterSessionID) return res
python
async def stop(self): """Stop playback?""" state = await self.state() res = await self.call("X_Stop", MasterSessionID=state.MasterSessionID) return res
[ "async", "def", "stop", "(", "self", ")", ":", "state", "=", "await", "self", ".", "state", "(", ")", "res", "=", "await", "self", ".", "call", "(", "\"X_Stop\"", ",", "MasterSessionID", "=", "state", ".", "MasterSessionID", ")", "return", "res" ]
Stop playback?
[ "Stop", "playback?" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L199-L203
rytilahti/python-songpal
songpal/group.py
GroupControl.play
async def play(self): """Start playback?""" state = await self.state() res = await self.call("X_Play", MasterSessionID=state.MasterSessionID) return res
python
async def play(self): """Start playback?""" state = await self.state() res = await self.call("X_Play", MasterSessionID=state.MasterSessionID) return res
[ "async", "def", "play", "(", "self", ")", ":", "state", "=", "await", "self", ".", "state", "(", ")", "res", "=", "await", "self", ".", "call", "(", "\"X_Play\"", ",", "MasterSessionID", "=", "state", ".", "MasterSessionID", ")", "return", "res" ]
Start playback?
[ "Start", "playback?" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L205-L209
rytilahti/python-songpal
songpal/group.py
GroupControl.create
async def create(self, name, slaves): """Create a group.""" # NOTE: codectype and codecbitrate were simply chosen from an example.. res = await self.call("X_Start", GroupMode="GROUP", GroupName=name, SlaveList=",".join(slaves), ...
python
async def create(self, name, slaves): """Create a group.""" # NOTE: codectype and codecbitrate were simply chosen from an example.. res = await self.call("X_Start", GroupMode="GROUP", GroupName=name, SlaveList=",".join(slaves), ...
[ "async", "def", "create", "(", "self", ",", "name", ",", "slaves", ")", ":", "# NOTE: codectype and codecbitrate were simply chosen from an example..", "res", "=", "await", "self", ".", "call", "(", "\"X_Start\"", ",", "GroupMode", "=", "\"GROUP\"", ",", "GroupName"...
Create a group.
[ "Create", "a", "group", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/group.py#L211-L219
rytilahti/python-songpal
songpal/service.py
Service.fetch_signatures
async def fetch_signatures(endpoint, protocol, idgen): """Request available methods for the service.""" async with aiohttp.ClientSession() as session: req = { "method": "getMethodTypes", "params": [''], "version": "1.0", "id": n...
python
async def fetch_signatures(endpoint, protocol, idgen): """Request available methods for the service.""" async with aiohttp.ClientSession() as session: req = { "method": "getMethodTypes", "params": [''], "version": "1.0", "id": n...
[ "async", "def", "fetch_signatures", "(", "endpoint", ",", "protocol", ",", "idgen", ")", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "req", "=", "{", "\"method\"", ":", "\"getMethodTypes\"", ",", "\"params\"", ":", ...
Request available methods for the service.
[ "Request", "available", "methods", "for", "the", "service", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L41-L60
rytilahti/python-songpal
songpal/service.py
Service.from_payload
async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None): """Create Service object from a payload.""" service_name = payload["service"] if "protocols" not in payload: raise SongpalException( "Unable to find protocols from payload: %s" % paylo...
python
async def from_payload(cls, payload, endpoint, idgen, debug, force_protocol=None): """Create Service object from a payload.""" service_name = payload["service"] if "protocols" not in payload: raise SongpalException( "Unable to find protocols from payload: %s" % paylo...
[ "async", "def", "from_payload", "(", "cls", ",", "payload", ",", "endpoint", ",", "idgen", ",", "debug", ",", "force_protocol", "=", "None", ")", ":", "service_name", "=", "payload", "[", "\"service\"", "]", "if", "\"protocols\"", "not", "in", "payload", "...
Create Service object from a payload.
[ "Create", "Service", "object", "from", "a", "payload", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L63-L124
rytilahti/python-songpal
songpal/service.py
Service.call_method
async def call_method(self, method, *args, **kwargs): """Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides exter...
python
async def call_method(self, method, *args, **kwargs): """Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides exter...
[ "async", "def", "call_method", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"%s got called with args (%s) kwargs (%s)\"", "%", "(", "method", ".", "name", ",", "args", ",", "kwargs", ")", ...
Call a method (internal). This is an internal implementation, which formats the parameters if necessary and chooses the preferred transport protocol. The return values are JSON objects. Use :func:__call__: provides external API leveraging this.
[ "Call", "a", "method", "(", "internal", ")", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L126-L197
rytilahti/python-songpal
songpal/service.py
Service.wrap_notification
def wrap_notification(self, data): """Convert notification JSON to a notification class.""" if "method" in data: method = data["method"] params = data["params"] change = params[0] if method == "notifyPowerStatus": return PowerChange.make(**...
python
def wrap_notification(self, data): """Convert notification JSON to a notification class.""" if "method" in data: method = data["method"] params = data["params"] change = params[0] if method == "notifyPowerStatus": return PowerChange.make(**...
[ "def", "wrap_notification", "(", "self", ",", "data", ")", ":", "if", "\"method\"", "in", "data", ":", "method", "=", "data", "[", "\"method\"", "]", "params", "=", "data", "[", "\"params\"", "]", "change", "=", "params", "[", "0", "]", "if", "method",...
Convert notification JSON to a notification class.
[ "Convert", "notification", "JSON", "to", "a", "notification", "class", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L199-L223
rytilahti/python-songpal
songpal/service.py
Service.listen_all_notifications
async def listen_all_notifications(self, callback): """Enable all exposed notifications. :param callback: Callback to call when a notification is received. """ everything = [noti.asdict() for noti in self.notifications] if len(everything) > 0: await self._methods["sw...
python
async def listen_all_notifications(self, callback): """Enable all exposed notifications. :param callback: Callback to call when a notification is received. """ everything = [noti.asdict() for noti in self.notifications] if len(everything) > 0: await self._methods["sw...
[ "async", "def", "listen_all_notifications", "(", "self", ",", "callback", ")", ":", "everything", "=", "[", "noti", ".", "asdict", "(", ")", "for", "noti", "in", "self", ".", "notifications", "]", "if", "len", "(", "everything", ")", ">", "0", ":", "aw...
Enable all exposed notifications. :param callback: Callback to call when a notification is received.
[ "Enable", "all", "exposed", "notifications", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L266-L277
rytilahti/python-songpal
songpal/service.py
Service.asdict
def asdict(self): """Return dict presentation of this service. Useful for dumping the device information into JSON. """ return { "methods": {m.name: m.asdict() for m in self.methods}, "protocols": self.protocols, "notifications": {n.name: n.asdict() f...
python
def asdict(self): """Return dict presentation of this service. Useful for dumping the device information into JSON. """ return { "methods": {m.name: m.asdict() for m in self.methods}, "protocols": self.protocols, "notifications": {n.name: n.asdict() f...
[ "def", "asdict", "(", "self", ")", ":", "return", "{", "\"methods\"", ":", "{", "m", ".", "name", ":", "m", ".", "asdict", "(", ")", "for", "m", "in", "self", ".", "methods", "}", ",", "\"protocols\"", ":", "self", ".", "protocols", ",", "\"notific...
Return dict presentation of this service. Useful for dumping the device information into JSON.
[ "Return", "dict", "presentation", "of", "this", "service", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/service.py#L283-L292
scivision/lowtran
lowtran/scenarios.py
horizrad
def horizrad(infn: Path, outfn: Path, c1: dict) -> xarray.Dataset: """ read CSV, simulate, write, plot """ if infn is not None: infn = Path(infn).expanduser() if infn.suffix == '.h5': TR = xarray.open_dataset(infn) return TR c1.update({'model': 0, # 0: user...
python
def horizrad(infn: Path, outfn: Path, c1: dict) -> xarray.Dataset: """ read CSV, simulate, write, plot """ if infn is not None: infn = Path(infn).expanduser() if infn.suffix == '.h5': TR = xarray.open_dataset(infn) return TR c1.update({'model': 0, # 0: user...
[ "def", "horizrad", "(", "infn", ":", "Path", ",", "outfn", ":", "Path", ",", "c1", ":", "dict", ")", "->", "xarray", ".", "Dataset", ":", "if", "infn", "is", "not", "None", ":", "infn", "=", "Path", "(", "infn", ")", ".", "expanduser", "(", ")", ...
read CSV, simulate, write, plot
[ "read", "CSV", "simulate", "write", "plot" ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/scenarios.py#L50-L85
scivision/lowtran
lowtran/base.py
nm2lt7
def nm2lt7(short_nm: float, long_nm: float, step_cminv: float = 20) -> Tuple[float, float, float]: """converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step s...
python
def nm2lt7(short_nm: float, long_nm: float, step_cminv: float = 20) -> Tuple[float, float, float]: """converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step s...
[ "def", "nm2lt7", "(", "short_nm", ":", "float", ",", "long_nm", ":", "float", ",", "step_cminv", ":", "float", "=", "20", ")", "->", "Tuple", "[", "float", ",", "float", ",", "float", "]", ":", "short", "=", "1e7", "/", "short_nm", "long", "=", "1e...
converts wavelength in nm to cm^-1 minimum meaningful step is 20, but 5 is minimum before crashing lowtran short: shortest wavelength e.g. 200 nm long: longest wavelength e.g. 30000 nm step: step size in cm^-1 e.g. 20 output in cm^-1
[ "converts", "wavelength", "in", "nm", "to", "cm^", "-", "1", "minimum", "meaningful", "step", "is", "20", "but", "5", "is", "minimum", "before", "crashing", "lowtran" ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L12-L27
scivision/lowtran
lowtran/base.py
loopuserdef
def loopuserdef(c1: Dict[str, Any]) -> xarray.DataArray: """ golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length """ wmol = np.atleast_2d(c1['wmol']) P = np.atleast_1d(c1['p']) T =...
python
def loopuserdef(c1: Dict[str, Any]) -> xarray.DataArray: """ golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length """ wmol = np.atleast_2d(c1['wmol']) P = np.atleast_1d(c1['p']) T =...
[ "def", "loopuserdef", "(", "c1", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "xarray", ".", "DataArray", ":", "wmol", "=", "np", ".", "atleast_2d", "(", "c1", "[", "'wmol'", "]", ")", "P", "=", "np", ".", "atleast_1d", "(", "c1", "[", ...
golowtran() is for scalar parameters only (besides vector of wavelength, which Lowtran internally loops over) wmol, p, t must all be vector(s) of same length
[ "golowtran", "()", "is", "for", "scalar", "parameters", "only", "(", "besides", "vector", "of", "wavelength", "which", "Lowtran", "internally", "loops", "over", ")" ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L30-L60
scivision/lowtran
lowtran/base.py
loopangle
def loopangle(c1: Dict[str, Any]) -> xarray.Dataset: """ loop over "ANGLE" """ angles = np.atleast_1d(c1['angle']) TR = xarray.Dataset(coords={'wavelength_nm': None, 'angle_deg': angles}) for a in angles: c = c1.copy() c['angle'] = a TR = TR.merge(golowtran(c)) retu...
python
def loopangle(c1: Dict[str, Any]) -> xarray.Dataset: """ loop over "ANGLE" """ angles = np.atleast_1d(c1['angle']) TR = xarray.Dataset(coords={'wavelength_nm': None, 'angle_deg': angles}) for a in angles: c = c1.copy() c['angle'] = a TR = TR.merge(golowtran(c)) retu...
[ "def", "loopangle", "(", "c1", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "xarray", ".", "Dataset", ":", "angles", "=", "np", ".", "atleast_1d", "(", "c1", "[", "'angle'", "]", ")", "TR", "=", "xarray", ".", "Dataset", "(", "coords", "=...
loop over "ANGLE"
[ "loop", "over", "ANGLE" ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L63-L75
scivision/lowtran
lowtran/base.py
golowtran
def golowtran(c1: Dict[str, Any]) -> xarray.Dataset: """directly run Fortran code""" # %% default parameters c1.setdefault('time', None) defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: c1.setdefault(p, 0) c1.setdefault('wmol', [0]*12) # %% ...
python
def golowtran(c1: Dict[str, Any]) -> xarray.Dataset: """directly run Fortran code""" # %% default parameters c1.setdefault('time', None) defp = ('h1', 'h2', 'angle', 'im', 'iseasn', 'ird1', 'range_km', 'zmdl', 'p', 't') for p in defp: c1.setdefault(p, 0) c1.setdefault('wmol', [0]*12) # %% ...
[ "def", "golowtran", "(", "c1", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "xarray", ".", "Dataset", ":", "# %% default parameters", "c1", ".", "setdefault", "(", "'time'", ",", "None", ")", "defp", "=", "(", "'h1'", ",", "'h2'", ",", "'angl...
directly run Fortran code
[ "directly", "run", "Fortran", "code" ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/base.py#L78-L121
scivision/lowtran
lowtran/plots.py
plotradtime
def plotradtime(TR: xarray.Dataset, c1: Dict[str, Any], log: bool = False): """ make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar """ for t in TR.time: # for each time plotirrad(TR.sel(time=t), c1, lo...
python
def plotradtime(TR: xarray.Dataset, c1: Dict[str, Any], log: bool = False): """ make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar """ for t in TR.time: # for each time plotirrad(TR.sel(time=t), c1, lo...
[ "def", "plotradtime", "(", "TR", ":", "xarray", ".", "Dataset", ",", "c1", ":", "Dict", "[", "str", ",", "Any", "]", ",", "log", ":", "bool", "=", "False", ")", ":", "for", "t", "in", "TR", ".", "time", ":", "# for each time", "plotirrad", "(", "...
make one plot per time for now. TR: 3-D array: time, wavelength, [transmittance, radiance] radiance is currently single-scatter solar
[ "make", "one", "plot", "per", "time", "for", "now", "." ]
train
https://github.com/scivision/lowtran/blob/9954d859e53437436103f9ab54a7e2602ecaa1b7/lowtran/plots.py#L90-L100
rytilahti/python-songpal
songpal/method.py
Method.asdict
def asdict(self) -> Dict[str, Union[Dict, Union[str, Dict]]]: """Return a dictionary describing the method. This can be used to dump the information into a JSON file. """ return { "service": self.service.name, **self.signature.serialize(), }
python
def asdict(self) -> Dict[str, Union[Dict, Union[str, Dict]]]: """Return a dictionary describing the method. This can be used to dump the information into a JSON file. """ return { "service": self.service.name, **self.signature.serialize(), }
[ "def", "asdict", "(", "self", ")", "->", "Dict", "[", "str", ",", "Union", "[", "Dict", ",", "Union", "[", "str", ",", "Dict", "]", "]", "]", ":", "return", "{", "\"service\"", ":", "self", ".", "service", ".", "name", ",", "*", "*", "self", "....
Return a dictionary describing the method. This can be used to dump the information into a JSON file.
[ "Return", "a", "dictionary", "describing", "the", "method", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/method.py#L107-L115
rytilahti/python-songpal
songpal/common.py
DeviceError.error
def error(self): """Return user-friendly error message.""" try: errcode = DeviceErrorCode(self.error_code) return "%s (%s): %s" % (errcode.name, errcode.value, self.error_message) except: return "Error %s: %s" % (self.error_code, self.error_message)
python
def error(self): """Return user-friendly error message.""" try: errcode = DeviceErrorCode(self.error_code) return "%s (%s): %s" % (errcode.name, errcode.value, self.error_message) except: return "Error %s: %s" % (self.error_code, self.error_message)
[ "def", "error", "(", "self", ")", ":", "try", ":", "errcode", "=", "DeviceErrorCode", "(", "self", ".", "error_code", ")", "return", "\"%s (%s): %s\"", "%", "(", "errcode", ".", "name", ",", "errcode", ".", "value", ",", "self", ".", "error_message", ")"...
Return user-friendly error message.
[ "Return", "user", "-", "friendly", "error", "message", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/common.py#L29-L35
rytilahti/python-songpal
songpal/main.py
err
def err(msg): """Pretty-print an error.""" click.echo(click.style(msg, fg="red", bold=True))
python
def err(msg): """Pretty-print an error.""" click.echo(click.style(msg, fg="red", bold=True))
[ "def", "err", "(", "msg", ")", ":", "click", ".", "echo", "(", "click", ".", "style", "(", "msg", ",", "fg", "=", "\"red\"", ",", "bold", "=", "True", ")", ")" ]
Pretty-print an error.
[ "Pretty", "-", "print", "an", "error", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L33-L35
rytilahti/python-songpal
songpal/main.py
coro
def coro(f): """Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930 """ f = asyncio.coroutine(f) def wrapper(*args, **kwargs): loop = asyncio.get_event_loop() try: return loop.run_until_co...
python
def coro(f): """Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930 """ f = asyncio.coroutine(f) def wrapper(*args, **kwargs): loop = asyncio.get_event_loop() try: return loop.run_until_co...
[ "def", "coro", "(", "f", ")", ":", "f", "=", "asyncio", ".", "coroutine", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "try", ":", "return", "loop",...
Run a coroutine and handle possible errors for the click cli. Source https://github.com/pallets/click/issues/85#issuecomment-43378930
[ "Run", "a", "coroutine", "and", "handle", "possible", "errors", "for", "the", "click", "cli", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L38-L59
rytilahti/python-songpal
songpal/main.py
traverse_settings
async def traverse_settings(dev, module, settings, depth=0): """Print all available settings.""" for setting in settings: if setting.is_directory: print("%s%s (%s)" % (depth * " ", setting.title, module)) return await traverse_settings(dev, module, setting.settings, depth + 2) ...
python
async def traverse_settings(dev, module, settings, depth=0): """Print all available settings.""" for setting in settings: if setting.is_directory: print("%s%s (%s)" % (depth * " ", setting.title, module)) return await traverse_settings(dev, module, setting.settings, depth + 2) ...
[ "async", "def", "traverse_settings", "(", "dev", ",", "module", ",", "settings", ",", "depth", "=", "0", ")", ":", "for", "setting", "in", "settings", ":", "if", "setting", ".", "is_directory", ":", "print", "(", "\"%s%s (%s)\"", "%", "(", "depth", "*", ...
Print all available settings.
[ "Print", "all", "available", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L62-L73
rytilahti/python-songpal
songpal/main.py
print_settings
def print_settings(settings, depth=0): """Print all available settings of the device.""" # handle the case where a single setting is passed if isinstance(settings, Setting): settings = [settings] for setting in settings: cur = setting.currentValue print( "%s* %s (%s, ...
python
def print_settings(settings, depth=0): """Print all available settings of the device.""" # handle the case where a single setting is passed if isinstance(settings, Setting): settings = [settings] for setting in settings: cur = setting.currentValue print( "%s* %s (%s, ...
[ "def", "print_settings", "(", "settings", ",", "depth", "=", "0", ")", ":", "# handle the case where a single setting is passed", "if", "isinstance", "(", "settings", ",", "Setting", ")", ":", "settings", "=", "[", "settings", "]", "for", "setting", "in", "setti...
Print all available settings of the device.
[ "Print", "all", "available", "settings", "of", "the", "device", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L76-L102
rytilahti/python-songpal
songpal/main.py
cli
async def cli(ctx, endpoint, debug, websocket, post): """Songpal CLI.""" lvl = logging.INFO if debug: lvl = logging.DEBUG click.echo("Setting debug level to %s" % debug) logging.basicConfig(level=lvl) if ctx.invoked_subcommand == "discover": ctx.obj = {"debug": debug} ...
python
async def cli(ctx, endpoint, debug, websocket, post): """Songpal CLI.""" lvl = logging.INFO if debug: lvl = logging.DEBUG click.echo("Setting debug level to %s" % debug) logging.basicConfig(level=lvl) if ctx.invoked_subcommand == "discover": ctx.obj = {"debug": debug} ...
[ "async", "def", "cli", "(", "ctx", ",", "endpoint", ",", "debug", ",", "websocket", ",", "post", ")", ":", "lvl", "=", "logging", ".", "INFO", "if", "debug", ":", "lvl", "=", "logging", ".", "DEBUG", "click", ".", "echo", "(", "\"Setting debug level to...
Songpal CLI.
[ "Songpal", "CLI", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L115-L147
rytilahti/python-songpal
songpal/main.py
status
async def status(dev: Device): """Display status information.""" power = await dev.get_power() click.echo(click.style("%s" % power, bold=power)) vol = await dev.get_volume_information() click.echo(vol.pop()) play_info = await dev.get_play_info() if not play_info.is_idle: click.echo...
python
async def status(dev: Device): """Display status information.""" power = await dev.get_power() click.echo(click.style("%s" % power, bold=power)) vol = await dev.get_volume_information() click.echo(vol.pop()) play_info = await dev.get_play_info() if not play_info.is_idle: click.echo...
[ "async", "def", "status", "(", "dev", ":", "Device", ")", ":", "power", "=", "await", "dev", ".", "get_power", "(", ")", "click", ".", "echo", "(", "click", ".", "style", "(", "\"%s\"", "%", "power", ",", "bold", "=", "power", ")", ")", "vol", "=...
Display status information.
[ "Display", "status", "information", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L157-L177
rytilahti/python-songpal
songpal/main.py
discover
async def discover(ctx): """Discover supported devices.""" TIMEOUT = 5 async def print_discovered(dev): pretty_name = "%s - %s" % (dev.name, dev.model_number) click.echo(click.style("\nFound %s" % pretty_name, bold=True)) click.echo("* API version: %s" % dev.version) click....
python
async def discover(ctx): """Discover supported devices.""" TIMEOUT = 5 async def print_discovered(dev): pretty_name = "%s - %s" % (dev.name, dev.model_number) click.echo(click.style("\nFound %s" % pretty_name, bold=True)) click.echo("* API version: %s" % dev.version) click....
[ "async", "def", "discover", "(", "ctx", ")", ":", "TIMEOUT", "=", "5", "async", "def", "print_discovered", "(", "dev", ")", ":", "pretty_name", "=", "\"%s - %s\"", "%", "(", "dev", ".", "name", ",", "dev", ".", "model_number", ")", "click", ".", "echo"...
Discover supported devices.
[ "Discover", "supported", "devices", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L183-L204
rytilahti/python-songpal
songpal/main.py
power
async def power(dev: Device, cmd, target, value): """Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'. """ async def try_turn(cmd): state = True if cmd == "on" else False try: return await dev.set_power(state) except SongpalExcept...
python
async def power(dev: Device, cmd, target, value): """Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'. """ async def try_turn(cmd): state = True if cmd == "on" else False try: return await dev.set_power(state) except SongpalExcept...
[ "async", "def", "power", "(", "dev", ":", "Device", ",", "cmd", ",", "target", ",", "value", ")", ":", "async", "def", "try_turn", "(", "cmd", ")", ":", "state", "=", "True", "if", "cmd", "==", "\"on\"", "else", "False", "try", ":", "return", "awai...
Turn on and off, control power settings. Accepts commands 'on', 'off', and 'settings'.
[ "Turn", "on", "and", "off", "control", "power", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L213-L237
rytilahti/python-songpal
songpal/main.py
input
async def input(dev: Device, input, output): """Get and change outputs.""" inputs = await dev.get_inputs() if input: click.echo("Activating %s" % input) try: input = next((x for x in inputs if x.title == input)) except StopIteration: click.echo("Unable to find...
python
async def input(dev: Device, input, output): """Get and change outputs.""" inputs = await dev.get_inputs() if input: click.echo("Activating %s" % input) try: input = next((x for x in inputs if x.title == input)) except StopIteration: click.echo("Unable to find...
[ "async", "def", "input", "(", "dev", ":", "Device", ",", "input", ",", "output", ")", ":", "inputs", "=", "await", "dev", ".", "get_inputs", "(", ")", "if", "input", ":", "click", ".", "echo", "(", "\"Activating %s\"", "%", "input", ")", "try", ":", ...
Get and change outputs.
[ "Get", "and", "change", "outputs", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L245-L271
rytilahti/python-songpal
songpal/main.py
zone
async def zone(dev: Device, zone, activate): """Get and change outputs.""" if zone: zone = await dev.get_zone(zone) click.echo("%s %s" % ("Activating" if activate else "Deactivating", zone)) await zone.activate(activate) else: click.echo("Zones:") for zone in await d...
python
async def zone(dev: Device, zone, activate): """Get and change outputs.""" if zone: zone = await dev.get_zone(zone) click.echo("%s %s" % ("Activating" if activate else "Deactivating", zone)) await zone.activate(activate) else: click.echo("Zones:") for zone in await d...
[ "async", "def", "zone", "(", "dev", ":", "Device", ",", "zone", ",", "activate", ")", ":", "if", "zone", ":", "zone", "=", "await", "dev", ".", "get_zone", "(", "zone", ")", "click", ".", "echo", "(", "\"%s %s\"", "%", "(", "\"Activating\"", "if", ...
Get and change outputs.
[ "Get", "and", "change", "outputs", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L279-L291
rytilahti/python-songpal
songpal/main.py
googlecast
async def googlecast(dev: Device, target, value): """Return Googlecast settings.""" if target and value: click.echo("Setting %s = %s" % (target, value)) await dev.set_googlecast_settings(target, value) print_settings(await dev.get_googlecast_settings())
python
async def googlecast(dev: Device, target, value): """Return Googlecast settings.""" if target and value: click.echo("Setting %s = %s" % (target, value)) await dev.set_googlecast_settings(target, value) print_settings(await dev.get_googlecast_settings())
[ "async", "def", "googlecast", "(", "dev", ":", "Device", ",", "target", ",", "value", ")", ":", "if", "target", "and", "value", ":", "click", ".", "echo", "(", "\"Setting %s = %s\"", "%", "(", "target", ",", "value", ")", ")", "await", "dev", ".", "s...
Return Googlecast settings.
[ "Return", "Googlecast", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L299-L304
rytilahti/python-songpal
songpal/main.py
source
async def source(dev: Device, scheme): """List available sources. If no `scheme` is given, will list sources for all sc hemes. """ if scheme is None: schemes = await dev.get_schemes() schemes = [scheme.scheme for scheme in schemes] # noqa: T484 else: schemes = [scheme] ...
python
async def source(dev: Device, scheme): """List available sources. If no `scheme` is given, will list sources for all sc hemes. """ if scheme is None: schemes = await dev.get_schemes() schemes = [scheme.scheme for scheme in schemes] # noqa: T484 else: schemes = [scheme] ...
[ "async", "def", "source", "(", "dev", ":", "Device", ",", "scheme", ")", ":", "if", "scheme", "is", "None", ":", "schemes", "=", "await", "dev", ".", "get_schemes", "(", ")", "schemes", "=", "[", "scheme", ".", "scheme", "for", "scheme", "in", "schem...
List available sources. If no `scheme` is given, will list sources for all sc hemes.
[ "List", "available", "sources", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L311-L340
rytilahti/python-songpal
songpal/main.py
volume
async def volume(dev: Device, volume, output): """Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it. """ vol = None vol_controls = await dev.get_volume_information() if output is not None: click.echo("Using output: %s" % output) ...
python
async def volume(dev: Device, volume, output): """Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it. """ vol = None vol_controls = await dev.get_volume_information() if output is not None: click.echo("Using output: %s" % output) ...
[ "async", "def", "volume", "(", "dev", ":", "Device", ",", "volume", ",", "output", ")", ":", "vol", "=", "None", "vol_controls", "=", "await", "dev", ".", "get_volume_information", "(", ")", "if", "output", "is", "not", "None", ":", "click", ".", "echo...
Get and set the volume settings. Passing 'mute' as new volume will mute the volume, 'unmute' removes it.
[ "Get", "and", "set", "the", "volume", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L348-L383
rytilahti/python-songpal
songpal/main.py
schemes
async def schemes(dev: Device): """Print supported uri schemes.""" schemes = await dev.get_schemes() for scheme in schemes: click.echo(scheme)
python
async def schemes(dev: Device): """Print supported uri schemes.""" schemes = await dev.get_schemes() for scheme in schemes: click.echo(scheme)
[ "async", "def", "schemes", "(", "dev", ":", "Device", ")", ":", "schemes", "=", "await", "dev", ".", "get_schemes", "(", ")", "for", "scheme", "in", "schemes", ":", "click", ".", "echo", "(", "scheme", ")" ]
Print supported uri schemes.
[ "Print", "supported", "uri", "schemes", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L389-L393
rytilahti/python-songpal
songpal/main.py
check_update
async def check_update(dev: Device, internet: bool, update: bool): """Print out update information.""" if internet: print("Checking updates from network") else: print("Not checking updates from internet") update_info = await dev.get_update_info(from_network=internet) if not update_in...
python
async def check_update(dev: Device, internet: bool, update: bool): """Print out update information.""" if internet: print("Checking updates from network") else: print("Not checking updates from internet") update_info = await dev.get_update_info(from_network=internet) if not update_in...
[ "async", "def", "check_update", "(", "dev", ":", "Device", ",", "internet", ":", "bool", ",", "update", ":", "bool", ")", ":", "if", "internet", ":", "print", "(", "\"Checking updates from network\"", ")", "else", ":", "print", "(", "\"Not checking updates fro...
Print out update information.
[ "Print", "out", "update", "information", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L401-L417
rytilahti/python-songpal
songpal/main.py
bluetooth
async def bluetooth(dev: Device, target, value): """Get or set bluetooth settings.""" if target and value: await dev.set_bluetooth_settings(target, value) print_settings(await dev.get_bluetooth_settings())
python
async def bluetooth(dev: Device, target, value): """Get or set bluetooth settings.""" if target and value: await dev.set_bluetooth_settings(target, value) print_settings(await dev.get_bluetooth_settings())
[ "async", "def", "bluetooth", "(", "dev", ":", "Device", ",", "target", ",", "value", ")", ":", "if", "target", "and", "value", ":", "await", "dev", ".", "set_bluetooth_settings", "(", "target", ",", "value", ")", "print_settings", "(", "await", "dev", "....
Get or set bluetooth settings.
[ "Get", "or", "set", "bluetooth", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L425-L430
rytilahti/python-songpal
songpal/main.py
sysinfo
async def sysinfo(dev: Device): """Print out system information (version, MAC addrs).""" click.echo(await dev.get_system_info()) click.echo(await dev.get_interface_information())
python
async def sysinfo(dev: Device): """Print out system information (version, MAC addrs).""" click.echo(await dev.get_system_info()) click.echo(await dev.get_interface_information())
[ "async", "def", "sysinfo", "(", "dev", ":", "Device", ")", ":", "click", ".", "echo", "(", "await", "dev", ".", "get_system_info", "(", ")", ")", "click", ".", "echo", "(", "await", "dev", ".", "get_interface_information", "(", ")", ")" ]
Print out system information (version, MAC addrs).
[ "Print", "out", "system", "information", "(", "version", "MAC", "addrs", ")", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L436-L439
rytilahti/python-songpal
songpal/main.py
settings
async def settings(dev: Device): """Print out all possible settings.""" settings_tree = await dev.get_settings() for module in settings_tree: await traverse_settings(dev, module.usage, module.settings)
python
async def settings(dev: Device): """Print out all possible settings.""" settings_tree = await dev.get_settings() for module in settings_tree: await traverse_settings(dev, module.usage, module.settings)
[ "async", "def", "settings", "(", "dev", ":", "Device", ")", ":", "settings_tree", "=", "await", "dev", ".", "get_settings", "(", ")", "for", "module", "in", "settings_tree", ":", "await", "traverse_settings", "(", "dev", ",", "module", ".", "usage", ",", ...
Print out all possible settings.
[ "Print", "out", "all", "possible", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L453-L458
rytilahti/python-songpal
songpal/main.py
storage
async def storage(dev: Device): """Print storage information.""" storages = await dev.get_storage_list() for storage in storages: click.echo(storage)
python
async def storage(dev: Device): """Print storage information.""" storages = await dev.get_storage_list() for storage in storages: click.echo(storage)
[ "async", "def", "storage", "(", "dev", ":", "Device", ")", ":", "storages", "=", "await", "dev", ".", "get_storage_list", "(", ")", "for", "storage", "in", "storages", ":", "click", ".", "echo", "(", "storage", ")" ]
Print storage information.
[ "Print", "storage", "information", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L464-L468
rytilahti/python-songpal
songpal/main.py
sound
async def sound(dev: Device, target, value): """Get or set sound settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) click.echo(await dev.set_sound_settings(target, value)) print_settings(await dev.get_sound_settings())
python
async def sound(dev: Device, target, value): """Get or set sound settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) click.echo(await dev.set_sound_settings(target, value)) print_settings(await dev.get_sound_settings())
[ "async", "def", "sound", "(", "dev", ":", "Device", ",", "target", ",", "value", ")", ":", "if", "target", "and", "value", ":", "click", ".", "echo", "(", "\"Setting %s to %s\"", "%", "(", "target", ",", "value", ")", ")", "click", ".", "echo", "(", ...
Get or set sound settings.
[ "Get", "or", "set", "sound", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L476-L482
rytilahti/python-songpal
songpal/main.py
soundfield
async def soundfield(dev: Device, soundfield: str): """Get or set sound field.""" if soundfield is not None: await dev.set_sound_settings("soundField", soundfield) soundfields = await dev.get_sound_settings("soundField") print_settings(soundfields)
python
async def soundfield(dev: Device, soundfield: str): """Get or set sound field.""" if soundfield is not None: await dev.set_sound_settings("soundField", soundfield) soundfields = await dev.get_sound_settings("soundField") print_settings(soundfields)
[ "async", "def", "soundfield", "(", "dev", ":", "Device", ",", "soundfield", ":", "str", ")", ":", "if", "soundfield", "is", "not", "None", ":", "await", "dev", ".", "set_sound_settings", "(", "\"soundField\"", ",", "soundfield", ")", "soundfields", "=", "a...
Get or set sound field.
[ "Get", "or", "set", "sound", "field", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L489-L494
rytilahti/python-songpal
songpal/main.py
playback
async def playback(dev: Device, cmd, target, value): """Get and set playback settings, e.g. repeat and shuffle..""" if target and value: dev.set_playback_settings(target, value) if cmd == "support": click.echo("Supported playback functions:") supported = await dev.get_supported_playb...
python
async def playback(dev: Device, cmd, target, value): """Get and set playback settings, e.g. repeat and shuffle..""" if target and value: dev.set_playback_settings(target, value) if cmd == "support": click.echo("Supported playback functions:") supported = await dev.get_supported_playb...
[ "async", "def", "playback", "(", "dev", ":", "Device", ",", "cmd", ",", "target", ",", "value", ")", ":", "if", "target", "and", "value", ":", "dev", ".", "set_playback_settings", "(", "target", ",", "value", ")", "if", "cmd", "==", "\"support\"", ":",...
Get and set playback settings, e.g. repeat and shuffle..
[ "Get", "and", "set", "playback", "settings", "e", ".", "g", ".", "repeat", "and", "shuffle", ".." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L511-L526
rytilahti/python-songpal
songpal/main.py
speaker
async def speaker(dev: Device, target, value): """Get and set external speaker settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) await dev.set_speaker_settings(target, value) print_settings(await dev.get_speaker_settings())
python
async def speaker(dev: Device, target, value): """Get and set external speaker settings.""" if target and value: click.echo("Setting %s to %s" % (target, value)) await dev.set_speaker_settings(target, value) print_settings(await dev.get_speaker_settings())
[ "async", "def", "speaker", "(", "dev", ":", "Device", ",", "target", ",", "value", ")", ":", "if", "target", "and", "value", ":", "click", ".", "echo", "(", "\"Setting %s to %s\"", "%", "(", "target", ",", "value", ")", ")", "await", "dev", ".", "set...
Get and set external speaker settings.
[ "Get", "and", "set", "external", "speaker", "settings", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L534-L540
rytilahti/python-songpal
songpal/main.py
notifications
async def notifications(dev: Device, notification: str, listen_all: bool): """List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are request...
python
async def notifications(dev: Device, notification: str, listen_all: bool): """List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are request...
[ "async", "def", "notifications", "(", "dev", ":", "Device", ",", "notification", ":", "str", ",", "listen_all", ":", "bool", ")", ":", "notifications", "=", "await", "dev", ".", "get_notifications", "(", ")", "async", "def", "handle_notification", "(", "x", ...
List available notifications and listen to them. Using --listen-all [notification] allows to listen to all notifications from the given subsystem. If the subsystem is omited, notifications from all subsystems are requested.
[ "List", "available", "notifications", "and", "listen", "to", "them", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L548-L581
rytilahti/python-songpal
songpal/main.py
list_all
def list_all(dev: Device): """List all available API calls.""" for name, service in dev.services.items(): click.echo(click.style("\nService %s" % name, bold=True)) for method in service.methods: click.echo(" %s" % method.name)
python
def list_all(dev: Device): """List all available API calls.""" for name, service in dev.services.items(): click.echo(click.style("\nService %s" % name, bold=True)) for method in service.methods: click.echo(" %s" % method.name)
[ "def", "list_all", "(", "dev", ":", "Device", ")", ":", "for", "name", ",", "service", "in", "dev", ".", "services", ".", "items", "(", ")", ":", "click", ".", "echo", "(", "click", ".", "style", "(", "\"\\nService %s\"", "%", "name", ",", "bold", ...
List all available API calls.
[ "List", "all", "available", "API", "calls", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L594-L599
rytilahti/python-songpal
songpal/main.py
command
async def command(dev, service, method, parameters): """Run a raw command.""" params = None if parameters is not None: params = ast.literal_eval(parameters) click.echo("Calling %s.%s with params %s" % (service, method, params)) res = await dev.raw_command(service, method, params) click.e...
python
async def command(dev, service, method, parameters): """Run a raw command.""" params = None if parameters is not None: params = ast.literal_eval(parameters) click.echo("Calling %s.%s with params %s" % (service, method, params)) res = await dev.raw_command(service, method, params) click.e...
[ "async", "def", "command", "(", "dev", ",", "service", ",", "method", ",", "parameters", ")", ":", "params", "=", "None", "if", "parameters", "is", "not", "None", ":", "params", "=", "ast", ".", "literal_eval", "(", "parameters", ")", "click", ".", "ec...
Run a raw command.
[ "Run", "a", "raw", "command", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L608-L615
rytilahti/python-songpal
songpal/main.py
dump_devinfo
async def dump_devinfo(dev: Device, file): """Dump developer information. Pass `file` to write the results directly into a file. """ import attr methods = await dev.get_supported_methods() res = { "supported_methods": {k: v.asdict() for k, v in methods.items()}, "settings": [at...
python
async def dump_devinfo(dev: Device, file): """Dump developer information. Pass `file` to write the results directly into a file. """ import attr methods = await dev.get_supported_methods() res = { "supported_methods": {k: v.asdict() for k, v in methods.items()}, "settings": [at...
[ "async", "def", "dump_devinfo", "(", "dev", ":", "Device", ",", "file", ")", ":", "import", "attr", "methods", "=", "await", "dev", ".", "get_supported_methods", "(", ")", "res", "=", "{", "\"supported_methods\"", ":", "{", "k", ":", "v", ".", "asdict", ...
Dump developer information. Pass `file` to write the results directly into a file.
[ "Dump", "developer", "information", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L622-L640
rytilahti/python-songpal
songpal/main.py
state
async def state(gc: GroupControl): """Current group state.""" state = await gc.state() click.echo(state) click.echo("Full state info: %s" % repr(state))
python
async def state(gc: GroupControl): """Current group state.""" state = await gc.state() click.echo(state) click.echo("Full state info: %s" % repr(state))
[ "async", "def", "state", "(", "gc", ":", "GroupControl", ")", ":", "state", "=", "await", "gc", ".", "state", "(", ")", "click", ".", "echo", "(", "state", ")", "click", ".", "echo", "(", "\"Full state info: %s\"", "%", "repr", "(", "state", ")", ")"...
Current group state.
[ "Current", "group", "state", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L667-L671
rytilahti/python-songpal
songpal/main.py
create
async def create(gc: GroupControl, name, slaves): """Create new group""" click.echo("Creating group %s with slaves: %s" % (name, slaves)) click.echo(await gc.create(name, slaves))
python
async def create(gc: GroupControl, name, slaves): """Create new group""" click.echo("Creating group %s with slaves: %s" % (name, slaves)) click.echo(await gc.create(name, slaves))
[ "async", "def", "create", "(", "gc", ":", "GroupControl", ",", "name", ",", "slaves", ")", ":", "click", ".", "echo", "(", "\"Creating group %s with slaves: %s\"", "%", "(", "name", ",", "slaves", ")", ")", "click", ".", "echo", "(", "await", "gc", ".", ...
Create new group
[ "Create", "new", "group" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L697-L700
rytilahti/python-songpal
songpal/main.py
add
async def add(gc: GroupControl, slaves): """Add speakers to group.""" click.echo("Adding to existing group: %s" % slaves) click.echo(await gc.add(slaves))
python
async def add(gc: GroupControl, slaves): """Add speakers to group.""" click.echo("Adding to existing group: %s" % slaves) click.echo(await gc.add(slaves))
[ "async", "def", "add", "(", "gc", ":", "GroupControl", ",", "slaves", ")", ":", "click", ".", "echo", "(", "\"Adding to existing group: %s\"", "%", "slaves", ")", "click", ".", "echo", "(", "await", "gc", ".", "add", "(", "slaves", ")", ")" ]
Add speakers to group.
[ "Add", "speakers", "to", "group", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L715-L718
rytilahti/python-songpal
songpal/main.py
remove
async def remove(gc: GroupControl, slaves): """Remove speakers from group.""" click.echo("Removing from existing group: %s" % slaves) click.echo(await gc.remove(slaves))
python
async def remove(gc: GroupControl, slaves): """Remove speakers from group.""" click.echo("Removing from existing group: %s" % slaves) click.echo(await gc.remove(slaves))
[ "async", "def", "remove", "(", "gc", ":", "GroupControl", ",", "slaves", ")", ":", "click", ".", "echo", "(", "\"Removing from existing group: %s\"", "%", "slaves", ")", "click", ".", "echo", "(", "await", "gc", ".", "remove", "(", "slaves", ")", ")" ]
Remove speakers from group.
[ "Remove", "speakers", "from", "group", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L724-L727
rytilahti/python-songpal
songpal/main.py
volume
async def volume(gc: GroupControl, volume): """Adjust volume [-100, 100]""" click.echo("Setting volume to %s" % volume) click.echo(await gc.set_group_volume(volume))
python
async def volume(gc: GroupControl, volume): """Adjust volume [-100, 100]""" click.echo("Setting volume to %s" % volume) click.echo(await gc.set_group_volume(volume))
[ "async", "def", "volume", "(", "gc", ":", "GroupControl", ",", "volume", ")", ":", "click", ".", "echo", "(", "\"Setting volume to %s\"", "%", "volume", ")", "click", ".", "echo", "(", "await", "gc", ".", "set_group_volume", "(", "volume", ")", ")" ]
Adjust volume [-100, 100]
[ "Adjust", "volume", "[", "-", "100", "100", "]" ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L733-L736
rytilahti/python-songpal
songpal/main.py
mute
async def mute(gc: GroupControl, mute): """(Un)mute group.""" click.echo("Muting group: %s" % mute) click.echo(await gc.set_mute(mute))
python
async def mute(gc: GroupControl, mute): """(Un)mute group.""" click.echo("Muting group: %s" % mute) click.echo(await gc.set_mute(mute))
[ "async", "def", "mute", "(", "gc", ":", "GroupControl", ",", "mute", ")", ":", "click", ".", "echo", "(", "\"Muting group: %s\"", "%", "mute", ")", "click", ".", "echo", "(", "await", "gc", ".", "set_mute", "(", "mute", ")", ")" ]
(Un)mute group.
[ "(", "Un", ")", "mute", "group", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/main.py#L742-L745
rytilahti/python-songpal
songpal/discovery.py
Discover.discover
async def discover(timeout, debug=0, callback=None): """Discover supported devices.""" ST = "urn:schemas-sony-com:service:ScalarWebAPI:1" _LOGGER.info("Discovering for %s seconds" % timeout) from async_upnp_client import UpnpFactory from async_upnp_client.aiohttp import AiohttpR...
python
async def discover(timeout, debug=0, callback=None): """Discover supported devices.""" ST = "urn:schemas-sony-com:service:ScalarWebAPI:1" _LOGGER.info("Discovering for %s seconds" % timeout) from async_upnp_client import UpnpFactory from async_upnp_client.aiohttp import AiohttpR...
[ "async", "def", "discover", "(", "timeout", ",", "debug", "=", "0", ",", "callback", "=", "None", ")", ":", "ST", "=", "\"urn:schemas-sony-com:service:ScalarWebAPI:1\"", "_LOGGER", ".", "info", "(", "\"Discovering for %s seconds\"", "%", "timeout", ")", "from", ...
Discover supported devices.
[ "Discover", "supported", "devices", "." ]
train
https://github.com/rytilahti/python-songpal/blob/0443de6b3d960b9067a851d82261ca00e46b4618/songpal/discovery.py#L21-L68
kanboard/python-api-client
kanboard/client.py
Kanboard.execute
def execute(self, method, **kwargs): """ Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.e...
python
def execute(self, method, **kwargs): """ Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.e...
[ "def", "execute", "(", "self", ",", "method", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'id'", ":", "1", ",", "'jsonrpc'", ":", "'2.0'", ",", "'method'", ":", "method", ",", "'params'", ":", "kwargs", "}", "credentials", "=", "base64",...
Call remote API procedure Args: method: Procedure name kwargs: Procedure named arguments Returns: Procedure result Raises: urllib2.HTTPError: Any HTTP error (Python 2) urllib.error.HTTPError: Any HTTP error (Python 3)
[ "Call", "remote", "API", "procedure" ]
train
https://github.com/kanboard/python-api-client/blob/a1e81094bb399a9a3f4f14de67406e1d2bbee393/kanboard/client.py#L106-L135
bwesterb/py-tarjan
src/tc.py
tc
def tc(g): """ Given a graph @g, returns the transitive closure of @g """ ret = {} for scc in tarjan(g): ws = set() ews = set() for v in scc: ws.update(g[v]) for w in ws: assert w in r...
python
def tc(g): """ Given a graph @g, returns the transitive closure of @g """ ret = {} for scc in tarjan(g): ws = set() ews = set() for v in scc: ws.update(g[v]) for w in ws: assert w in r...
[ "def", "tc", "(", "g", ")", ":", "ret", "=", "{", "}", "for", "scc", "in", "tarjan", "(", "g", ")", ":", "ws", "=", "set", "(", ")", "ews", "=", "set", "(", ")", "for", "v", "in", "scc", ":", "ws", ".", "update", "(", "g", "[", "v", "]"...
Given a graph @g, returns the transitive closure of @g
[ "Given", "a", "graph" ]
train
https://github.com/bwesterb/py-tarjan/blob/60b0e3a1a7b925514fdce2ffbd84e1e246aba6d8/src/tc.py#L3-L20
manolomartinez/greg
greg/classes.py
Session.list_feeds
def list_feeds(self): """ Output a list of all feed names """ feeds = configparser.ConfigParser() feeds.read(self.data_filename) return feeds.sections()
python
def list_feeds(self): """ Output a list of all feed names """ feeds = configparser.ConfigParser() feeds.read(self.data_filename) return feeds.sections()
[ "def", "list_feeds", "(", "self", ")", ":", "feeds", "=", "configparser", ".", "ConfigParser", "(", ")", "feeds", ".", "read", "(", "self", ".", "data_filename", ")", "return", "feeds", ".", "sections", "(", ")" ]
Output a list of all feed names
[ "Output", "a", "list", "of", "all", "feed", "names" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L52-L58
manolomartinez/greg
greg/classes.py
Session.retrieve_config_file
def retrieve_config_file(self): """ Retrieve config file """ try: if self.args["configfile"]: return self.args["configfile"] except KeyError: pass return os.path.expanduser('~/.config/greg/greg.conf')
python
def retrieve_config_file(self): """ Retrieve config file """ try: if self.args["configfile"]: return self.args["configfile"] except KeyError: pass return os.path.expanduser('~/.config/greg/greg.conf')
[ "def", "retrieve_config_file", "(", "self", ")", ":", "try", ":", "if", "self", ".", "args", "[", "\"configfile\"", "]", ":", "return", "self", ".", "args", "[", "\"configfile\"", "]", "except", "KeyError", ":", "pass", "return", "os", ".", "path", ".", ...
Retrieve config file
[ "Retrieve", "config", "file" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L60-L69
manolomartinez/greg
greg/classes.py
Session.retrieve_data_directory
def retrieve_data_directory(self): """ Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence. """ args = self.args try: if args['datadirectory']: aux.ensure_dir(a...
python
def retrieve_data_directory(self): """ Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence. """ args = self.args try: if args['datadirectory']: aux.ensure_dir(a...
[ "def", "retrieve_data_directory", "(", "self", ")", ":", "args", "=", "self", ".", "args", "try", ":", "if", "args", "[", "'datadirectory'", "]", ":", "aux", ".", "ensure_dir", "(", "args", "[", "'datadirectory'", "]", ")", "return", "args", "[", "'datad...
Retrieve the data directory Look first into config_filename_global then into config_filename_user. The latter takes preeminence.
[ "Retrieve", "the", "data", "directory", "Look", "first", "into", "config_filename_global", "then", "into", "config_filename_user", ".", "The", "latter", "takes", "preeminence", "." ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L71-L91
manolomartinez/greg
greg/classes.py
Feed.retrieve_config
def retrieve_config(self, value, default): """ Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides e...
python
def retrieve_config(self, value, default): """ Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides e...
[ "def", "retrieve_config", "(", "self", ",", "value", ",", "default", ")", ":", "args", "=", "self", ".", "args", "name", "=", "self", ".", "name", "try", ":", "if", "args", "[", "value", "]", ":", "return", "args", "[", "value", "]", "except", "Key...
Retrieves a value (with a certain fallback) from the config files (looks first into config_filename_global then into config_filename_user. The latest takes preeminence) if the command line flag for the value is used, that overrides everything else
[ "Retrieves", "a", "value", "(", "with", "a", "certain", "fallback", ")", "from", "the", "config", "files", "(", "looks", "first", "into", "config_filename_global", "then", "into", "config_filename_user", ".", "The", "latest", "takes", "preeminence", ")", "if", ...
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L119-L136
manolomartinez/greg
greg/classes.py
Feed.retrieve_download_path
def retrieve_download_path(self): """ Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence) """ section = self.name if self.config.has_section( ...
python
def retrieve_download_path(self): """ Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence) """ section = self.name if self.config.has_section( ...
[ "def", "retrieve_download_path", "(", "self", ")", ":", "section", "=", "self", ".", "name", "if", "self", ".", "config", ".", "has_section", "(", "self", ".", "name", ")", "else", "self", ".", "config", ".", "default_section", "download_path", "=", "self"...
Retrieves the download path (looks first into config_filename_global then into the [DEFAULT], then the [feed], section of config_filename_user. The latest takes preeminence)
[ "Retrieves", "the", "download", "path", "(", "looks", "first", "into", "config_filename_global", "then", "into", "the", "[", "DEFAULT", "]", "then", "the", "[", "feed", "]", "section", "of", "config_filename_user", ".", "The", "latest", "takes", "preeminence", ...
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L146-L158
manolomartinez/greg
greg/classes.py
Feed.will_tag
def will_tag(self): """ Check whether the feed should be tagged """ wanttags = self.retrieve_config('Tag', 'no') if wanttags == 'yes': if aux.staggerexists: willtag = True else: willtag = False print(("You wa...
python
def will_tag(self): """ Check whether the feed should be tagged """ wanttags = self.retrieve_config('Tag', 'no') if wanttags == 'yes': if aux.staggerexists: willtag = True else: willtag = False print(("You wa...
[ "def", "will_tag", "(", "self", ")", ":", "wanttags", "=", "self", ".", "retrieve_config", "(", "'Tag'", ",", "'no'", ")", "if", "wanttags", "==", "'yes'", ":", "if", "aux", ".", "staggerexists", ":", "willtag", "=", "True", "else", ":", "willtag", "="...
Check whether the feed should be tagged
[ "Check", "whether", "the", "feed", "should", "be", "tagged" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L202-L217
manolomartinez/greg
greg/classes.py
Feed.how_many
def how_many(self): """ Ascertain where to start downloading, and how many entries. """ if self.linkdates != []: # What follows is a quick sanity check: if the entry date is in the # future, this is probably a mistake, and we just count the entry # dat...
python
def how_many(self): """ Ascertain where to start downloading, and how many entries. """ if self.linkdates != []: # What follows is a quick sanity check: if the entry date is in the # future, this is probably a mistake, and we just count the entry # dat...
[ "def", "how_many", "(", "self", ")", ":", "if", "self", ".", "linkdates", "!=", "[", "]", ":", "# What follows is a quick sanity check: if the entry date is in the", "# future, this is probably a mistake, and we just count the entry", "# date as right now.", "if", "max", "(", ...
Ascertain where to start downloading, and how many entries.
[ "Ascertain", "where", "to", "start", "downloading", "and", "how", "many", "entries", "." ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L219-L243
manolomartinez/greg
greg/classes.py
Feed.fix_linkdate
def fix_linkdate(self, entry): """ Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate """ if self.sync_by_date: try: entry.linkdate = list(entry.published_parsed) self.linkdate = list(entry.published_pars...
python
def fix_linkdate(self, entry): """ Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate """ if self.sync_by_date: try: entry.linkdate = list(entry.published_parsed) self.linkdate = list(entry.published_pars...
[ "def", "fix_linkdate", "(", "self", ",", "entry", ")", ":", "if", "self", ".", "sync_by_date", ":", "try", ":", "entry", ".", "linkdate", "=", "list", "(", "entry", ".", "published_parsed", ")", "self", ".", "linkdate", "=", "list", "(", "entry", ".", ...
Give a date for the entry, depending on feed.sync_by_date Save it as feed.linkdate
[ "Give", "a", "date", "for", "the", "entry", "depending", "on", "feed", ".", "sync_by_date", "Save", "it", "as", "feed", ".", "linkdate" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L245-L265
manolomartinez/greg
greg/classes.py
Feed.retrieve_mime
def retrieve_mime(self): """ Check the mime-type to download """ mime = self.retrieve_config('mime', 'audio') mimedict = {"number": mime} # the input that parse_for_download expects return aux.parse_for_download(mimedict)
python
def retrieve_mime(self): """ Check the mime-type to download """ mime = self.retrieve_config('mime', 'audio') mimedict = {"number": mime} # the input that parse_for_download expects return aux.parse_for_download(mimedict)
[ "def", "retrieve_mime", "(", "self", ")", ":", "mime", "=", "self", ".", "retrieve_config", "(", "'mime'", ",", "'audio'", ")", "mimedict", "=", "{", "\"number\"", ":", "mime", "}", "# the input that parse_for_download expects", "return", "aux", ".", "parse_for_...
Check the mime-type to download
[ "Check", "the", "mime", "-", "type", "to", "download" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L267-L274
manolomartinez/greg
greg/classes.py
Feed.download_entry
def download_entry(self, entry): """ Find entry link and download entry """ downloadlinks = {} downloaded = False ignoreenclosures = self.retrieve_config('ignoreenclosures', 'no') notype = self.retrieve_config('notype', 'no') if ignoreenclosures == 'no': ...
python
def download_entry(self, entry): """ Find entry link and download entry """ downloadlinks = {} downloaded = False ignoreenclosures = self.retrieve_config('ignoreenclosures', 'no') notype = self.retrieve_config('notype', 'no') if ignoreenclosures == 'no': ...
[ "def", "download_entry", "(", "self", ",", "entry", ")", ":", "downloadlinks", "=", "{", "}", "downloaded", "=", "False", "ignoreenclosures", "=", "self", ".", "retrieve_config", "(", "'ignoreenclosures'", ",", "'no'", ")", "notype", "=", "self", ".", "retri...
Find entry link and download entry
[ "Find", "entry", "link", "and", "download", "entry" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L276-L345
manolomartinez/greg
greg/parser.py
main
def main(): """ Parse the args and call whatever function was selected """ args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
python
def main(): """ Parse the args and call whatever function was selected """ args = parser.parse_args() try: function = args.func except AttributeError: parser.print_usage() parser.exit(1) function(vars(args))
[ "def", "main", "(", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "try", ":", "function", "=", "args", ".", "func", "except", "AttributeError", ":", "parser", ".", "print_usage", "(", ")", "parser", ".", "exit", "(", "1", ")", "functi...
Parse the args and call whatever function was selected
[ "Parse", "the", "args", "and", "call", "whatever", "function", "was", "selected" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/parser.py#L128-L138
manolomartinez/greg
greg/commands.py
add
def add(args): """ Add a new feed """ session = c.Session(args) if args["name"] in session.feeds.sections(): sys.exit("You already have a feed with that name.") if args["name"] in ["all", "DEFAULT"]: sys.exit( ("greg uses ""{}"" for a special purpose." "P...
python
def add(args): """ Add a new feed """ session = c.Session(args) if args["name"] in session.feeds.sections(): sys.exit("You already have a feed with that name.") if args["name"] in ["all", "DEFAULT"]: sys.exit( ("greg uses ""{}"" for a special purpose." "P...
[ "def", "add", "(", "args", ")", ":", "session", "=", "c", ".", "Session", "(", "args", ")", "if", "args", "[", "\"name\"", "]", "in", "session", ".", "feeds", ".", "sections", "(", ")", ":", "sys", ".", "exit", "(", "\"You already have a feed with that...
Add a new feed
[ "Add", "a", "new", "feed" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L35-L52
manolomartinez/greg
greg/commands.py
remove
def remove(args): """ Remove the feed given in <args> """ session = c.Session(args) if not args["name"] in session.feeds: sys.exit("You don't have a feed with that name.") inputtext = ("Are you sure you want to remove the {} " " feed? (y/N) ").format(args["name"]) re...
python
def remove(args): """ Remove the feed given in <args> """ session = c.Session(args) if not args["name"] in session.feeds: sys.exit("You don't have a feed with that name.") inputtext = ("Are you sure you want to remove the {} " " feed? (y/N) ").format(args["name"]) re...
[ "def", "remove", "(", "args", ")", ":", "session", "=", "c", ".", "Session", "(", "args", ")", "if", "not", "args", "[", "\"name\"", "]", "in", "session", ".", "feeds", ":", "sys", ".", "exit", "(", "\"You don't have a feed with that name.\"", ")", "inpu...
Remove the feed given in <args>
[ "Remove", "the", "feed", "given", "in", "<args", ">" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L98-L117
manolomartinez/greg
greg/commands.py
info
def info(args): """ Provide information of a number of feeds """ session = c.Session(args) if "all" in args["names"]: feeds = session.list_feeds() else: feeds = args["names"] for feed in feeds: aux.pretty_print(session, feed)
python
def info(args): """ Provide information of a number of feeds """ session = c.Session(args) if "all" in args["names"]: feeds = session.list_feeds() else: feeds = args["names"] for feed in feeds: aux.pretty_print(session, feed)
[ "def", "info", "(", "args", ")", ":", "session", "=", "c", ".", "Session", "(", "args", ")", "if", "\"all\"", "in", "args", "[", "\"names\"", "]", ":", "feeds", "=", "session", ".", "list_feeds", "(", ")", "else", ":", "feeds", "=", "args", "[", ...
Provide information of a number of feeds
[ "Provide", "information", "of", "a", "number", "of", "feeds" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L120-L130
manolomartinez/greg
greg/commands.py
sync
def sync(args): """ Implement the 'greg sync' command """ import operator session = c.Session(args) if "all" in args["names"]: targetfeeds = session.list_feeds() else: targetfeeds = [] for name in args["names"]: if name not in session.feeds: ...
python
def sync(args): """ Implement the 'greg sync' command """ import operator session = c.Session(args) if "all" in args["names"]: targetfeeds = session.list_feeds() else: targetfeeds = [] for name in args["names"]: if name not in session.feeds: ...
[ "def", "sync", "(", "args", ")", ":", "import", "operator", "session", "=", "c", ".", "Session", "(", "args", ")", "if", "\"all\"", "in", "args", "[", "\"names\"", "]", ":", "targetfeeds", "=", "session", ".", "list_feeds", "(", ")", "else", ":", "ta...
Implement the 'greg sync' command
[ "Implement", "the", "greg", "sync", "command" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L140-L184
manolomartinez/greg
greg/commands.py
check
def check(args): """ Implement the 'greg check' command """ session = c.Session(args) if str(args["url"]) != 'None': url = args["url"] name = "DEFAULT" else: try: url = session.feeds[args["feed"]]["url"] name = args["feed"] except KeyError:...
python
def check(args): """ Implement the 'greg check' command """ session = c.Session(args) if str(args["url"]) != 'None': url = args["url"] name = "DEFAULT" else: try: url = session.feeds[args["feed"]]["url"] name = args["feed"] except KeyError:...
[ "def", "check", "(", "args", ")", ":", "session", "=", "c", ".", "Session", "(", "args", ")", "if", "str", "(", "args", "[", "\"url\"", "]", ")", "!=", "'None'", ":", "url", "=", "args", "[", "\"url\"", "]", "name", "=", "\"DEFAULT\"", "else", ":...
Implement the 'greg check' command
[ "Implement", "the", "greg", "check", "command" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L187-L217
manolomartinez/greg
greg/commands.py
download
def download(args): """ Implement the 'greg download' command """ session = c.Session(args) issues = aux.parse_for_download(args) if issues == ['']: sys.exit( "You need to give a list of issues, of the form ""a, b-c, d...""") dumpfilename = os.path.join(session.data_dir, ...
python
def download(args): """ Implement the 'greg download' command """ session = c.Session(args) issues = aux.parse_for_download(args) if issues == ['']: sys.exit( "You need to give a list of issues, of the form ""a, b-c, d...""") dumpfilename = os.path.join(session.data_dir, ...
[ "def", "download", "(", "args", ")", ":", "session", "=", "c", ".", "Session", "(", "args", ")", "issues", "=", "aux", ".", "parse_for_download", "(", "args", ")", "if", "issues", "==", "[", "''", "]", ":", "sys", ".", "exit", "(", "\"You need to giv...
Implement the 'greg download' command
[ "Implement", "the", "greg", "download", "command" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/commands.py#L220-L247
manolomartinez/greg
greg/aux_functions.py
parse_podcast
def parse_podcast(url): """ Try to parse podcast """ try: podcast = feedparser.parse(url) wentwrong = "urlopen" in str(podcast["bozo_exception"]) except KeyError: wentwrong = False if wentwrong: print("Error: ", url, ": ", str(podcast["bozo_exception"])) retur...
python
def parse_podcast(url): """ Try to parse podcast """ try: podcast = feedparser.parse(url) wentwrong = "urlopen" in str(podcast["bozo_exception"]) except KeyError: wentwrong = False if wentwrong: print("Error: ", url, ": ", str(podcast["bozo_exception"])) retur...
[ "def", "parse_podcast", "(", "url", ")", ":", "try", ":", "podcast", "=", "feedparser", ".", "parse", "(", "url", ")", "wentwrong", "=", "\"urlopen\"", "in", "str", "(", "podcast", "[", "\"bozo_exception\"", "]", ")", "except", "KeyError", ":", "wentwrong"...
Try to parse podcast
[ "Try", "to", "parse", "podcast" ]
train
https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/aux_functions.py#L93-L104