repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.search_location_check
def search_location_check(cls, location): """Core.Client.request_search location parameter should be a dictionary that contains lat, lon and radius floats """ if not (isinstance(location, Mapping) and set(location.keys()) == _LOCATION_SEARCH_ARGS): raise ValueError('Search location should be mapping with keys: %s' % _LOCATION_SEARCH_ARGS) cls.location_check(location['lat'], location['long']) radius = location['radius'] if not (isinstance(radius, number_types) and 0 < radius <= 20038): # half circumference raise ValueError("Radius: '{radius}' is invalid".format(radius=radius))
python
def search_location_check(cls, location): """Core.Client.request_search location parameter should be a dictionary that contains lat, lon and radius floats """ if not (isinstance(location, Mapping) and set(location.keys()) == _LOCATION_SEARCH_ARGS): raise ValueError('Search location should be mapping with keys: %s' % _LOCATION_SEARCH_ARGS) cls.location_check(location['lat'], location['long']) radius = location['radius'] if not (isinstance(radius, number_types) and 0 < radius <= 20038): # half circumference raise ValueError("Radius: '{radius}' is invalid".format(radius=radius))
[ "def", "search_location_check", "(", "cls", ",", "location", ")", ":", "if", "not", "(", "isinstance", "(", "location", ",", "Mapping", ")", "and", "set", "(", "location", ".", "keys", "(", ")", ")", "==", "_LOCATION_SEARCH_ARGS", ")", ":", "raise", "Val...
Core.Client.request_search location parameter should be a dictionary that contains lat, lon and radius floats
[ "Core", ".", "Client", ".", "request_search", "location", "parameter", "should", "be", "a", "dictionary", "that", "contains", "lat", "lon", "and", "radius", "floats" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L248-L257
train
38,200
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.__search_text_check_convert
def __search_text_check_convert(cls, text): """Converts and keeps only words in text deemed to be valid""" text = cls.check_convert_string(text, name='text', no_leading_trailing_whitespace=False) if len(text) > VALIDATION_META_SEARCH_TEXT: raise ValueError("Search text can contain at most %d characters" % VALIDATION_META_SEARCH_TEXT) text = ' '.join(_PATTERN_WORDS.findall(text)) if not text: raise ValueError('Search text must contain at least one non-whitespace term (word)') return text
python
def __search_text_check_convert(cls, text): """Converts and keeps only words in text deemed to be valid""" text = cls.check_convert_string(text, name='text', no_leading_trailing_whitespace=False) if len(text) > VALIDATION_META_SEARCH_TEXT: raise ValueError("Search text can contain at most %d characters" % VALIDATION_META_SEARCH_TEXT) text = ' '.join(_PATTERN_WORDS.findall(text)) if not text: raise ValueError('Search text must contain at least one non-whitespace term (word)') return text
[ "def", "__search_text_check_convert", "(", "cls", ",", "text", ")", ":", "text", "=", "cls", ".", "check_convert_string", "(", "text", ",", "name", "=", "'text'", ",", "no_leading_trailing_whitespace", "=", "False", ")", "if", "len", "(", "text", ")", ">", ...
Converts and keeps only words in text deemed to be valid
[ "Converts", "and", "keeps", "only", "words", "in", "text", "deemed", "to", "be", "valid" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L298-L306
train
38,201
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/Validation.py
Validation.callable_check
def callable_check(func, arg_count=1, arg_value=None, allow_none=False): """Check whether func is callable, with the given number of positional arguments. Returns True if check succeeded, False otherwise.""" if func is None: if not allow_none: raise ValueError('callable cannot be None') elif not arg_checker(func, *[arg_value for _ in range(arg_count)]): raise ValueError('callable %s invalid (for %d arguments)' % (func, arg_count))
python
def callable_check(func, arg_count=1, arg_value=None, allow_none=False): """Check whether func is callable, with the given number of positional arguments. Returns True if check succeeded, False otherwise.""" if func is None: if not allow_none: raise ValueError('callable cannot be None') elif not arg_checker(func, *[arg_value for _ in range(arg_count)]): raise ValueError('callable %s invalid (for %d arguments)' % (func, arg_count))
[ "def", "callable_check", "(", "func", ",", "arg_count", "=", "1", ",", "arg_value", "=", "None", ",", "allow_none", "=", "False", ")", ":", "if", "func", "is", "None", ":", "if", "not", "allow_none", ":", "raise", "ValueError", "(", "'callable cannot be No...
Check whether func is callable, with the given number of positional arguments. Returns True if check succeeded, False otherwise.
[ "Check", "whether", "func", "is", "callable", "with", "the", "given", "number", "of", "positional", "arguments", ".", "Returns", "True", "if", "check", "succeeded", "False", "otherwise", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/Validation.py#L309-L316
train
38,202
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.list_feeds
def list_feeds(self, limit=500, offset=0): """List `all` the feeds on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset """ return self.__list(R_FEED, limit=limit, offset=offset)['feeds']
python
def list_feeds(self, limit=500, offset=0): """List `all` the feeds on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset """ return self.__list(R_FEED, limit=limit, offset=offset)['feeds']
[ "def", "list_feeds", "(", "self", ",", "limit", "=", "500", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "__list", "(", "R_FEED", ",", "limit", "=", "limit", ",", "offset", "=", "offset", ")", "[", "'feeds'", "]" ]
List `all` the feeds on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset
[ "List", "all", "the", "feeds", "on", "this", "Thing", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L93-L108
train
38,203
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.list_controls
def list_controls(self, limit=500, offset=0): """List `all` the controls on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset """ return self.__list(R_CONTROL, limit=limit, offset=offset)['controls']
python
def list_controls(self, limit=500, offset=0): """List `all` the controls on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset """ return self.__list(R_CONTROL, limit=limit, offset=offset)['controls']
[ "def", "list_controls", "(", "self", ",", "limit", "=", "500", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "__list", "(", "R_CONTROL", ",", "limit", "=", "limit", ",", "offset", "=", "offset", ")", "[", "'controls'", "]" ]
List `all` the controls on this Thing. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many Point details `offset` (optional) (integer) Return Point details starting at this offset
[ "List", "all", "the", "controls", "on", "this", "Thing", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L110-L125
train
38,204
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.set_public
def set_public(self, public=True): """Sets your Thing to be public to all. If `public=True`. This means the tags, label and description of your Thing are now searchable by anybody, along with its location and the units of any values on any Points. If `public=False` the metadata of your Thing is no longer searchable. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `public` (optional) (boolean) Whether (or not) to allow your Thing's metadata to be searched by anybody """ logger.info("set_public(public=%s) [lid=%s]", public, self.__lid) evt = self._client._request_entity_meta_setpublic(self.__lid, public) self._client._wait_and_except_if_failed(evt)
python
def set_public(self, public=True): """Sets your Thing to be public to all. If `public=True`. This means the tags, label and description of your Thing are now searchable by anybody, along with its location and the units of any values on any Points. If `public=False` the metadata of your Thing is no longer searchable. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `public` (optional) (boolean) Whether (or not) to allow your Thing's metadata to be searched by anybody """ logger.info("set_public(public=%s) [lid=%s]", public, self.__lid) evt = self._client._request_entity_meta_setpublic(self.__lid, public) self._client._wait_and_except_if_failed(evt)
[ "def", "set_public", "(", "self", ",", "public", "=", "True", ")", ":", "logger", ".", "info", "(", "\"set_public(public=%s) [lid=%s]\"", ",", "public", ",", "self", ".", "__lid", ")", "evt", "=", "self", ".", "_client", ".", "_request_entity_meta_setpublic", ...
Sets your Thing to be public to all. If `public=True`. This means the tags, label and description of your Thing are now searchable by anybody, along with its location and the units of any values on any Points. If `public=False` the metadata of your Thing is no longer searchable. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `public` (optional) (boolean) Whether (or not) to allow your Thing's metadata to be searched by anybody
[ "Sets", "your", "Thing", "to", "be", "public", "to", "all", ".", "If", "public", "=", "True", ".", "This", "means", "the", "tags", "label", "and", "description", "of", "your", "Thing", "are", "now", "searchable", "by", "anybody", "along", "with", "its", ...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L127-L144
train
38,205
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.rename
def rename(self, new_lid): """Rename the Thing. `ADVANCED USERS ONLY` This can be confusing. You are changing the local id of a Thing to `new_lid`. If you create another Thing using the "old_lid", the system will oblige, but it will be a completely _new_ Thing. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_lid` (required) (string) the new local identifier of your Thing """ logger.info("rename(new_lid=\"%s\") [lid=%s]", new_lid, self.__lid) evt = self._client._request_entity_rename(self.__lid, new_lid) self._client._wait_and_except_if_failed(evt) self.__lid = new_lid self._client._notify_thing_lid_change(self.__lid, new_lid)
python
def rename(self, new_lid): """Rename the Thing. `ADVANCED USERS ONLY` This can be confusing. You are changing the local id of a Thing to `new_lid`. If you create another Thing using the "old_lid", the system will oblige, but it will be a completely _new_ Thing. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_lid` (required) (string) the new local identifier of your Thing """ logger.info("rename(new_lid=\"%s\") [lid=%s]", new_lid, self.__lid) evt = self._client._request_entity_rename(self.__lid, new_lid) self._client._wait_and_except_if_failed(evt) self.__lid = new_lid self._client._notify_thing_lid_change(self.__lid, new_lid)
[ "def", "rename", "(", "self", ",", "new_lid", ")", ":", "logger", ".", "info", "(", "\"rename(new_lid=\\\"%s\\\") [lid=%s]\"", ",", "new_lid", ",", "self", ".", "__lid", ")", "evt", "=", "self", ".", "_client", ".", "_request_entity_rename", "(", "self", "."...
Rename the Thing. `ADVANCED USERS ONLY` This can be confusing. You are changing the local id of a Thing to `new_lid`. If you create another Thing using the "old_lid", the system will oblige, but it will be a completely _new_ Thing. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_lid` (required) (string) the new local identifier of your Thing
[ "Rename", "the", "Thing", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L146-L164
train
38,206
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.reassign
def reassign(self, new_epid): """Reassign the Thing from one agent to another. `ADVANCED USERS ONLY` This will lead to any local instances of a Thing being rendered useless. They won't be able to receive control requests, feed data or to share any feeds as they won't be in this agent. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_epid` (required) (string) the new agent id to which your Thing should be assigned. If None, current agent will be chosen. If False, existing agent will be unassigned. """ logger.info("reassign(new_epid=\"%s\") [lid=%s]", new_epid, self.__lid) evt = self._client._request_entity_reassign(self.__lid, new_epid) self._client._wait_and_except_if_failed(evt)
python
def reassign(self, new_epid): """Reassign the Thing from one agent to another. `ADVANCED USERS ONLY` This will lead to any local instances of a Thing being rendered useless. They won't be able to receive control requests, feed data or to share any feeds as they won't be in this agent. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_epid` (required) (string) the new agent id to which your Thing should be assigned. If None, current agent will be chosen. If False, existing agent will be unassigned. """ logger.info("reassign(new_epid=\"%s\") [lid=%s]", new_epid, self.__lid) evt = self._client._request_entity_reassign(self.__lid, new_epid) self._client._wait_and_except_if_failed(evt)
[ "def", "reassign", "(", "self", ",", "new_epid", ")", ":", "logger", ".", "info", "(", "\"reassign(new_epid=\\\"%s\\\") [lid=%s]\"", ",", "new_epid", ",", "self", ".", "__lid", ")", "evt", "=", "self", ".", "_client", ".", "_request_entity_reassign", "(", "sel...
Reassign the Thing from one agent to another. `ADVANCED USERS ONLY` This will lead to any local instances of a Thing being rendered useless. They won't be able to receive control requests, feed data or to share any feeds as they won't be in this agent. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_epid` (required) (string) the new agent id to which your Thing should be assigned. If None, current agent will be chosen. If False, existing agent will be unassigned.
[ "Reassign", "the", "Thing", "from", "one", "agent", "to", "another", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L166-L183
train
38,207
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.delete_tag
def delete_tag(self, tags): """Delete tags for a Thing in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Thing, e.g. `["garden", "soil"]` """ if isinstance(tags, str): tags = [tags] evt = self._client._request_entity_tag_update(self.__lid, tags, delete=True) self._client._wait_and_except_if_failed(evt)
python
def delete_tag(self, tags): """Delete tags for a Thing in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Thing, e.g. `["garden", "soil"]` """ if isinstance(tags, str): tags = [tags] evt = self._client._request_entity_tag_update(self.__lid, tags, delete=True) self._client._wait_and_except_if_failed(evt)
[ "def", "delete_tag", "(", "self", ",", "tags", ")", ":", "if", "isinstance", "(", "tags", ",", "str", ")", ":", "tags", "=", "[", "tags", "]", "evt", "=", "self", ".", "_client", ".", "_request_entity_tag_update", "(", "self", ".", "__lid", ",", "tag...
Delete tags for a Thing in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Thing, e.g. `["garden", "soil"]`
[ "Delete", "tags", "for", "a", "Thing", "in", "the", "language", "you", "specify", ".", "Case", "will", "be", "ignored", "and", "any", "tags", "matching", "lower", "-", "cased", "will", "be", "deleted", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L204-L221
train
38,208
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.list_tag
def list_tag(self, limit=500, offset=0): """List `all` the tags for this Thing Returns lists of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset """ evt = self._client._request_entity_tag_list(self.__lid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['tags']
python
def list_tag(self, limit=500, offset=0): """List `all` the tags for this Thing Returns lists of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset """ evt = self._client._request_entity_tag_list(self.__lid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['tags']
[ "def", "list_tag", "(", "self", ",", "limit", "=", "500", ",", "offset", "=", "0", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_entity_tag_list", "(", "self", ".", "__lid", ",", "limit", "=", "limit", ",", "offset", "=", "offset", ")"...
List `all` the tags for this Thing Returns lists of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset
[ "List", "all", "the", "tags", "for", "this", "Thing" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L223-L251
train
38,209
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.get_meta
def get_meta(self): """Get the metadata object for this Thing Returns a [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) object """ rdf = self.get_meta_rdf(fmt='n3') return ThingMeta(self, rdf, self._client.default_lang, fmt='n3')
python
def get_meta(self): """Get the metadata object for this Thing Returns a [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) object """ rdf = self.get_meta_rdf(fmt='n3') return ThingMeta(self, rdf, self._client.default_lang, fmt='n3')
[ "def", "get_meta", "(", "self", ")", ":", "rdf", "=", "self", ".", "get_meta_rdf", "(", "fmt", "=", "'n3'", ")", "return", "ThingMeta", "(", "self", ",", "rdf", ",", "self", ".", "_client", ".", "default_lang", ",", "fmt", "=", "'n3'", ")" ]
Get the metadata object for this Thing Returns a [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) object
[ "Get", "the", "metadata", "object", "for", "this", "Thing" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L253-L259
train
38,210
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.get_meta_rdf
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Thing in rdf fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_entity_meta_get(self.__lid, fmt=fmt) self._client._wait_and_except_if_failed(evt) return evt.payload['meta']
python
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Thing in rdf fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_entity_meta_get(self.__lid, fmt=fmt) self._client._wait_and_except_if_failed(evt) return evt.payload['meta']
[ "def", "get_meta_rdf", "(", "self", ",", "fmt", "=", "'n3'", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_entity_meta_get", "(", "self", ".", "__lid", ",", "fmt", "=", "fmt", ")", "self", ".", "_client", ".", "_wait_and_except_if_failed", ...
Get the metadata for this Thing in rdf fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle"
[ "Get", "the", "metadata", "for", "this", "Thing", "in", "rdf", "fmt" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L261-L281
train
38,211
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.set_meta_rdf
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you have sent. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_entity_meta_set(self.__lid, rdf, fmt=fmt) self._client._wait_and_except_if_failed(evt)
python
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you have sent. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_entity_meta_set(self.__lid, rdf, fmt=fmt) self._client._wait_and_except_if_failed(evt)
[ "def", "set_meta_rdf", "(", "self", ",", "rdf", ",", "fmt", "=", "'n3'", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_entity_meta_set", "(", "self", ".", "__lid", ",", "rdf", ",", "fmt", "=", "fmt", ")", "self", ".", "_client", ".", ...
Set the metadata for this Thing in RDF fmt Advanced users who want to manipulate the RDF for this Thing directly without the [ThingMeta](ThingMeta.m.html#IoticAgent.IOT.ThingMeta.ThingMeta) helper object Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you have sent. Valid formats are: "xml", "n3", "turtle"
[ "Set", "the", "metadata", "for", "this", "Thing", "in", "RDF", "fmt" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L283-L299
train
38,212
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.get_feed
def get_feed(self, pid): """Get the details of a newly created feed. This only applies to asynchronous creation of feeds and the new feed instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_feed once, any further calls will raise a `KeyError` Returns a [Feed](Point.m.html#IoticAgent.IOT.Point.Feed) object, which corresponds to the cached entry for this local feed id `pid` (required) (string) Point id - local identifier of your feed. Raises `KeyError` if the feed has not been newly created (or has already been retrieved by a previous call) """ with self.__new_feeds: try: return self.__new_feeds.pop(pid) except KeyError as ex: raise_from(KeyError('Feed %s not know as new' % pid), ex)
python
def get_feed(self, pid): """Get the details of a newly created feed. This only applies to asynchronous creation of feeds and the new feed instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_feed once, any further calls will raise a `KeyError` Returns a [Feed](Point.m.html#IoticAgent.IOT.Point.Feed) object, which corresponds to the cached entry for this local feed id `pid` (required) (string) Point id - local identifier of your feed. Raises `KeyError` if the feed has not been newly created (or has already been retrieved by a previous call) """ with self.__new_feeds: try: return self.__new_feeds.pop(pid) except KeyError as ex: raise_from(KeyError('Feed %s not know as new' % pid), ex)
[ "def", "get_feed", "(", "self", ",", "pid", ")", ":", "with", "self", ".", "__new_feeds", ":", "try", ":", "return", "self", ".", "__new_feeds", ".", "pop", "(", "pid", ")", "except", "KeyError", "as", "ex", ":", "raise_from", "(", "KeyError", "(", "...
Get the details of a newly created feed. This only applies to asynchronous creation of feeds and the new feed instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_feed once, any further calls will raise a `KeyError` Returns a [Feed](Point.m.html#IoticAgent.IOT.Point.Feed) object, which corresponds to the cached entry for this local feed id `pid` (required) (string) Point id - local identifier of your feed. Raises `KeyError` if the feed has not been newly created (or has already been retrieved by a previous call)
[ "Get", "the", "details", "of", "a", "newly", "created", "feed", ".", "This", "only", "applies", "to", "asynchronous", "creation", "of", "feeds", "and", "the", "new", "feed", "instance", "can", "only", "be", "retrieved", "once", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L301-L318
train
38,213
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.get_control
def get_control(self, pid): """Get the details of a newly created control. This only applies to asynchronous creation of feeds and the new control instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_control once, any further calls will raise a `KeyError` Returns a [Control](Point.m.html#IoticAgent.IOT.Point.Control) object, which corresponds to the cached entry for this local control id `pid` (required) (string) local identifier of your control. Raises `KeyError` if the control has not been newly created (or has already been retrieved by a previous call) """ with self.__new_controls: try: return self.__new_controls.pop(pid) except KeyError as ex: raise_from(KeyError('Control %s not know as new' % pid), ex)
python
def get_control(self, pid): """Get the details of a newly created control. This only applies to asynchronous creation of feeds and the new control instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_control once, any further calls will raise a `KeyError` Returns a [Control](Point.m.html#IoticAgent.IOT.Point.Control) object, which corresponds to the cached entry for this local control id `pid` (required) (string) local identifier of your control. Raises `KeyError` if the control has not been newly created (or has already been retrieved by a previous call) """ with self.__new_controls: try: return self.__new_controls.pop(pid) except KeyError as ex: raise_from(KeyError('Control %s not know as new' % pid), ex)
[ "def", "get_control", "(", "self", ",", "pid", ")", ":", "with", "self", ".", "__new_controls", ":", "try", ":", "return", "self", ".", "__new_controls", ".", "pop", "(", "pid", ")", "except", "KeyError", "as", "ex", ":", "raise_from", "(", "KeyError", ...
Get the details of a newly created control. This only applies to asynchronous creation of feeds and the new control instance can only be retrieved once. `NOTE` - Destructive Read. Once you've called get_control once, any further calls will raise a `KeyError` Returns a [Control](Point.m.html#IoticAgent.IOT.Point.Control) object, which corresponds to the cached entry for this local control id `pid` (required) (string) local identifier of your control. Raises `KeyError` if the control has not been newly created (or has already been retrieved by a previous call)
[ "Get", "the", "details", "of", "a", "newly", "created", "control", ".", "This", "only", "applies", "to", "asynchronous", "creation", "of", "feeds", "and", "the", "new", "control", "instance", "can", "only", "be", "retrieved", "once", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L320-L337
train
38,214
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.delete_feed
def delete_feed(self, pid): """Delete a feed, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your feed you want to delete """ logger.info("delete_feed(pid=\"%s\") [lid=%s]", pid, self.__lid) return self.__delete_point(R_FEED, pid)
python
def delete_feed(self, pid): """Delete a feed, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your feed you want to delete """ logger.info("delete_feed(pid=\"%s\") [lid=%s]", pid, self.__lid) return self.__delete_point(R_FEED, pid)
[ "def", "delete_feed", "(", "self", ",", "pid", ")", ":", "logger", ".", "info", "(", "\"delete_feed(pid=\\\"%s\\\") [lid=%s]\"", ",", "pid", ",", "self", ".", "__lid", ")", "return", "self", ".", "__delete_point", "(", "R_FEED", ",", "pid", ")" ]
Delete a feed, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your feed you want to delete
[ "Delete", "a", "feed", "identified", "by", "its", "local", "id", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L432-L445
train
38,215
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.delete_control
def delete_control(self, pid): """Delete a control, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your control you want to delete """ logger.info("delete_control(pid=\"%s\") [lid=%s]", pid, self.__lid) return self.__delete_point(R_CONTROL, pid)
python
def delete_control(self, pid): """Delete a control, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your control you want to delete """ logger.info("delete_control(pid=\"%s\") [lid=%s]", pid, self.__lid) return self.__delete_point(R_CONTROL, pid)
[ "def", "delete_control", "(", "self", ",", "pid", ")", ":", "logger", ".", "info", "(", "\"delete_control(pid=\\\"%s\\\") [lid=%s]\"", ",", "pid", ",", "self", ".", "__lid", ")", "return", "self", ".", "__delete_point", "(", "R_CONTROL", ",", "pid", ")" ]
Delete a control, identified by its local id. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `pid` (required) (string) local identifier of your control you want to delete
[ "Delete", "a", "control", "identified", "by", "its", "local", "id", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L451-L463
train
38,216
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.__sub_del_reference
def __sub_del_reference(self, req, key): """Blindly clear reference to pending subscription on failure.""" if not req.success: try: self.__new_subs.pop(key) except KeyError: logger.warning('No sub ref %s', key)
python
def __sub_del_reference(self, req, key): """Blindly clear reference to pending subscription on failure.""" if not req.success: try: self.__new_subs.pop(key) except KeyError: logger.warning('No sub ref %s', key)
[ "def", "__sub_del_reference", "(", "self", ",", "req", ",", "key", ")", ":", "if", "not", "req", ".", "success", ":", "try", ":", "self", ".", "__new_subs", ".", "pop", "(", "key", ")", "except", "KeyError", ":", "logger", ".", "warning", "(", "'No s...
Blindly clear reference to pending subscription on failure.
[ "Blindly", "clear", "reference", "to", "pending", "subscription", "on", "failure", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L530-L536
train
38,217
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
Thing.list_connections
def list_connections(self, limit=500, offset=0): """List Points to which this Things is subscribed. I.e. list all the Points this Thing is following and controls it's attached to Returns subscription list e.g. #!python { "<Subscription GUID 1>": { "id": "<Control GUID>", "entityId": "<Control's Thing GUID>", "type": 3 # R_CONTROL from IoticAgent.Core.Const }, "<Subscription GUID 2>": { "id": "<Feed GUID>", "entityId": "<Feed's Thing GUID>", "type": 2 # R_FEED from IoticAgent.Core.Const } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure Note: For Things following a Point see [list_followers](./Point.m.html#IoticAgent.IOT.Point.Point.list_followers) """ evt = self._client._request_sub_list(self.__lid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['subs']
python
def list_connections(self, limit=500, offset=0): """List Points to which this Things is subscribed. I.e. list all the Points this Thing is following and controls it's attached to Returns subscription list e.g. #!python { "<Subscription GUID 1>": { "id": "<Control GUID>", "entityId": "<Control's Thing GUID>", "type": 3 # R_CONTROL from IoticAgent.Core.Const }, "<Subscription GUID 2>": { "id": "<Feed GUID>", "entityId": "<Feed's Thing GUID>", "type": 2 # R_FEED from IoticAgent.Core.Const } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure Note: For Things following a Point see [list_followers](./Point.m.html#IoticAgent.IOT.Point.Point.list_followers) """ evt = self._client._request_sub_list(self.__lid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['subs']
[ "def", "list_connections", "(", "self", ",", "limit", "=", "500", ",", "offset", "=", "0", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_sub_list", "(", "self", ".", "__lid", ",", "limit", "=", "limit", ",", "offset", "=", "offset", ")...
List Points to which this Things is subscribed. I.e. list all the Points this Thing is following and controls it's attached to Returns subscription list e.g. #!python { "<Subscription GUID 1>": { "id": "<Control GUID>", "entityId": "<Control's Thing GUID>", "type": 3 # R_CONTROL from IoticAgent.Core.Const }, "<Subscription GUID 2>": { "id": "<Feed GUID>", "entityId": "<Feed's Thing GUID>", "type": 2 # R_FEED from IoticAgent.Core.Const } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure Note: For Things following a Point see [list_followers](./Point.m.html#IoticAgent.IOT.Point.Point.list_followers)
[ "List", "Points", "to", "which", "this", "Things", "is", "subscribed", ".", "I", ".", "e", ".", "list", "all", "the", "Points", "this", "Thing", "is", "following", "and", "controls", "it", "s", "attached", "to" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L671-L702
train
38,218
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/RemotePoint.py
RemoteFeed.get_recent_async
def get_recent_async(self, count, callback): """Similar to `get_recent` except instead of returning an iterable, passes each dict to the given function which must accept a single argument. Returns the request. `callback` (mandatory) (function) instead of returning an iterable, pass each dict (as described above) to the given function which must accept a single argument. Nothing is returned. """ validate_nonnegative_int(count, 'count') Validation.callable_check(callback, allow_none=True) evt = self._client._request_sub_recent(self.subid, count=count) self._client._add_recent_cb_for(evt, callback) return evt
python
def get_recent_async(self, count, callback): """Similar to `get_recent` except instead of returning an iterable, passes each dict to the given function which must accept a single argument. Returns the request. `callback` (mandatory) (function) instead of returning an iterable, pass each dict (as described above) to the given function which must accept a single argument. Nothing is returned. """ validate_nonnegative_int(count, 'count') Validation.callable_check(callback, allow_none=True) evt = self._client._request_sub_recent(self.subid, count=count) self._client._add_recent_cb_for(evt, callback) return evt
[ "def", "get_recent_async", "(", "self", ",", "count", ",", "callback", ")", ":", "validate_nonnegative_int", "(", "count", ",", "'count'", ")", "Validation", ".", "callable_check", "(", "callback", ",", "allow_none", "=", "True", ")", "evt", "=", "self", "."...
Similar to `get_recent` except instead of returning an iterable, passes each dict to the given function which must accept a single argument. Returns the request. `callback` (mandatory) (function) instead of returning an iterable, pass each dict (as described above) to the given function which must accept a single argument. Nothing is returned.
[ "Similar", "to", "get_recent", "except", "instead", "of", "returning", "an", "iterable", "passes", "each", "dict", "to", "the", "given", "function", "which", "must", "accept", "a", "single", "argument", ".", "Returns", "the", "request", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/RemotePoint.py#L112-L123
train
38,219
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/RemotePoint.py
RemoteFeed.simulate
def simulate(self, data, mime=None): """Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn't publish very often. `data` (mandatory) (as applicable) The data you want to use to simulate the arrival of remote feed data `mime` (optional) (string) The mime type of your data. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ self._client.simulate_feeddata(self.__pointid, data, mime)
python
def simulate(self, data, mime=None): """Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn't publish very often. `data` (mandatory) (as applicable) The data you want to use to simulate the arrival of remote feed data `mime` (optional) (string) The mime type of your data. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ self._client.simulate_feeddata(self.__pointid, data, mime)
[ "def", "simulate", "(", "self", ",", "data", ",", "mime", "=", "None", ")", ":", "self", ".", "_client", ".", "simulate_feeddata", "(", "self", ".", "__pointid", ",", "data", ",", "mime", ")" ]
Simulate the arrival of feeddata into the feed. Useful if the remote Thing doesn't publish very often. `data` (mandatory) (as applicable) The data you want to use to simulate the arrival of remote feed data `mime` (optional) (string) The mime type of your data. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share)
[ "Simulate", "the", "arrival", "of", "feeddata", "into", "the", "feed", ".", "Useful", "if", "the", "remote", "Thing", "doesn", "t", "publish", "very", "often", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/RemotePoint.py#L125-L134
train
38,220
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/RemotePoint.py
RemoteControl.ask
def ask(self, data, mime=None): """Request a remote control to do something. Ask is "fire-and-forget" in that you won't receive any notification of the success or otherwise of the action at the far end. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ evt = self.ask_async(data, mime=mime) self._client._wait_and_except_if_failed(evt)
python
def ask(self, data, mime=None): """Request a remote control to do something. Ask is "fire-and-forget" in that you won't receive any notification of the success or otherwise of the action at the far end. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ evt = self.ask_async(data, mime=mime) self._client._wait_and_except_if_failed(evt)
[ "def", "ask", "(", "self", ",", "data", ",", "mime", "=", "None", ")", ":", "evt", "=", "self", ".", "ask_async", "(", "data", ",", "mime", "=", "mime", ")", "self", ".", "_client", ".", "_wait_and_except_if_failed", "(", "evt", ")" ]
Request a remote control to do something. Ask is "fire-and-forget" in that you won't receive any notification of the success or otherwise of the action at the far end. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share)
[ "Request", "a", "remote", "control", "to", "do", "something", ".", "Ask", "is", "fire", "-", "and", "-", "forget", "in", "that", "you", "won", "t", "receive", "any", "notification", "of", "the", "success", "or", "otherwise", "of", "the", "action", "at", ...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/RemotePoint.py#L156-L172
train
38,221
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/RemotePoint.py
RemoteControl.tell
def tell(self, data, timeout=10, mime=None): """Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback `Example` #!python data = {"thermostat":18.0} retval = r_thermostat.tell(data, timeout=10, mime=None) if retval is not True: print("Thermostat not reset - reason: {reason}".format(reason=retval)) Returns True on success or else returns the reason (string) one of: #!python "timeout" # The request-specified timeout has been reached. "unreachable" # The remote control is not associated with an agent # or is not reachable in some other way. "failed" # The remote control indicates it did not perform # the request. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `timeout` (optional) (int) Default 10. The delay in seconds before your tell request times out. `mime` (optional) (string) See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ evt = self.tell_async(data, timeout=timeout, mime=mime) # No point in waiting longer than supplied timeout (as opposed to waiting for sync timeout) try: self._client._wait_and_except_if_failed(evt, timeout=timeout) except IOTSyncTimeout: return 'timeout' return True if evt.payload['success'] else evt.payload['reason']
python
def tell(self, data, timeout=10, mime=None): """Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback `Example` #!python data = {"thermostat":18.0} retval = r_thermostat.tell(data, timeout=10, mime=None) if retval is not True: print("Thermostat not reset - reason: {reason}".format(reason=retval)) Returns True on success or else returns the reason (string) one of: #!python "timeout" # The request-specified timeout has been reached. "unreachable" # The remote control is not associated with an agent # or is not reachable in some other way. "failed" # The remote control indicates it did not perform # the request. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `timeout` (optional) (int) Default 10. The delay in seconds before your tell request times out. `mime` (optional) (string) See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share) """ evt = self.tell_async(data, timeout=timeout, mime=mime) # No point in waiting longer than supplied timeout (as opposed to waiting for sync timeout) try: self._client._wait_and_except_if_failed(evt, timeout=timeout) except IOTSyncTimeout: return 'timeout' return True if evt.payload['success'] else evt.payload['reason']
[ "def", "tell", "(", "self", ",", "data", ",", "timeout", "=", "10", ",", "mime", "=", "None", ")", ":", "evt", "=", "self", ".", "tell_async", "(", "data", ",", "timeout", "=", "timeout", ",", "mime", "=", "mime", ")", "# No point in waiting longer tha...
Order a remote control to do something. Tell is confirmed in that you will receive a notification of the success or otherwise of the action at the far end via a callback `Example` #!python data = {"thermostat":18.0} retval = r_thermostat.tell(data, timeout=10, mime=None) if retval is not True: print("Thermostat not reset - reason: {reason}".format(reason=retval)) Returns True on success or else returns the reason (string) one of: #!python "timeout" # The request-specified timeout has been reached. "unreachable" # The remote control is not associated with an agent # or is not reachable in some other way. "failed" # The remote control indicates it did not perform # the request. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `timeout` (optional) (int) Default 10. The delay in seconds before your tell request times out. `mime` (optional) (string) See: [share()](./Point.m.html#IoticAgent.IOT.Point.Feed.share)
[ "Order", "a", "remote", "control", "to", "do", "something", ".", "Tell", "is", "confirmed", "in", "that", "you", "will", "receive", "a", "notification", "of", "the", "success", "or", "otherwise", "of", "the", "action", "at", "the", "far", "end", "via", "...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/RemotePoint.py#L180-L220
train
38,222
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.rename
def rename(self, new_pid): """Rename the Point. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_pid` (required) (string) the new local identifier of your Point """ logger.info("rename(new_pid=\"%s\") [lid=%s, pid=%s]", new_pid, self.__lid, self.__pid) evt = self._client._request_point_rename(self._type, self.__lid, self.__pid, new_pid) self._client._wait_and_except_if_failed(evt) self.__pid = new_pid
python
def rename(self, new_pid): """Rename the Point. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_pid` (required) (string) the new local identifier of your Point """ logger.info("rename(new_pid=\"%s\") [lid=%s, pid=%s]", new_pid, self.__lid, self.__pid) evt = self._client._request_point_rename(self._type, self.__lid, self.__pid, new_pid) self._client._wait_and_except_if_failed(evt) self.__pid = new_pid
[ "def", "rename", "(", "self", ",", "new_pid", ")", ":", "logger", ".", "info", "(", "\"rename(new_pid=\\\"%s\\\") [lid=%s, pid=%s]\"", ",", "new_pid", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ")", "evt", "=", "self", ".", "_client", ".", "_req...
Rename the Point. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `new_pid` (required) (string) the new local identifier of your Point
[ "Rename", "the", "Point", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L86-L100
train
38,223
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.list
def list(self, limit=50, offset=0): """List `all` the values on this Point. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset """ logger.info("list(limit=%s, offset=%s) [lid=%s,pid=%s]", limit, offset, self.__lid, self.__pid) evt = self._client._request_point_value_list(self.__lid, self.__pid, self._type, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['values']
python
def list(self, limit=50, offset=0): """List `all` the values on this Point. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset """ logger.info("list(limit=%s, offset=%s) [lid=%s,pid=%s]", limit, offset, self.__lid, self.__pid) evt = self._client._request_point_value_list(self.__lid, self.__pid, self._type, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['values']
[ "def", "list", "(", "self", ",", "limit", "=", "50", ",", "offset", "=", "0", ")", ":", "logger", ".", "info", "(", "\"list(limit=%s, offset=%s) [lid=%s,pid=%s]\"", ",", "limit", ",", "offset", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ")", ...
List `all` the values on this Point. Returns QAPI list function payload Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset
[ "List", "all", "the", "values", "on", "this", "Point", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L102-L121
train
38,224
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.list_followers
def list_followers(self): """list followers for this point, i.e. remote follows for feeds and remote attaches for controls. Returns QAPI subscription list function payload #!python { "<Subscription GUID 1>": "<GUID of follower1>", "<Subscription GUID 2>": "<GUID of follower2>" } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset """ evt = self._client._request_point_list_detailed(self._type, self.__lid, self.__pid) self._client._wait_and_except_if_failed(evt) return evt.payload['subs']
python
def list_followers(self): """list followers for this point, i.e. remote follows for feeds and remote attaches for controls. Returns QAPI subscription list function payload #!python { "<Subscription GUID 1>": "<GUID of follower1>", "<Subscription GUID 2>": "<GUID of follower2>" } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset """ evt = self._client._request_point_list_detailed(self._type, self.__lid, self.__pid) self._client._wait_and_except_if_failed(evt) return evt.payload['subs']
[ "def", "list_followers", "(", "self", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_point_list_detailed", "(", "self", ".", "_type", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ")", "self", ".", "_client", ".", "_wait_and_except_if...
list followers for this point, i.e. remote follows for feeds and remote attaches for controls. Returns QAPI subscription list function payload #!python { "<Subscription GUID 1>": "<GUID of follower1>", "<Subscription GUID 2>": "<GUID of follower2>" } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return this many value details `offset` (optional) (integer) Return value details starting at this offset
[ "list", "followers", "for", "this", "point", "i", ".", "e", ".", "remote", "follows", "for", "feeds", "and", "remote", "attaches", "for", "controls", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L123-L147
train
38,225
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.get_meta
def get_meta(self): """Get the metadata object for this Point Returns a [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) object - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ rdf = self.get_meta_rdf(fmt='n3') return PointMeta(self, rdf, self._client.default_lang, fmt='n3')
python
def get_meta(self): """Get the metadata object for this Point Returns a [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) object - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ rdf = self.get_meta_rdf(fmt='n3') return PointMeta(self, rdf, self._client.default_lang, fmt='n3')
[ "def", "get_meta", "(", "self", ")", ":", "rdf", "=", "self", ".", "get_meta_rdf", "(", "fmt", "=", "'n3'", ")", "return", "PointMeta", "(", "self", ",", "rdf", ",", "self", ".", "_client", ".", "default_lang", ",", "fmt", "=", "'n3'", ")" ]
Get the metadata object for this Point Returns a [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) object - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure
[ "Get", "the", "metadata", "object", "for", "this", "Point" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L149-L161
train
38,226
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.get_meta_rdf
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Point in rdf fmt Advanced users who want to manipulate the RDF for this Point directly without the [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_point_meta_get(self._type, self.__lid, self.__pid, fmt=fmt) self._client._wait_and_except_if_failed(evt) return evt.payload['meta']
python
def get_meta_rdf(self, fmt='n3'): """Get the metadata for this Point in rdf fmt Advanced users who want to manipulate the RDF for this Point directly without the [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle" """ evt = self._client._request_point_meta_get(self._type, self.__lid, self.__pid, fmt=fmt) self._client._wait_and_except_if_failed(evt) return evt.payload['meta']
[ "def", "get_meta_rdf", "(", "self", ",", "fmt", "=", "'n3'", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_point_meta_get", "(", "self", ".", "_type", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ",", "fmt", "=", "fmt", ")", ...
Get the metadata for this Point in rdf fmt Advanced users who want to manipulate the RDF for this Point directly without the [PointMeta](PointMeta.m.html#IoticAgent.IOT.PointMeta.PointMeta) helper object Returns the RDF in the format you specify. - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `fmt` (optional) (string) The format of RDF you want returned. Valid formats are: "xml", "n3", "turtle"
[ "Get", "the", "metadata", "for", "this", "Point", "in", "rdf", "fmt" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L163-L183
train
38,227
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.set_meta_rdf
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Point in rdf fmt """ evt = self._client._request_point_meta_set(self._type, self.__lid, self.__pid, rdf, fmt=fmt) self._client._wait_and_except_if_failed(evt)
python
def set_meta_rdf(self, rdf, fmt='n3'): """Set the metadata for this Point in rdf fmt """ evt = self._client._request_point_meta_set(self._type, self.__lid, self.__pid, rdf, fmt=fmt) self._client._wait_and_except_if_failed(evt)
[ "def", "set_meta_rdf", "(", "self", ",", "rdf", ",", "fmt", "=", "'n3'", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_point_meta_set", "(", "self", ".", "_type", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ",", "rdf", ",", ...
Set the metadata for this Point in rdf fmt
[ "Set", "the", "metadata", "for", "this", "Point", "in", "rdf", "fmt" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L185-L189
train
38,228
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.delete_tag
def delete_tag(self, tags): """Delete tags for a Point in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Point, e.g. ["garden", "soil"] """ if isinstance(tags, str): tags = [tags] evt = self._client._request_point_tag_update(self._type, self.__lid, self.__pid, tags, delete=True) self._client._wait_and_except_if_failed(evt)
python
def delete_tag(self, tags): """Delete tags for a Point in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Point, e.g. ["garden", "soil"] """ if isinstance(tags, str): tags = [tags] evt = self._client._request_point_tag_update(self._type, self.__lid, self.__pid, tags, delete=True) self._client._wait_and_except_if_failed(evt)
[ "def", "delete_tag", "(", "self", ",", "tags", ")", ":", "if", "isinstance", "(", "tags", ",", "str", ")", ":", "tags", "=", "[", "tags", "]", "evt", "=", "self", ".", "_client", ".", "_request_point_tag_update", "(", "self", ".", "_type", ",", "self...
Delete tags for a Point in the language you specify. Case will be ignored and any tags matching lower-cased will be deleted. Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `tags` (mandatory) (list) - the list of tags you want to delete from your Point, e.g. ["garden", "soil"]
[ "Delete", "tags", "for", "a", "Point", "in", "the", "language", "you", "specify", ".", "Case", "will", "be", "ignored", "and", "any", "tags", "matching", "lower", "-", "cased", "will", "be", "deleted", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L210-L227
train
38,229
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Point.list_tag
def list_tag(self, limit=50, offset=0): """List `all` the tags for this Point Returns list of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset """ evt = self._client._request_point_tag_list(self._type, self.__lid, self.__pid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['tags']
python
def list_tag(self, limit=50, offset=0): """List `all` the tags for this Point Returns list of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset """ evt = self._client._request_point_tag_list(self._type, self.__lid, self.__pid, limit=limit, offset=offset) self._client._wait_and_except_if_failed(evt) return evt.payload['tags']
[ "def", "list_tag", "(", "self", ",", "limit", "=", "50", ",", "offset", "=", "0", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_point_tag_list", "(", "self", ".", "_type", ",", "self", ".", "__lid", ",", "self", ".", "__pid", ",", "l...
List `all` the tags for this Point Returns list of tags, as below #!python [ "mytag1", "mytag2" "ein_name", "nochein_name" ] - OR... Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `limit` (optional) (integer) Return at most this many tags `offset` (optional) (integer) Return tags starting at this offset
[ "List", "all", "the", "tags", "for", "this", "Point" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L229-L257
train
38,230
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Feed.share
def share(self, data, mime=None, time=None): """Share some data from this Feed Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. There are some Iotic Labs-defined default values: `"idx/1"` - Corresponds to "application/ubjson" - the recommended way to send mixed data. Share a python dictionary as the data and the agent will to the encoding and decoding for you. #!python data = {} data["temperature"] = self._convert_to_celsius(ADC.read(1)) # ...etc... my_feed.share(data) `"idx/2"` Corresponds to "text/plain" - the recommended way to send textual data. Share a utf8 string as data and the agent will pass it on, unchanged. #!python my_feed.share(u"string data") `"text/xml"` or any other valid mime type. To show the recipients that you're sending something more than just bytes #!python my_feed.share("<xml>...</xml>".encode('utf8'), mime="text/xml") `time` (optional) (datetime) UTC time for this share. If not specified, the container's time will be used. Thus it makes almost no sense to specify `datetime.utcnow()` here. This parameter can be used to indicate that the share time does not correspond to the time to which the data applies, e.g. to populate recent storgage with historical data. """ evt = self.share_async(data, mime=mime, time=time) self._client._wait_and_except_if_failed(evt)
python
def share(self, data, mime=None, time=None): """Share some data from this Feed Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. There are some Iotic Labs-defined default values: `"idx/1"` - Corresponds to "application/ubjson" - the recommended way to send mixed data. Share a python dictionary as the data and the agent will to the encoding and decoding for you. #!python data = {} data["temperature"] = self._convert_to_celsius(ADC.read(1)) # ...etc... my_feed.share(data) `"idx/2"` Corresponds to "text/plain" - the recommended way to send textual data. Share a utf8 string as data and the agent will pass it on, unchanged. #!python my_feed.share(u"string data") `"text/xml"` or any other valid mime type. To show the recipients that you're sending something more than just bytes #!python my_feed.share("<xml>...</xml>".encode('utf8'), mime="text/xml") `time` (optional) (datetime) UTC time for this share. If not specified, the container's time will be used. Thus it makes almost no sense to specify `datetime.utcnow()` here. This parameter can be used to indicate that the share time does not correspond to the time to which the data applies, e.g. to populate recent storgage with historical data. """ evt = self.share_async(data, mime=mime, time=time) self._client._wait_and_except_if_failed(evt)
[ "def", "share", "(", "self", ",", "data", ",", "mime", "=", "None", ",", "time", "=", "None", ")", ":", "evt", "=", "self", ".", "share_async", "(", "data", ",", "mime", "=", "mime", ",", "time", "=", "time", ")", "self", ".", "_client", ".", "...
Share some data from this Feed Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure `data` (mandatory) (as applicable) The data you want to share `mime` (optional) (string) The mime type of the data you're sharing. There are some Iotic Labs-defined default values: `"idx/1"` - Corresponds to "application/ubjson" - the recommended way to send mixed data. Share a python dictionary as the data and the agent will to the encoding and decoding for you. #!python data = {} data["temperature"] = self._convert_to_celsius(ADC.read(1)) # ...etc... my_feed.share(data) `"idx/2"` Corresponds to "text/plain" - the recommended way to send textual data. Share a utf8 string as data and the agent will pass it on, unchanged. #!python my_feed.share(u"string data") `"text/xml"` or any other valid mime type. To show the recipients that you're sending something more than just bytes #!python my_feed.share("<xml>...</xml>".encode('utf8'), mime="text/xml") `time` (optional) (datetime) UTC time for this share. If not specified, the container's time will be used. Thus it makes almost no sense to specify `datetime.utcnow()` here. This parameter can be used to indicate that the share time does not correspond to the time to which the data applies, e.g. to populate recent storgage with historical data.
[ "Share", "some", "data", "from", "this", "Feed" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L334-L375
train
38,231
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
Feed.get_recent_info
def get_recent_info(self): """Retrieves statistics and configuration about recent storage for this Feed. Returns QAPI recent info function payload #!python { "maxSamples": 0, "count": 0 } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ evt = self._client._request_point_recent_info(self._type, self.lid, self.pid) self._client._wait_and_except_if_failed(evt) return evt.payload['recent']
python
def get_recent_info(self): """Retrieves statistics and configuration about recent storage for this Feed. Returns QAPI recent info function payload #!python { "maxSamples": 0, "count": 0 } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ evt = self._client._request_point_recent_info(self._type, self.lid, self.pid) self._client._wait_and_except_if_failed(evt) return evt.payload['recent']
[ "def", "get_recent_info", "(", "self", ")", ":", "evt", "=", "self", ".", "_client", ".", "_request_point_recent_info", "(", "self", ".", "_type", ",", "self", ".", "lid", ",", "self", ".", "pid", ")", "self", ".", "_client", ".", "_wait_and_except_if_fail...
Retrieves statistics and configuration about recent storage for this Feed. Returns QAPI recent info function payload #!python { "maxSamples": 0, "count": 0 } Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure
[ "Retrieves", "statistics", "and", "configuration", "about", "recent", "storage", "for", "this", "Feed", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L383-L403
train
38,232
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
PointDataObject.to_dict
def to_dict(self): """Converts the set of values into a dictionary. Unset values are excluded.""" return {value.label: value.value for value in self.__values if not value.unset}
python
def to_dict(self): """Converts the set of values into a dictionary. Unset values are excluded.""" return {value.label: value.value for value in self.__values if not value.unset}
[ "def", "to_dict", "(", "self", ")", ":", "return", "{", "value", ".", "label", ":", "value", ".", "value", "for", "value", "in", "self", ".", "__values", "if", "not", "value", ".", "unset", "}" ]
Converts the set of values into a dictionary. Unset values are excluded.
[ "Converts", "the", "set", "of", "values", "into", "a", "dictionary", ".", "Unset", "values", "are", "excluded", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L500-L502
train
38,233
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Point.py
PointDataObject._from_dict
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True): """Instantiates new PointDataObject, populated from the given dictionary. With allow_unset=False, a ValueError will be raised if any value has not been set. Used by PointDataObjectHandler""" if not isinstance(dictionary, Mapping): raise TypeError('dictionary should be mapping') obj = cls(values, value_filter) values = obj.__values for name, value in dictionary.items(): if not isinstance(name, string_types): raise TypeError('Key %s is not a string' % str(name)) setattr(values, name, value) if obj.missing and not allow_unset: raise ValueError('%d value(s) are unset' % len(obj.missing)) return obj
python
def _from_dict(cls, values, value_filter, dictionary, allow_unset=True): """Instantiates new PointDataObject, populated from the given dictionary. With allow_unset=False, a ValueError will be raised if any value has not been set. Used by PointDataObjectHandler""" if not isinstance(dictionary, Mapping): raise TypeError('dictionary should be mapping') obj = cls(values, value_filter) values = obj.__values for name, value in dictionary.items(): if not isinstance(name, string_types): raise TypeError('Key %s is not a string' % str(name)) setattr(values, name, value) if obj.missing and not allow_unset: raise ValueError('%d value(s) are unset' % len(obj.missing)) return obj
[ "def", "_from_dict", "(", "cls", ",", "values", ",", "value_filter", ",", "dictionary", ",", "allow_unset", "=", "True", ")", ":", "if", "not", "isinstance", "(", "dictionary", ",", "Mapping", ")", ":", "raise", "TypeError", "(", "'dictionary should be mapping...
Instantiates new PointDataObject, populated from the given dictionary. With allow_unset=False, a ValueError will be raised if any value has not been set. Used by PointDataObjectHandler
[ "Instantiates", "new", "PointDataObject", "populated", "from", "the", "given", "dictionary", ".", "With", "allow_unset", "=", "False", "a", "ValueError", "will", "be", "raised", "if", "any", "value", "has", "not", "been", "set", ".", "Used", "by", "PointDataOb...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Point.py#L505-L518
train
38,234
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/ResourceMeta.py
ResourceMeta.update
def update(self): """Gets the latest version of your metadata from the infrastructure and updates your local copy Returns `True` if successful, `False` otherwise - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ graph = Graph() graph.parse(data=self.__parent.get_meta_rdf(fmt=self.__fmt), format=self.__fmt) self._graph = graph
python
def update(self): """Gets the latest version of your metadata from the infrastructure and updates your local copy Returns `True` if successful, `False` otherwise - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure """ graph = Graph() graph.parse(data=self.__parent.get_meta_rdf(fmt=self.__fmt), format=self.__fmt) self._graph = graph
[ "def", "update", "(", "self", ")", ":", "graph", "=", "Graph", "(", ")", "graph", ".", "parse", "(", "data", "=", "self", ".", "__parent", ".", "get_meta_rdf", "(", "fmt", "=", "self", ".", "__fmt", ")", ",", "format", "=", "self", ".", "__fmt", ...
Gets the latest version of your metadata from the infrastructure and updates your local copy Returns `True` if successful, `False` otherwise - OR - Raises [IOTException](./Exceptions.m.html#IoticAgent.IOT.Exceptions.IOTException) containing the error if the infrastructure detects a problem Raises [LinkException](../Core/AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if there is a communications problem between you and the infrastructure
[ "Gets", "the", "latest", "version", "of", "your", "metadata", "from", "the", "infrastructure", "and", "updates", "your", "local", "copy" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/ResourceMeta.py#L133-L146
train
38,235
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/compat/thread_utils.py
_InterruptableLock.acquire
def acquire(self, blocking=True, timeout=-1): """Acquire a lock, blocking or non-blocking. Blocks until timeout, if timeout a positive float and blocking=True. A timeout value of -1 blocks indefinitely, unless blocking=False.""" if not isinstance(timeout, (int, float)): raise TypeError('a float is required') if blocking: # blocking indefinite if timeout == -1: with self.__condition: while not self.__lock.acquire(False): # condition with timeout is interruptable self.__condition.wait(60) return True # same as non-blocking elif timeout == 0: return self.__lock.acquire(False) elif timeout < 0: raise ValueError('timeout value must be strictly positive (or -1)') # blocking finite else: start = time() waited_time = 0 with self.__condition: while waited_time < timeout: if self.__lock.acquire(False): return True else: self.__condition.wait(timeout - waited_time) waited_time = time() - start return False elif timeout != -1: raise ValueError('can\'t specify a timeout for a non-blocking call') else: # non-blocking return self.__lock.acquire(False)
python
def acquire(self, blocking=True, timeout=-1): """Acquire a lock, blocking or non-blocking. Blocks until timeout, if timeout a positive float and blocking=True. A timeout value of -1 blocks indefinitely, unless blocking=False.""" if not isinstance(timeout, (int, float)): raise TypeError('a float is required') if blocking: # blocking indefinite if timeout == -1: with self.__condition: while not self.__lock.acquire(False): # condition with timeout is interruptable self.__condition.wait(60) return True # same as non-blocking elif timeout == 0: return self.__lock.acquire(False) elif timeout < 0: raise ValueError('timeout value must be strictly positive (or -1)') # blocking finite else: start = time() waited_time = 0 with self.__condition: while waited_time < timeout: if self.__lock.acquire(False): return True else: self.__condition.wait(timeout - waited_time) waited_time = time() - start return False elif timeout != -1: raise ValueError('can\'t specify a timeout for a non-blocking call') else: # non-blocking return self.__lock.acquire(False)
[ "def", "acquire", "(", "self", ",", "blocking", "=", "True", ",", "timeout", "=", "-", "1", ")", ":", "if", "not", "isinstance", "(", "timeout", ",", "(", "int", ",", "float", ")", ")", ":", "raise", "TypeError", "(", "'a float is required'", ")", "i...
Acquire a lock, blocking or non-blocking. Blocks until timeout, if timeout a positive float and blocking=True. A timeout value of -1 blocks indefinitely, unless blocking=False.
[ "Acquire", "a", "lock", "blocking", "or", "non", "-", "blocking", ".", "Blocks", "until", "timeout", "if", "timeout", "a", "positive", "float", "and", "blocking", "=", "True", ".", "A", "timeout", "value", "of", "-", "1", "blocks", "indefinitely", "unless"...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/compat/thread_utils.py#L34-L75
train
38,236
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/compat/thread_utils.py
_InterruptableLock.release
def release(self): """Release a lock.""" self.__lock.release() with self.__condition: self.__condition.notify()
python
def release(self): """Release a lock.""" self.__lock.release() with self.__condition: self.__condition.notify()
[ "def", "release", "(", "self", ")", ":", "self", ".", "__lock", ".", "release", "(", ")", "with", "self", ".", "__condition", ":", "self", ".", "__condition", ".", "notify", "(", ")" ]
Release a lock.
[ "Release", "a", "lock", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/compat/thread_utils.py#L77-L81
train
38,237
tophatmonocle/ims_lti_py
ims_lti_py/tool_consumer.py
ToolConsumer.set_config
def set_config(self, config): ''' Set launch data from a ToolConfig. ''' if self.launch_url == None: self.launch_url = config.launch_url self.custom_params.update(config.custom_params)
python
def set_config(self, config): ''' Set launch data from a ToolConfig. ''' if self.launch_url == None: self.launch_url = config.launch_url self.custom_params.update(config.custom_params)
[ "def", "set_config", "(", "self", ",", "config", ")", ":", "if", "self", ".", "launch_url", "==", "None", ":", "self", ".", "launch_url", "=", "config", ".", "launch_url", "self", ".", "custom_params", ".", "update", "(", "config", ".", "custom_params", ...
Set launch data from a ToolConfig.
[ "Set", "launch", "data", "from", "a", "ToolConfig", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_consumer.py#L38-L44
train
38,238
tophatmonocle/ims_lti_py
ims_lti_py/tool_consumer.py
ToolConsumer.has_required_params
def has_required_params(self): ''' Check if required parameters for a tool launch are set. ''' return self.consumer_key and\ self.consumer_secret and\ self.resource_link_id and\ self.launch_url
python
def has_required_params(self): ''' Check if required parameters for a tool launch are set. ''' return self.consumer_key and\ self.consumer_secret and\ self.resource_link_id and\ self.launch_url
[ "def", "has_required_params", "(", "self", ")", ":", "return", "self", ".", "consumer_key", "and", "self", ".", "consumer_secret", "and", "self", ".", "resource_link_id", "and", "self", ".", "launch_url" ]
Check if required parameters for a tool launch are set.
[ "Check", "if", "required", "parameters", "for", "a", "tool", "launch", "are", "set", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_consumer.py#L46-L53
train
38,239
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/RequestEvent.py
RequestEvent._sent_without_response
def _sent_without_response(self, send_time_before): """Used internally to determine whether the request has not received any response from the container and was send before the given time. Unsent requests are not considered.""" return not self._messages and self._send_time and self._send_time < send_time_before
python
def _sent_without_response(self, send_time_before): """Used internally to determine whether the request has not received any response from the container and was send before the given time. Unsent requests are not considered.""" return not self._messages and self._send_time and self._send_time < send_time_before
[ "def", "_sent_without_response", "(", "self", ",", "send_time_before", ")", ":", "return", "not", "self", ".", "_messages", "and", "self", ".", "_send_time", "and", "self", ".", "_send_time", "<", "send_time_before" ]
Used internally to determine whether the request has not received any response from the container and was send before the given time. Unsent requests are not considered.
[ "Used", "internally", "to", "determine", "whether", "the", "request", "has", "not", "received", "any", "response", "from", "the", "container", "and", "was", "send", "before", "the", "given", "time", ".", "Unsent", "requests", "are", "not", "considered", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/RequestEvent.py#L62-L65
train
38,240
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/RequestEvent.py
RequestEvent.is_set
def is_set(self): """Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem. """ if self.__event.is_set(): if self.exception is not None: # todo better way to raise errors on behalf of other Threads? raise self.exception # pylint: disable=raising-bad-type return True return False
python
def is_set(self): """Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem. """ if self.__event.is_set(): if self.exception is not None: # todo better way to raise errors on behalf of other Threads? raise self.exception # pylint: disable=raising-bad-type return True return False
[ "def", "is_set", "(", "self", ")", ":", "if", "self", ".", "__event", ".", "is_set", "(", ")", ":", "if", "self", ".", "exception", "is", "not", "None", ":", "# todo better way to raise errors on behalf of other Threads?", "raise", "self", ".", "exception", "#...
Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem.
[ "Returns", "True", "if", "the", "request", "has", "finished", "or", "False", "if", "it", "is", "still", "pending", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/RequestEvent.py#L67-L78
train
38,241
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/RequestEvent.py
RequestEvent._set
def _set(self): """Called internally by Client to indicate this request has finished""" self.__event.set() if self._complete_func: self.__run_completion_func(self._complete_func, self.id_)
python
def _set(self): """Called internally by Client to indicate this request has finished""" self.__event.set() if self._complete_func: self.__run_completion_func(self._complete_func, self.id_)
[ "def", "_set", "(", "self", ")", ":", "self", ".", "__event", ".", "set", "(", ")", "if", "self", ".", "_complete_func", ":", "self", ".", "__run_completion_func", "(", "self", ".", "_complete_func", ",", "self", ".", "id_", ")" ]
Called internally by Client to indicate this request has finished
[ "Called", "internally", "by", "Client", "to", "indicate", "this", "request", "has", "finished" ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/RequestEvent.py#L80-L84
train
38,242
Iotic-Labs/py-IoticAgent
src/IoticAgent/Core/RequestEvent.py
RequestEvent.wait
def wait(self, timeout=None): """Wait for the request to finish, optionally timing out. Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem. """ if self.__event.wait(timeout): if self.exception is not None: # todo better way to raise errors on behalf of other Threads? raise self.exception # pylint: disable=raising-bad-type return True return False
python
def wait(self, timeout=None): """Wait for the request to finish, optionally timing out. Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem. """ if self.__event.wait(timeout): if self.exception is not None: # todo better way to raise errors on behalf of other Threads? raise self.exception # pylint: disable=raising-bad-type return True return False
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "if", "self", ".", "__event", ".", "wait", "(", "timeout", ")", ":", "if", "self", ".", "exception", "is", "not", "None", ":", "# todo better way to raise errors on behalf of other Threads?", ...
Wait for the request to finish, optionally timing out. Returns True if the request has finished or False if it is still pending. Raises [LinkException](AmqpLink.m.html#IoticAgent.Core.AmqpLink.LinkException) if the request failed due to a network related problem.
[ "Wait", "for", "the", "request", "to", "finish", "optionally", "timing", "out", ".", "Returns", "True", "if", "the", "request", "has", "finished", "or", "False", "if", "it", "is", "still", "pending", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/Core/RequestEvent.py#L107-L119
train
38,243
edx/edx-django-utils
edx_django_utils/private_utils.py
_check_middleware_dependencies
def _check_middleware_dependencies(concerned_object, required_middleware): """ Check required middleware dependencies exist and in the correct order. Args: concerned_object (object): The object for which the required middleware is being checked. This is used for error messages only. required_middleware (list of String): An ordered list representing the required middleware to be checked. Usage: Add in __init__ method to a Middleware class to have its dependencies checked on startup. def __init__(self): super(SomeMiddleware, self).__init__() _check_middleware_dependencies(self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', ]) Raises: AssertionError if the provided dependencies don't appear in MIDDLEWARE_CLASSES in the correct order. """ declared_middleware = getattr(settings, 'MIDDLEWARE', None) if declared_middleware is None: declared_middleware = settings.MIDDLEWARE_CLASSES # Django 1.8 support # Filter out all the middleware except the ones we care about for ordering. matching_middleware = [mw for mw in declared_middleware if mw in required_middleware] if required_middleware != matching_middleware: raise AssertionError( "{} requires middleware order {} but matching middleware was {}".format( concerned_object, required_middleware, matching_middleware ) )
python
def _check_middleware_dependencies(concerned_object, required_middleware): """ Check required middleware dependencies exist and in the correct order. Args: concerned_object (object): The object for which the required middleware is being checked. This is used for error messages only. required_middleware (list of String): An ordered list representing the required middleware to be checked. Usage: Add in __init__ method to a Middleware class to have its dependencies checked on startup. def __init__(self): super(SomeMiddleware, self).__init__() _check_middleware_dependencies(self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', ]) Raises: AssertionError if the provided dependencies don't appear in MIDDLEWARE_CLASSES in the correct order. """ declared_middleware = getattr(settings, 'MIDDLEWARE', None) if declared_middleware is None: declared_middleware = settings.MIDDLEWARE_CLASSES # Django 1.8 support # Filter out all the middleware except the ones we care about for ordering. matching_middleware = [mw for mw in declared_middleware if mw in required_middleware] if required_middleware != matching_middleware: raise AssertionError( "{} requires middleware order {} but matching middleware was {}".format( concerned_object, required_middleware, matching_middleware ) )
[ "def", "_check_middleware_dependencies", "(", "concerned_object", ",", "required_middleware", ")", ":", "declared_middleware", "=", "getattr", "(", "settings", ",", "'MIDDLEWARE'", ",", "None", ")", "if", "declared_middleware", "is", "None", ":", "declared_middleware", ...
Check required middleware dependencies exist and in the correct order. Args: concerned_object (object): The object for which the required middleware is being checked. This is used for error messages only. required_middleware (list of String): An ordered list representing the required middleware to be checked. Usage: Add in __init__ method to a Middleware class to have its dependencies checked on startup. def __init__(self): super(SomeMiddleware, self).__init__() _check_middleware_dependencies(self, required_middleware=[ 'edx_django_utils.cache.middleware.RequestCacheMiddleware', ]) Raises: AssertionError if the provided dependencies don't appear in MIDDLEWARE_CLASSES in the correct order.
[ "Check", "required", "middleware", "dependencies", "exist", "and", "in", "the", "correct", "order", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/private_utils.py#L12-L48
train
38,244
tophatmonocle/ims_lti_py
ims_lti_py/request_validator.py
FlaskRequestValidatorMixin.parse_request
def parse_request(self, request, parameters=None, fake_method=None): ''' Parse Flask request ''' return (request.method, request.url, request.headers, request.form.copy())
python
def parse_request(self, request, parameters=None, fake_method=None): ''' Parse Flask request ''' return (request.method, request.url, request.headers, request.form.copy())
[ "def", "parse_request", "(", "self", ",", "request", ",", "parameters", "=", "None", ",", "fake_method", "=", "None", ")", ":", "return", "(", "request", ".", "method", ",", "request", ".", "url", ",", "request", ".", "headers", ",", "request", ".", "f...
Parse Flask request
[ "Parse", "Flask", "request" ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/request_validator.py#L74-L81
train
38,245
tophatmonocle/ims_lti_py
ims_lti_py/request_validator.py
DjangoRequestValidatorMixin.parse_request
def parse_request(self, request, parameters, fake_method=None): ''' Parse Django request ''' return (fake_method or request.method, request.build_absolute_uri(), request.META, (dict(request.POST.iteritems()) if request.method == 'POST' else parameters))
python
def parse_request(self, request, parameters, fake_method=None): ''' Parse Django request ''' return (fake_method or request.method, request.build_absolute_uri(), request.META, (dict(request.POST.iteritems()) if request.method == 'POST' else parameters))
[ "def", "parse_request", "(", "self", ",", "request", ",", "parameters", ",", "fake_method", "=", "None", ")", ":", "return", "(", "fake_method", "or", "request", ".", "method", ",", "request", ".", "build_absolute_uri", "(", ")", ",", "request", ".", "META...
Parse Django request
[ "Parse", "Django", "request" ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/request_validator.py#L89-L98
train
38,246
tophatmonocle/ims_lti_py
ims_lti_py/request_validator.py
WebObRequestValidatorMixin.parse_request
def parse_request(self, request, parameters=None, fake_method=None): ''' Parse WebOb request ''' return (request.method, request.url, request.headers, request.POST.mixed())
python
def parse_request(self, request, parameters=None, fake_method=None): ''' Parse WebOb request ''' return (request.method, request.url, request.headers, request.POST.mixed())
[ "def", "parse_request", "(", "self", ",", "request", ",", "parameters", "=", "None", ",", "fake_method", "=", "None", ")", ":", "return", "(", "request", ".", "method", ",", "request", ".", "url", ",", "request", ".", "headers", ",", "request", ".", "P...
Parse WebOb request
[ "Parse", "WebOb", "request" ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/request_validator.py#L105-L112
train
38,247
tophatmonocle/ims_lti_py
ims_lti_py/outcome_response.py
OutcomeResponse.from_post_response
def from_post_response(post_response, content): ''' Convenience method for creating a new OutcomeResponse from a response object. ''' response = OutcomeResponse() response.post_response = post_response response.response_code = post_response.status response.process_xml(content) return response
python
def from_post_response(post_response, content): ''' Convenience method for creating a new OutcomeResponse from a response object. ''' response = OutcomeResponse() response.post_response = post_response response.response_code = post_response.status response.process_xml(content) return response
[ "def", "from_post_response", "(", "post_response", ",", "content", ")", ":", "response", "=", "OutcomeResponse", "(", ")", "response", ".", "post_response", "=", "post_response", "response", ".", "response_code", "=", "post_response", ".", "status", "response", "....
Convenience method for creating a new OutcomeResponse from a response object.
[ "Convenience", "method", "for", "creating", "a", "new", "OutcomeResponse", "from", "a", "response", "object", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_response.py#L55-L64
train
38,248
tophatmonocle/ims_lti_py
ims_lti_py/outcome_response.py
OutcomeResponse.process_xml
def process_xml(self, xml): ''' Parse OutcomeResponse data form XML. ''' try: root = objectify.fromstring(xml) # Get message idenifier from header info self.message_identifier = root.imsx_POXHeader.\ imsx_POXResponseHeaderInfo.\ imsx_messageIdentifier status_node = root.imsx_POXHeader.\ imsx_POXResponseHeaderInfo.\ imsx_statusInfo # Get status parameters from header info status self.code_major = status_node.imsx_codeMajor self.severity = status_node.imsx_severity self.description = status_node.imsx_description self.message_ref_identifier = str( status_node.imsx_messageRefIdentifier) self.operation = status_node.imsx_operationRefIdentifier try: # Try to get the score self.score = str(root.imsx_POXBody.readResultResponse. result.resultScore.textString) except AttributeError: # Not a readResult, just ignore! pass except: pass
python
def process_xml(self, xml): ''' Parse OutcomeResponse data form XML. ''' try: root = objectify.fromstring(xml) # Get message idenifier from header info self.message_identifier = root.imsx_POXHeader.\ imsx_POXResponseHeaderInfo.\ imsx_messageIdentifier status_node = root.imsx_POXHeader.\ imsx_POXResponseHeaderInfo.\ imsx_statusInfo # Get status parameters from header info status self.code_major = status_node.imsx_codeMajor self.severity = status_node.imsx_severity self.description = status_node.imsx_description self.message_ref_identifier = str( status_node.imsx_messageRefIdentifier) self.operation = status_node.imsx_operationRefIdentifier try: # Try to get the score self.score = str(root.imsx_POXBody.readResultResponse. result.resultScore.textString) except AttributeError: # Not a readResult, just ignore! pass except: pass
[ "def", "process_xml", "(", "self", ",", "xml", ")", ":", "try", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ")", "# Get message idenifier from header info", "self", ".", "message_identifier", "=", "root", ".", "imsx_POXHeader", ".", "imsx_POXRe...
Parse OutcomeResponse data form XML.
[ "Parse", "OutcomeResponse", "data", "form", "XML", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_response.py#L84-L115
train
38,249
tophatmonocle/ims_lti_py
ims_lti_py/outcome_response.py
OutcomeResponse.generate_response_xml
def generate_response_xml(self): ''' Generate XML based on the current configuration. ''' root = etree.Element( 'imsx_POXEnvelopeResponse', xmlns='http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0') header = etree.SubElement(root, 'imsx_POXHeader') header_info = etree.SubElement(header, 'imsx_POXResponseHeaderInfo') version = etree.SubElement(header_info, 'imsx_version') version.text = 'V1.0' message_identifier = etree.SubElement(header_info, 'imsx_messageIdentifier') message_identifier.text = str(self.message_identifier) status_info = etree.SubElement(header_info, 'imsx_statusInfo') code_major = etree.SubElement(status_info, 'imsx_codeMajor') code_major.text = str(self.code_major) severity = etree.SubElement(status_info, 'imsx_severity') severity.text = str(self.severity) description = etree.SubElement(status_info, 'imsx_description') description.text = str(self.description) message_ref_identifier = etree.SubElement( status_info, 'imsx_messageRefIdentifier') message_ref_identifier.text = str(self.message_ref_identifier) operation_ref_identifier = etree.SubElement( status_info, 'imsx_operationRefIdentifier') operation_ref_identifier.text = str(self.operation) body = etree.SubElement(root, 'imsx_POXBody') response = etree.SubElement(body, '%s%s' % (self.operation, 'Response')) if self.score: result = etree.SubElement(response, 'result') result_score = etree.SubElement(result, 'resultScore') language = etree.SubElement(result_score, 'language') language.text = 'en' text_string = etree.SubElement(result_score, 'textString') text_string.text = str(self.score) return '<?xml version="1.0" encoding="UTF-8"?>' + etree.tostring(root)
python
def generate_response_xml(self): ''' Generate XML based on the current configuration. ''' root = etree.Element( 'imsx_POXEnvelopeResponse', xmlns='http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0') header = etree.SubElement(root, 'imsx_POXHeader') header_info = etree.SubElement(header, 'imsx_POXResponseHeaderInfo') version = etree.SubElement(header_info, 'imsx_version') version.text = 'V1.0' message_identifier = etree.SubElement(header_info, 'imsx_messageIdentifier') message_identifier.text = str(self.message_identifier) status_info = etree.SubElement(header_info, 'imsx_statusInfo') code_major = etree.SubElement(status_info, 'imsx_codeMajor') code_major.text = str(self.code_major) severity = etree.SubElement(status_info, 'imsx_severity') severity.text = str(self.severity) description = etree.SubElement(status_info, 'imsx_description') description.text = str(self.description) message_ref_identifier = etree.SubElement( status_info, 'imsx_messageRefIdentifier') message_ref_identifier.text = str(self.message_ref_identifier) operation_ref_identifier = etree.SubElement( status_info, 'imsx_operationRefIdentifier') operation_ref_identifier.text = str(self.operation) body = etree.SubElement(root, 'imsx_POXBody') response = etree.SubElement(body, '%s%s' % (self.operation, 'Response')) if self.score: result = etree.SubElement(response, 'result') result_score = etree.SubElement(result, 'resultScore') language = etree.SubElement(result_score, 'language') language.text = 'en' text_string = etree.SubElement(result_score, 'textString') text_string.text = str(self.score) return '<?xml version="1.0" encoding="UTF-8"?>' + etree.tostring(root)
[ "def", "generate_response_xml", "(", "self", ")", ":", "root", "=", "etree", ".", "Element", "(", "'imsx_POXEnvelopeResponse'", ",", "xmlns", "=", "'http://www.imsglobal.org/services/ltiv1p1/xsd/imsoms_v1p0'", ")", "header", "=", "etree", ".", "SubElement", "(", "root...
Generate XML based on the current configuration.
[ "Generate", "XML", "based", "on", "the", "current", "configuration", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/outcome_response.py#L117-L160
train
38,250
edx/edx-django-utils
edx_django_utils/monitoring/utils.py
set_custom_metrics_for_course_key
def set_custom_metrics_for_course_key(course_key): """ Set monitoring custom metrics related to a course key. This is not cached, and only support reporting to New Relic Insights. """ if not newrelic: return newrelic.agent.add_custom_parameter('course_id', six.text_type(course_key)) newrelic.agent.add_custom_parameter('org', six.text_type(course_key.org))
python
def set_custom_metrics_for_course_key(course_key): """ Set monitoring custom metrics related to a course key. This is not cached, and only support reporting to New Relic Insights. """ if not newrelic: return newrelic.agent.add_custom_parameter('course_id', six.text_type(course_key)) newrelic.agent.add_custom_parameter('org', six.text_type(course_key.org))
[ "def", "set_custom_metrics_for_course_key", "(", "course_key", ")", ":", "if", "not", "newrelic", ":", "return", "newrelic", ".", "agent", ".", "add_custom_parameter", "(", "'course_id'", ",", "six", ".", "text_type", "(", "course_key", ")", ")", "newrelic", "."...
Set monitoring custom metrics related to a course key. This is not cached, and only support reporting to New Relic Insights.
[ "Set", "monitoring", "custom", "metrics", "related", "to", "a", "course", "key", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/utils.py#L65-L75
train
38,251
edx/edx-django-utils
edx_django_utils/monitoring/utils.py
set_monitoring_transaction_name
def set_monitoring_transaction_name(name, group=None, priority=None): """ Sets the transaction name for monitoring. This is not cached, and only support reporting to New Relic. """ if not newrelic: return newrelic.agent.set_transaction_name(name, group, priority)
python
def set_monitoring_transaction_name(name, group=None, priority=None): """ Sets the transaction name for monitoring. This is not cached, and only support reporting to New Relic. """ if not newrelic: return newrelic.agent.set_transaction_name(name, group, priority)
[ "def", "set_monitoring_transaction_name", "(", "name", ",", "group", "=", "None", ",", "priority", "=", "None", ")", ":", "if", "not", "newrelic", ":", "return", "newrelic", ".", "agent", ".", "set_transaction_name", "(", "name", ",", "group", ",", "priority...
Sets the transaction name for monitoring. This is not cached, and only support reporting to New Relic.
[ "Sets", "the", "transaction", "name", "for", "monitoring", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/utils.py#L90-L99
train
38,252
edx/edx-django-utils
edx_django_utils/monitoring/utils.py
function_trace
def function_trace(function_name): """ Wraps a chunk of code that we want to appear as a separate, explicit, segment in our monitoring tools. """ if newrelic: nr_transaction = newrelic.agent.current_transaction() with newrelic.agent.FunctionTrace(nr_transaction, function_name): yield else: yield
python
def function_trace(function_name): """ Wraps a chunk of code that we want to appear as a separate, explicit, segment in our monitoring tools. """ if newrelic: nr_transaction = newrelic.agent.current_transaction() with newrelic.agent.FunctionTrace(nr_transaction, function_name): yield else: yield
[ "def", "function_trace", "(", "function_name", ")", ":", "if", "newrelic", ":", "nr_transaction", "=", "newrelic", ".", "agent", ".", "current_transaction", "(", ")", "with", "newrelic", ".", "agent", ".", "FunctionTrace", "(", "nr_transaction", ",", "function_n...
Wraps a chunk of code that we want to appear as a separate, explicit, segment in our monitoring tools.
[ "Wraps", "a", "chunk", "of", "code", "that", "we", "want", "to", "appear", "as", "a", "separate", "explicit", "segment", "in", "our", "monitoring", "tools", "." ]
16cb4ac617e53c572bf68ccd19d24afeff1ca769
https://github.com/edx/edx-django-utils/blob/16cb4ac617e53c572bf68ccd19d24afeff1ca769/edx_django_utils/monitoring/utils.py#L103-L113
train
38,253
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/PointValueHelper.py
_ValueFilter.filter_by
def filter_by(self, types=(), units=()): """Return list of value labels, filtered by either or both type and unit. An empty sequence for either argument will match as long as the other argument matches any values.""" if not (isinstance(types, Sequence) and isinstance(units, Sequence)): raise TypeError('types/units must be a sequence') empty = frozenset() if types: type_names = set() for type_ in types: type_names |= self.by_type.get(type_, empty) if not units: return type_names if units: unit_names = set() for unit in units: unit_names |= self.by_unit.get(unit, empty) if not types: return unit_names return (type_names & unit_names) if (types and units) else empty
python
def filter_by(self, types=(), units=()): """Return list of value labels, filtered by either or both type and unit. An empty sequence for either argument will match as long as the other argument matches any values.""" if not (isinstance(types, Sequence) and isinstance(units, Sequence)): raise TypeError('types/units must be a sequence') empty = frozenset() if types: type_names = set() for type_ in types: type_names |= self.by_type.get(type_, empty) if not units: return type_names if units: unit_names = set() for unit in units: unit_names |= self.by_unit.get(unit, empty) if not types: return unit_names return (type_names & unit_names) if (types and units) else empty
[ "def", "filter_by", "(", "self", ",", "types", "=", "(", ")", ",", "units", "=", "(", ")", ")", ":", "if", "not", "(", "isinstance", "(", "types", ",", "Sequence", ")", "and", "isinstance", "(", "units", ",", "Sequence", ")", ")", ":", "raise", "...
Return list of value labels, filtered by either or both type and unit. An empty sequence for either argument will match as long as the other argument matches any values.
[ "Return", "list", "of", "value", "labels", "filtered", "by", "either", "or", "both", "type", "and", "unit", ".", "An", "empty", "sequence", "for", "either", "argument", "will", "match", "as", "long", "as", "the", "other", "argument", "matches", "any", "val...
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/PointValueHelper.py#L99-L120
train
38,254
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/PointValueHelper.py
PointDataObjectHandler.__get_values
def __get_values(self): """Retrieve value information either via describe or point value listing. MUST be called within lock.""" values = [] if self.__remote: description = self.__client.describe(self.__point) if description is not None: if description['type'] != 'Point': raise IOTUnknown('%s is not a Point' % self.__point) values = description['meta']['values'] else: limit = 100 offset = 0 while True: new = self.__point.list(limit=limit, offset=offset) values += new if len(new) < limit: break offset += limit # Unlike for describe, value comments are keyed by language here, so unwrap to have same layout as for # describe call (default language only, if available). lang = self.__client.default_lang for value in values: value['comment'] = value['comment'].get(lang, None) if value['comment'] else None return values
python
def __get_values(self): """Retrieve value information either via describe or point value listing. MUST be called within lock.""" values = [] if self.__remote: description = self.__client.describe(self.__point) if description is not None: if description['type'] != 'Point': raise IOTUnknown('%s is not a Point' % self.__point) values = description['meta']['values'] else: limit = 100 offset = 0 while True: new = self.__point.list(limit=limit, offset=offset) values += new if len(new) < limit: break offset += limit # Unlike for describe, value comments are keyed by language here, so unwrap to have same layout as for # describe call (default language only, if available). lang = self.__client.default_lang for value in values: value['comment'] = value['comment'].get(lang, None) if value['comment'] else None return values
[ "def", "__get_values", "(", "self", ")", ":", "values", "=", "[", "]", "if", "self", ".", "__remote", ":", "description", "=", "self", ".", "__client", ".", "describe", "(", "self", ".", "__point", ")", "if", "description", "is", "not", "None", ":", ...
Retrieve value information either via describe or point value listing. MUST be called within lock.
[ "Retrieve", "value", "information", "either", "via", "describe", "or", "point", "value", "listing", ".", "MUST", "be", "called", "within", "lock", "." ]
893e8582ad1dacfe32dfc0ee89452bbd6f57d28d
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/PointValueHelper.py#L225-L251
train
38,255
HumanCellAtlas/dcplib
dcplib/s3_multipart.py
get_s3_multipart_chunk_size
def get_s3_multipart_chunk_size(filesize): """Returns the chunk size of the S3 multipart object, given a file's size.""" if filesize <= AWS_MAX_MULTIPART_COUNT * AWS_MIN_CHUNK_SIZE: return AWS_MIN_CHUNK_SIZE else: div = filesize // AWS_MAX_MULTIPART_COUNT if div * AWS_MAX_MULTIPART_COUNT < filesize: div += 1 return ((div + MiB - 1) // MiB) * MiB
python
def get_s3_multipart_chunk_size(filesize): """Returns the chunk size of the S3 multipart object, given a file's size.""" if filesize <= AWS_MAX_MULTIPART_COUNT * AWS_MIN_CHUNK_SIZE: return AWS_MIN_CHUNK_SIZE else: div = filesize // AWS_MAX_MULTIPART_COUNT if div * AWS_MAX_MULTIPART_COUNT < filesize: div += 1 return ((div + MiB - 1) // MiB) * MiB
[ "def", "get_s3_multipart_chunk_size", "(", "filesize", ")", ":", "if", "filesize", "<=", "AWS_MAX_MULTIPART_COUNT", "*", "AWS_MIN_CHUNK_SIZE", ":", "return", "AWS_MIN_CHUNK_SIZE", "else", ":", "div", "=", "filesize", "//", "AWS_MAX_MULTIPART_COUNT", "if", "div", "*", ...
Returns the chunk size of the S3 multipart object, given a file's size.
[ "Returns", "the", "chunk", "size", "of", "the", "S3", "multipart", "object", "given", "a", "file", "s", "size", "." ]
23614d39914a6b5fc278e732030674a2956a0767
https://github.com/HumanCellAtlas/dcplib/blob/23614d39914a6b5fc278e732030674a2956a0767/dcplib/s3_multipart.py#L14-L22
train
38,256
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.set_ext_param
def set_ext_param(self, ext_key, param_key, val): ''' Set the provided parameter in a set of extension parameters. ''' if not self.extensions[ext_key]: self.extensions[ext_key] = defaultdict(lambda: None) self.extensions[ext_key][param_key] = val
python
def set_ext_param(self, ext_key, param_key, val): ''' Set the provided parameter in a set of extension parameters. ''' if not self.extensions[ext_key]: self.extensions[ext_key] = defaultdict(lambda: None) self.extensions[ext_key][param_key] = val
[ "def", "set_ext_param", "(", "self", ",", "ext_key", ",", "param_key", ",", "val", ")", ":", "if", "not", "self", ".", "extensions", "[", "ext_key", "]", ":", "self", ".", "extensions", "[", "ext_key", "]", "=", "defaultdict", "(", "lambda", ":", "None...
Set the provided parameter in a set of extension parameters.
[ "Set", "the", "provided", "parameter", "in", "a", "set", "of", "extension", "parameters", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L90-L96
train
38,257
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.get_ext_param
def get_ext_param(self, ext_key, param_key): ''' Get specific param in set of provided extension parameters. ''' return self.extensions[ext_key][param_key] if self.extensions[ext_key]\ else None
python
def get_ext_param(self, ext_key, param_key): ''' Get specific param in set of provided extension parameters. ''' return self.extensions[ext_key][param_key] if self.extensions[ext_key]\ else None
[ "def", "get_ext_param", "(", "self", ",", "ext_key", ",", "param_key", ")", ":", "return", "self", ".", "extensions", "[", "ext_key", "]", "[", "param_key", "]", "if", "self", ".", "extensions", "[", "ext_key", "]", "else", "None" ]
Get specific param in set of provided extension parameters.
[ "Get", "specific", "param", "in", "set", "of", "provided", "extension", "parameters", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L98-L103
train
38,258
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.process_xml
def process_xml(self, xml): ''' Parse tool configuration data out of the Common Cartridge LTI link XML. ''' root = objectify.fromstring(xml, parser = etree.XMLParser()) # Parse all children of the root node for child in root.getchildren(): if 'title' in child.tag: self.title = child.text if 'description' in child.tag: self.description = child.text if 'secure_launch_url' in child.tag: self.secure_launch_url = child.text elif 'launch_url' in child.tag: self.launch_url = child.text if 'icon' in child.tag: self.icon = child.text if 'secure_icon' in child.tag: self.secure_icon = child.text if 'cartridge_bundle' in child.tag: self.cartridge_bundle = child.attrib['identifierref'] if 'catridge_icon' in child.tag: self.cartridge_icon = child.atrib['identifierref'] if 'vendor' in child.tag: # Parse vendor tag for v_child in child.getchildren(): if 'code' in v_child.tag: self.vendor_code = v_child.text if 'description' in v_child.tag: self.vendor_description = v_child.text if 'name' in v_child.tag: self.vendor_name = v_child.text if 'url' in v_child.tag: self.vendor_url = v_child.text if 'contact' in v_child.tag: # Parse contact tag for email and name for c_child in v_child: if 'name' in c_child.tag: self.vendor_contact_name = c_child.text if 'email' in c_child.tag: self.vendor_contact_email = c_child.text if 'custom' in child.tag: # Parse custom tags for custom_child in child.getchildren(): self.custom_params[custom_child.attrib['name']] =\ custom_child.text if 'extensions' in child.tag: platform = child.attrib['platform'] properties = {} # Parse extension tags for ext_child in child.getchildren(): if 'property' in ext_child.tag: properties[ext_child.attrib['name']] = ext_child.text elif 'options' in ext_child.tag: opt_name = ext_child.attrib['name'] options = {} for option_child in ext_child.getchildren(): options[option_child.attrib['name']] =\ option_child.text properties[opt_name] = options self.set_ext_params(platform, properties)
python
def process_xml(self, xml): ''' Parse tool configuration data out of the Common Cartridge LTI link XML. ''' root = objectify.fromstring(xml, parser = etree.XMLParser()) # Parse all children of the root node for child in root.getchildren(): if 'title' in child.tag: self.title = child.text if 'description' in child.tag: self.description = child.text if 'secure_launch_url' in child.tag: self.secure_launch_url = child.text elif 'launch_url' in child.tag: self.launch_url = child.text if 'icon' in child.tag: self.icon = child.text if 'secure_icon' in child.tag: self.secure_icon = child.text if 'cartridge_bundle' in child.tag: self.cartridge_bundle = child.attrib['identifierref'] if 'catridge_icon' in child.tag: self.cartridge_icon = child.atrib['identifierref'] if 'vendor' in child.tag: # Parse vendor tag for v_child in child.getchildren(): if 'code' in v_child.tag: self.vendor_code = v_child.text if 'description' in v_child.tag: self.vendor_description = v_child.text if 'name' in v_child.tag: self.vendor_name = v_child.text if 'url' in v_child.tag: self.vendor_url = v_child.text if 'contact' in v_child.tag: # Parse contact tag for email and name for c_child in v_child: if 'name' in c_child.tag: self.vendor_contact_name = c_child.text if 'email' in c_child.tag: self.vendor_contact_email = c_child.text if 'custom' in child.tag: # Parse custom tags for custom_child in child.getchildren(): self.custom_params[custom_child.attrib['name']] =\ custom_child.text if 'extensions' in child.tag: platform = child.attrib['platform'] properties = {} # Parse extension tags for ext_child in child.getchildren(): if 'property' in ext_child.tag: properties[ext_child.attrib['name']] = ext_child.text elif 'options' in ext_child.tag: opt_name = ext_child.attrib['name'] options = {} for option_child in ext_child.getchildren(): options[option_child.attrib['name']] =\ option_child.text properties[opt_name] = options self.set_ext_params(platform, properties)
[ "def", "process_xml", "(", "self", ",", "xml", ")", ":", "root", "=", "objectify", ".", "fromstring", "(", "xml", ",", "parser", "=", "etree", ".", "XMLParser", "(", ")", ")", "# Parse all children of the root node", "for", "child", "in", "root", ".", "get...
Parse tool configuration data out of the Common Cartridge LTI link XML.
[ "Parse", "tool", "configuration", "data", "out", "of", "the", "Common", "Cartridge", "LTI", "link", "XML", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L105-L170
train
38,259
tophatmonocle/ims_lti_py
ims_lti_py/tool_config.py
ToolConfig.to_xml
def to_xml(self, opts = defaultdict(lambda: None)): ''' Generate XML from the current settings. ''' if not self.launch_url or not self.secure_launch_url: raise InvalidLTIConfigError('Invalid LTI configuration') root = etree.Element('cartridge_basiclti_link', attrib = { '{%s}%s' %(NSMAP['xsi'], 'schemaLocation'): 'http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0p1.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd', 'xmlns': 'http://www.imsglobal.org/xsd/imslticc_v1p0' }, nsmap = NSMAP) for key in ['title', 'description', 'launch_url', 'secure_launch_url']: option = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], key)) option.text = getattr(self, key) vendor_keys = ['name', 'code', 'description', 'url'] if any('vendor_' + key for key in vendor_keys) or\ self.vendor_contact_email: vendor_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'vendor')) for key in vendor_keys: if getattr(self, 'vendor_' + key) != None: v_node = etree.SubElement(vendor_node, '{%s}%s' %(NSMAP['lticp'], key)) v_node.text = getattr(self, 'vendor_' + key) if getattr(self, 'vendor_contact_email'): v_node = etree.SubElement(vendor_node, '{%s}%s' %(NSMAP['lticp'], 'contact')) c_name = etree.SubElement(v_node, '{%s}%s' %(NSMAP['lticp'], 'name')) c_name.text = self.vendor_contact_name c_email = etree.SubElement(v_node, '{%s}%s' %(NSMAP['lticp'], 'email')) c_email.text = self.vendor_contact_email # Custom params if len(self.custom_params) != 0: custom_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'custom')) for (key, val) in sorted(self.custom_params.items()): c_node = etree.SubElement(custom_node, '{%s}%s' %(NSMAP['lticm'], 'property')) c_node.set('name', key) c_node.text = val # Extension params if len(self.extensions) != 0: for (key, params) in sorted(self.extensions.items()): extension_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'extensions'), platform = key) self.recursive_options(extension_node,params) if getattr(self, 'cartridge_bundle'): identifierref = etree.SubElement(root, 'cartridge_bundle', identifierref = self.cartridge_bundle) if getattr(self, 'cartridge_icon'): identifierref = etree.SubElement(root, 'cartridge_icon', identifierref = self.cartridge_icon) return '<?xml version="1.0" encoding="UTF-8"?>' + etree.tostring(root)
python
def to_xml(self, opts = defaultdict(lambda: None)): ''' Generate XML from the current settings. ''' if not self.launch_url or not self.secure_launch_url: raise InvalidLTIConfigError('Invalid LTI configuration') root = etree.Element('cartridge_basiclti_link', attrib = { '{%s}%s' %(NSMAP['xsi'], 'schemaLocation'): 'http://www.imsglobal.org/xsd/imslticc_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticc_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0p1.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd', 'xmlns': 'http://www.imsglobal.org/xsd/imslticc_v1p0' }, nsmap = NSMAP) for key in ['title', 'description', 'launch_url', 'secure_launch_url']: option = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], key)) option.text = getattr(self, key) vendor_keys = ['name', 'code', 'description', 'url'] if any('vendor_' + key for key in vendor_keys) or\ self.vendor_contact_email: vendor_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'vendor')) for key in vendor_keys: if getattr(self, 'vendor_' + key) != None: v_node = etree.SubElement(vendor_node, '{%s}%s' %(NSMAP['lticp'], key)) v_node.text = getattr(self, 'vendor_' + key) if getattr(self, 'vendor_contact_email'): v_node = etree.SubElement(vendor_node, '{%s}%s' %(NSMAP['lticp'], 'contact')) c_name = etree.SubElement(v_node, '{%s}%s' %(NSMAP['lticp'], 'name')) c_name.text = self.vendor_contact_name c_email = etree.SubElement(v_node, '{%s}%s' %(NSMAP['lticp'], 'email')) c_email.text = self.vendor_contact_email # Custom params if len(self.custom_params) != 0: custom_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'custom')) for (key, val) in sorted(self.custom_params.items()): c_node = etree.SubElement(custom_node, '{%s}%s' %(NSMAP['lticm'], 'property')) c_node.set('name', key) c_node.text = val # Extension params if len(self.extensions) != 0: for (key, params) in sorted(self.extensions.items()): extension_node = etree.SubElement(root, '{%s}%s' %(NSMAP['blti'], 'extensions'), platform = key) self.recursive_options(extension_node,params) if getattr(self, 'cartridge_bundle'): identifierref = etree.SubElement(root, 'cartridge_bundle', identifierref = self.cartridge_bundle) if getattr(self, 'cartridge_icon'): identifierref = etree.SubElement(root, 'cartridge_icon', identifierref = self.cartridge_icon) return '<?xml version="1.0" encoding="UTF-8"?>' + etree.tostring(root)
[ "def", "to_xml", "(", "self", ",", "opts", "=", "defaultdict", "(", "lambda", ":", "None", ")", ")", ":", "if", "not", "self", ".", "launch_url", "or", "not", "self", ".", "secure_launch_url", ":", "raise", "InvalidLTIConfigError", "(", "'Invalid LTI configu...
Generate XML from the current settings.
[ "Generate", "XML", "from", "the", "current", "settings", "." ]
979244d83c2e6420d2c1941f58e52f641c56ad12
https://github.com/tophatmonocle/ims_lti_py/blob/979244d83c2e6420d2c1941f58e52f641c56ad12/ims_lti_py/tool_config.py#L185-L247
train
38,260
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.destroy
def destroy(self): """ Custom destructor that deletes the fragment and removes itself from the adapter it was added to. """ #: Destroy fragment fragment = self.fragment if fragment: #: Stop listening fragment.setFragmentListener(None) #: Cleanup from fragment if self.adapter is not None: self.adapter.removeFragment(self.fragment) del self.fragment super(AndroidFragment, self).destroy()
python
def destroy(self): """ Custom destructor that deletes the fragment and removes itself from the adapter it was added to. """ #: Destroy fragment fragment = self.fragment if fragment: #: Stop listening fragment.setFragmentListener(None) #: Cleanup from fragment if self.adapter is not None: self.adapter.removeFragment(self.fragment) del self.fragment super(AndroidFragment, self).destroy()
[ "def", "destroy", "(", "self", ")", ":", "#: Destroy fragment", "fragment", "=", "self", ".", "fragment", "if", "fragment", ":", "#: Stop listening", "fragment", ".", "setFragmentListener", "(", "None", ")", "#: Cleanup from fragment", "if", "self", ".", "adapter"...
Custom destructor that deletes the fragment and removes itself from the adapter it was added to.
[ "Custom", "destructor", "that", "deletes", "the", "fragment", "and", "removes", "itself", "from", "the", "adapter", "it", "was", "added", "to", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L96-L112
train
38,261
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.on_create_view
def on_create_view(self): """ Trigger the click """ d = self.declaration changed = not d.condition if changed: d.condition = True view = self.get_view() if changed: self.ready.set_result(True) return view
python
def on_create_view(self): """ Trigger the click """ d = self.declaration changed = not d.condition if changed: d.condition = True view = self.get_view() if changed: self.ready.set_result(True) return view
[ "def", "on_create_view", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "changed", "=", "not", "d", ".", "condition", "if", "changed", ":", "d", ".", "condition", "=", "True", "view", "=", "self", ".", "get_view", "(", ")", "if", "chang...
Trigger the click
[ "Trigger", "the", "click" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L117-L131
train
38,262
codelv/enaml-native
src/enamlnative/android/android_fragment.py
AndroidFragment.get_view
def get_view(self): """ Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later. """ d = self.declaration if d.cached and self.widget: return self.widget if d.defer_loading: self.widget = FrameLayout(self.get_context()) app = self.get_context() app.deferred_call( lambda: self.widget.addView(self.load_view(), 0)) else: self.widget = self.load_view() return self.widget
python
def get_view(self): """ Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later. """ d = self.declaration if d.cached and self.widget: return self.widget if d.defer_loading: self.widget = FrameLayout(self.get_context()) app = self.get_context() app.deferred_call( lambda: self.widget.addView(self.load_view(), 0)) else: self.widget = self.load_view() return self.widget
[ "def", "get_view", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "cached", "and", "self", ".", "widget", ":", "return", "self", ".", "widget", "if", "d", ".", "defer_loading", ":", "self", ".", "widget", "=", "FrameLayo...
Get the page to display. If a view has already been created and is cached, use that otherwise initialize the view and proxy. If defer loading is used, wrap the view in a FrameLayout and defer add view until later.
[ "Get", "the", "page", "to", "display", ".", "If", "a", "view", "has", "already", "been", "created", "and", "is", "cached", "use", "that", "otherwise", "initialize", "the", "view", "and", "proxy", ".", "If", "defer", "loading", "is", "used", "wrap", "the"...
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_fragment.py#L150-L167
train
38,263
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
engine
def engine(func): """Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it does not return a `.Future` and the ``callback`` argument is not treated specially. In most cases, functions decorated with `engine` should take a ``callback`` argument and invoke it with their result when they are finished. One notable exception is the `~tornado.web.RequestHandler` :ref:`HTTP verb methods <verbs>`, which use ``self.finish()`` in place of a callback argument. """ func = _make_coroutine_wrapper(func, replace_callback=False) @functools.wraps(func) def wrapper(*args, **kwargs): future = func(*args, **kwargs) def final_callback(future): if future.result() is not None: raise ReturnValueIgnoredError( "@gen.engine functions cannot return values: %r" % (future.result(),)) # The engine interface doesn't give us any way to return # errors but to raise them into the stack context. # Save the stack context here to use when the Future has resolved. future.add_done_callback(stack_context.wrap(final_callback)) return wrapper
python
def engine(func): """Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it does not return a `.Future` and the ``callback`` argument is not treated specially. In most cases, functions decorated with `engine` should take a ``callback`` argument and invoke it with their result when they are finished. One notable exception is the `~tornado.web.RequestHandler` :ref:`HTTP verb methods <verbs>`, which use ``self.finish()`` in place of a callback argument. """ func = _make_coroutine_wrapper(func, replace_callback=False) @functools.wraps(func) def wrapper(*args, **kwargs): future = func(*args, **kwargs) def final_callback(future): if future.result() is not None: raise ReturnValueIgnoredError( "@gen.engine functions cannot return values: %r" % (future.result(),)) # The engine interface doesn't give us any way to return # errors but to raise them into the stack context. # Save the stack context here to use when the Future has resolved. future.add_done_callback(stack_context.wrap(final_callback)) return wrapper
[ "def", "engine", "(", "func", ")", ":", "func", "=", "_make_coroutine_wrapper", "(", "func", ",", "replace_callback", "=", "False", ")", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")",...
Callback-oriented decorator for asynchronous generators. This is an older interface; for new code that does not need to be compatible with versions of Tornado older than 3.0 the `coroutine` decorator is recommended instead. This decorator is similar to `coroutine`, except it does not return a `.Future` and the ``callback`` argument is not treated specially. In most cases, functions decorated with `engine` should take a ``callback`` argument and invoke it with their result when they are finished. One notable exception is the `~tornado.web.RequestHandler` :ref:`HTTP verb methods <verbs>`, which use ``self.finish()`` in place of a callback argument.
[ "Callback", "-", "oriented", "decorator", "for", "asynchronous", "generators", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L174-L206
train
38,264
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Task
def Task(func, *args, **kwargs): """Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yield expression. .. versionchanged:: 4.0 ``gen.Task`` is now a function that returns a `.Future`, instead of a subclass of `YieldPoint`. It still behaves the same way when yielded. """ future = Future() def handle_exception(typ, value, tb): if future.done(): return False future.set_exc_info((typ, value, tb)) return True def set_result(result): if future.done(): return future.set_result(result) with stack_context.ExceptionStackContext(handle_exception): func(*args, callback=_argument_adapter(set_result), **kwargs) return future
python
def Task(func, *args, **kwargs): """Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yield expression. .. versionchanged:: 4.0 ``gen.Task`` is now a function that returns a `.Future`, instead of a subclass of `YieldPoint`. It still behaves the same way when yielded. """ future = Future() def handle_exception(typ, value, tb): if future.done(): return False future.set_exc_info((typ, value, tb)) return True def set_result(result): if future.done(): return future.set_result(result) with stack_context.ExceptionStackContext(handle_exception): func(*args, callback=_argument_adapter(set_result), **kwargs) return future
[ "def", "Task", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "future", "=", "Future", "(", ")", "def", "handle_exception", "(", "typ", ",", "value", ",", "tb", ")", ":", "if", "future", ".", "done", "(", ")", ":", "return", ...
Adapts a callback-based asynchronous function for use in coroutines. Takes a function (and optional additional arguments) and runs it with those arguments plus a ``callback`` keyword argument. The argument passed to the callback is returned as the result of the yield expression. .. versionchanged:: 4.0 ``gen.Task`` is now a function that returns a `.Future`, instead of a subclass of `YieldPoint`. It still behaves the same way when yielded.
[ "Adapts", "a", "callback", "-", "based", "asynchronous", "function", "for", "use", "in", "coroutines", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L608-L634
train
38,265
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
_contains_yieldpoint
def _contains_yieldpoint(children): """Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`. """ if isinstance(children, dict): return any(isinstance(i, YieldPoint) for i in children.values()) if isinstance(children, list): return any(isinstance(i, YieldPoint) for i in children) return False
python
def _contains_yieldpoint(children): """Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`. """ if isinstance(children, dict): return any(isinstance(i, YieldPoint) for i in children.values()) if isinstance(children, list): return any(isinstance(i, YieldPoint) for i in children) return False
[ "def", "_contains_yieldpoint", "(", "children", ")", ":", "if", "isinstance", "(", "children", ",", "dict", ")", ":", "return", "any", "(", "isinstance", "(", "i", ",", "YieldPoint", ")", "for", "i", "in", "children", ".", "values", "(", ")", ")", "if"...
Returns True if ``children`` contains any YieldPoints. ``children`` may be a dict or a list, as used by `MultiYieldPoint` and `multi_future`.
[ "Returns", "True", "if", "children", "contains", "any", "YieldPoints", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L678-L688
train
38,266
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
_argument_adapter
def _argument_adapter(callback): """Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object. """ def wrapper(*args, **kwargs): if kwargs or len(args) > 1: callback(Arguments(args, kwargs)) elif args: callback(args[0]) else: callback(None) return wrapper
python
def _argument_adapter(callback): """Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object. """ def wrapper(*args, **kwargs): if kwargs or len(args) > 1: callback(Arguments(args, kwargs)) elif args: callback(args[0]) else: callback(None) return wrapper
[ "def", "_argument_adapter", "(", "callback", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", "or", "len", "(", "args", ")", ">", "1", ":", "callback", "(", "Arguments", "(", "args", ",", "kwargs", ")...
Returns a function that when invoked runs ``callback`` with one arg. If the function returned by this function is called with exactly one argument, that argument is passed to ``callback``. Otherwise the args tuple and kwargs dict are wrapped in an `Arguments` object.
[ "Returns", "a", "function", "that", "when", "invoked", "runs", "callback", "with", "one", "arg", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1222-L1236
train
38,267
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
WaitIterator.done
def done(self): """Returns True if this iterator has no more results.""" if self._finished or self._unfinished: return False # Clear the 'current' values when iteration is done. self.current_index = self.current_future = None return True
python
def done(self): """Returns True if this iterator has no more results.""" if self._finished or self._unfinished: return False # Clear the 'current' values when iteration is done. self.current_index = self.current_future = None return True
[ "def", "done", "(", "self", ")", ":", "if", "self", ".", "_finished", "or", "self", ".", "_unfinished", ":", "return", "False", "# Clear the 'current' values when iteration is done.", "self", ".", "current_index", "=", "self", ".", "current_future", "=", "None", ...
Returns True if this iterator has no more results.
[ "Returns", "True", "if", "this", "iterator", "has", "no", "more", "results", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L455-L461
train
38,268
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
WaitIterator._return_result
def _return_result(self, done): """Called set the returned future's state that of the future we yielded, and set the current future for the iterator. """ chain_future(done, self._running_future) self.current_future = done self.current_index = self._unfinished.pop(done)
python
def _return_result(self, done): """Called set the returned future's state that of the future we yielded, and set the current future for the iterator. """ chain_future(done, self._running_future) self.current_future = done self.current_index = self._unfinished.pop(done)
[ "def", "_return_result", "(", "self", ",", "done", ")", ":", "chain_future", "(", "done", ",", "self", ".", "_running_future", ")", "self", ".", "current_future", "=", "done", "self", ".", "current_index", "=", "self", ".", "_unfinished", ".", "pop", "(", ...
Called set the returned future's state that of the future we yielded, and set the current future for the iterator.
[ "Called", "set", "the", "returned", "future", "s", "state", "that", "of", "the", "future", "we", "yielded", "and", "set", "the", "current", "future", "for", "the", "iterator", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L482-L489
train
38,269
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.register_callback
def register_callback(self, key): """Adds ``key`` to the list of callbacks.""" if self.pending_callbacks is None: # Lazily initialize the old-style YieldPoint data structures. self.pending_callbacks = set() self.results = {} if key in self.pending_callbacks: raise KeyReuseError("key %r is already pending" % (key,)) self.pending_callbacks.add(key)
python
def register_callback(self, key): """Adds ``key`` to the list of callbacks.""" if self.pending_callbacks is None: # Lazily initialize the old-style YieldPoint data structures. self.pending_callbacks = set() self.results = {} if key in self.pending_callbacks: raise KeyReuseError("key %r is already pending" % (key,)) self.pending_callbacks.add(key)
[ "def", "register_callback", "(", "self", ",", "key", ")", ":", "if", "self", ".", "pending_callbacks", "is", "None", ":", "# Lazily initialize the old-style YieldPoint data structures.", "self", ".", "pending_callbacks", "=", "set", "(", ")", "self", ".", "results",...
Adds ``key`` to the list of callbacks.
[ "Adds", "key", "to", "the", "list", "of", "callbacks", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1047-L1055
train
38,270
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.is_ready
def is_ready(self, key): """Returns true if a result is available for ``key``.""" if self.pending_callbacks is None or key not in self.pending_callbacks: raise UnknownKeyError("key %r is not pending" % (key,)) return key in self.results
python
def is_ready(self, key): """Returns true if a result is available for ``key``.""" if self.pending_callbacks is None or key not in self.pending_callbacks: raise UnknownKeyError("key %r is not pending" % (key,)) return key in self.results
[ "def", "is_ready", "(", "self", ",", "key", ")", ":", "if", "self", ".", "pending_callbacks", "is", "None", "or", "key", "not", "in", "self", ".", "pending_callbacks", ":", "raise", "UnknownKeyError", "(", "\"key %r is not pending\"", "%", "(", "key", ",", ...
Returns true if a result is available for ``key``.
[ "Returns", "true", "if", "a", "result", "is", "available", "for", "key", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1057-L1061
train
38,271
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.set_result
def set_result(self, key, result): """Sets the result for ``key`` and attempts to resume the generator.""" self.results[key] = result if self.yield_point is not None and self.yield_point.is_ready(): try: self.future.set_result(self.yield_point.get_result()) except: self.future.set_exc_info(sys.exc_info()) self.yield_point = None self.run()
python
def set_result(self, key, result): """Sets the result for ``key`` and attempts to resume the generator.""" self.results[key] = result if self.yield_point is not None and self.yield_point.is_ready(): try: self.future.set_result(self.yield_point.get_result()) except: self.future.set_exc_info(sys.exc_info()) self.yield_point = None self.run()
[ "def", "set_result", "(", "self", ",", "key", ",", "result", ")", ":", "self", ".", "results", "[", "key", "]", "=", "result", "if", "self", ".", "yield_point", "is", "not", "None", "and", "self", ".", "yield_point", ".", "is_ready", "(", ")", ":", ...
Sets the result for ``key`` and attempts to resume the generator.
[ "Sets", "the", "result", "for", "key", "and", "attempts", "to", "resume", "the", "generator", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1063-L1072
train
38,272
codelv/enaml-native
src/enamlnative/core/eventloop/gen.py
Runner.pop_result
def pop_result(self, key): """Returns the result for ``key`` and unregisters it.""" self.pending_callbacks.remove(key) return self.results.pop(key)
python
def pop_result(self, key): """Returns the result for ``key`` and unregisters it.""" self.pending_callbacks.remove(key) return self.results.pop(key)
[ "def", "pop_result", "(", "self", ",", "key", ")", ":", "self", ".", "pending_callbacks", ".", "remove", "(", "key", ")", "return", "self", ".", "results", ".", "pop", "(", "key", ")" ]
Returns the result for ``key`` and unregisters it.
[ "Returns", "the", "result", "for", "key", "and", "unregisters", "it", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/eventloop/gen.py#L1074-L1077
train
38,273
codelv/enaml-native
src/enamlnative/core/dev.py
TornadoDevClient.write_message
def write_message(self, data, binary=False): """ Write a message to the client """ self.connection.write_message(data, binary)
python
def write_message(self, data, binary=False): """ Write a message to the client """ self.connection.write_message(data, binary)
[ "def", "write_message", "(", "self", ",", "data", ",", "binary", "=", "False", ")", ":", "self", ".", "connection", ".", "write_message", "(", "data", ",", "binary", ")" ]
Write a message to the client
[ "Write", "a", "message", "to", "the", "client" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L361-L363
train
38,274
codelv/enaml-native
src/enamlnative/core/dev.py
DevServer.render_files
def render_files(self, root=None): """ Render the file path as accordions """ if root is None: tmp = os.environ.get('TMP') root = sys.path[1 if tmp and tmp in sys.path else 0] items = [] for filename in os.listdir(root): # for subdirname in dirnames: # path = os.path.join(dirname, subdirname) # items.append(FOLDER_TMPL.format( # name=subdirname, # id=path, # items=self.render_files(path) # )) #for filename in filenames: f,ext = os.path.splitext(filename) if ext in ['.py', '.enaml']: items.append(FILE_TMPL.format( name=filename, id=filename )) return "".join(items)
python
def render_files(self, root=None): """ Render the file path as accordions """ if root is None: tmp = os.environ.get('TMP') root = sys.path[1 if tmp and tmp in sys.path else 0] items = [] for filename in os.listdir(root): # for subdirname in dirnames: # path = os.path.join(dirname, subdirname) # items.append(FOLDER_TMPL.format( # name=subdirname, # id=path, # items=self.render_files(path) # )) #for filename in filenames: f,ext = os.path.splitext(filename) if ext in ['.py', '.enaml']: items.append(FILE_TMPL.format( name=filename, id=filename )) return "".join(items)
[ "def", "render_files", "(", "self", ",", "root", "=", "None", ")", ":", "if", "root", "is", "None", ":", "tmp", "=", "os", ".", "environ", ".", "get", "(", "'TMP'", ")", "root", "=", "sys", ".", "path", "[", "1", "if", "tmp", "and", "tmp", "in"...
Render the file path as accordions
[ "Render", "the", "file", "path", "as", "accordions" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L491-L514
train
38,275
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.start
def start(self): """ Start the dev session. Attempt to use tornado first, then try twisted """ print("Starting debug client cwd: {}".format(os.getcwd())) print("Sys path: {}".format(sys.path)) #: Initialize the hotswapper self.hotswap = Hotswapper(debug=False) if self.mode == 'server': self.server.start(self) else: self.client.start(self)
python
def start(self): """ Start the dev session. Attempt to use tornado first, then try twisted """ print("Starting debug client cwd: {}".format(os.getcwd())) print("Sys path: {}".format(sys.path)) #: Initialize the hotswapper self.hotswap = Hotswapper(debug=False) if self.mode == 'server': self.server.start(self) else: self.client.start(self)
[ "def", "start", "(", "self", ")", ":", "print", "(", "\"Starting debug client cwd: {}\"", ".", "format", "(", "os", ".", "getcwd", "(", ")", ")", ")", "print", "(", "\"Sys path: {}\"", ".", "format", "(", "sys", ".", "path", ")", ")", "#: Initialize the ho...
Start the dev session. Attempt to use tornado first, then try twisted
[ "Start", "the", "dev", "session", ".", "Attempt", "to", "use", "tornado", "first", "then", "try", "twisted" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L782-L796
train
38,276
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession._default_url
def _default_url(self): """ Websocket URL to connect to and listen for reload requests """ host = 'localhost' if self.mode == 'remote' else self.host return 'ws://{}:{}/dev'.format(host, self.port)
python
def _default_url(self): """ Websocket URL to connect to and listen for reload requests """ host = 'localhost' if self.mode == 'remote' else self.host return 'ws://{}:{}/dev'.format(host, self.port)
[ "def", "_default_url", "(", "self", ")", ":", "host", "=", "'localhost'", "if", "self", ".", "mode", "==", "'remote'", "else", "self", ".", "host", "return", "'ws://{}:{}/dev'", ".", "format", "(", "host", ",", "self", ".", "port", ")" ]
Websocket URL to connect to and listen for reload requests
[ "Websocket", "URL", "to", "connect", "to", "and", "listen", "for", "reload", "requests" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L810-L813
train
38,277
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.write_message
def write_message(self, data, binary=False): """ Write a message to the active client """ self.client.write_message(data, binary=binary)
python
def write_message(self, data, binary=False): """ Write a message to the active client """ self.client.write_message(data, binary=binary)
[ "def", "write_message", "(", "self", ",", "data", ",", "binary", "=", "False", ")", ":", "self", ".", "client", ".", "write_message", "(", "data", ",", "binary", "=", "binary", ")" ]
Write a message to the active client
[ "Write", "a", "message", "to", "the", "active", "client" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L843-L847
train
38,278
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.handle_message
def handle_message(self, data): """ When we get a message """ msg = json.loads(data) print("Dev server message: {}".format(msg)) handler_name = 'do_{}'.format(msg['type']) if hasattr(self, handler_name): handler = getattr(self, handler_name) result = handler(msg) return {'ok': True, 'result': result} else: err = "Warning: Unhandled message: {}".format(msg) print(err) return {'ok': False, 'message': err}
python
def handle_message(self, data): """ When we get a message """ msg = json.loads(data) print("Dev server message: {}".format(msg)) handler_name = 'do_{}'.format(msg['type']) if hasattr(self, handler_name): handler = getattr(self, handler_name) result = handler(msg) return {'ok': True, 'result': result} else: err = "Warning: Unhandled message: {}".format(msg) print(err) return {'ok': False, 'message': err}
[ "def", "handle_message", "(", "self", ",", "data", ")", ":", "msg", "=", "json", ".", "loads", "(", "data", ")", "print", "(", "\"Dev server message: {}\"", ".", "format", "(", "msg", ")", ")", "handler_name", "=", "'do_{}'", ".", "format", "(", "msg", ...
When we get a message
[ "When", "we", "get", "a", "message" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L849-L861
train
38,279
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.do_reload
def do_reload(self, msg): """ Called when the dev server wants to reload the view. """ #: TODO: This should use the autorelaoder app = self.app #: Show loading screen try: self.app.widget.showLoading("Reloading... Please wait.", now=True) #self.app.widget.restartPython(now=True) #sys.exit(0) except: #: TODO: Implement for iOS... pass self.save_changed_files(msg) if app.load_view is None: print("Warning: Reloading the view is not implemented. " "Please set `app.load_view` to support this.") return if app.view is not None: try: app.view.destroy() except: pass def wrapped(f): def safe_reload(*args, **kwargs): try: return f(*args, **kwargs) except: #: Display the error app.send_event(Command.ERROR, traceback.format_exc()) return safe_reload app.deferred_call(wrapped(app.load_view), app)
python
def do_reload(self, msg): """ Called when the dev server wants to reload the view. """ #: TODO: This should use the autorelaoder app = self.app #: Show loading screen try: self.app.widget.showLoading("Reloading... Please wait.", now=True) #self.app.widget.restartPython(now=True) #sys.exit(0) except: #: TODO: Implement for iOS... pass self.save_changed_files(msg) if app.load_view is None: print("Warning: Reloading the view is not implemented. " "Please set `app.load_view` to support this.") return if app.view is not None: try: app.view.destroy() except: pass def wrapped(f): def safe_reload(*args, **kwargs): try: return f(*args, **kwargs) except: #: Display the error app.send_event(Command.ERROR, traceback.format_exc()) return safe_reload app.deferred_call(wrapped(app.load_view), app)
[ "def", "do_reload", "(", "self", ",", "msg", ")", ":", "#: TODO: This should use the autorelaoder", "app", "=", "self", ".", "app", "#: Show loading screen", "try", ":", "self", ".", "app", ".", "widget", ".", "showLoading", "(", "\"Reloading... Please wait.\"", "...
Called when the dev server wants to reload the view.
[ "Called", "when", "the", "dev", "server", "wants", "to", "reload", "the", "view", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L866-L900
train
38,280
codelv/enaml-native
src/enamlnative/core/dev.py
DevServerSession.do_hotswap
def do_hotswap(self, msg): """ Attempt to hotswap the code """ #: Show hotswap tooltip try: self.app.widget.showTooltip("Hot swapping...", now=True) except: pass self.save_changed_files(msg) hotswap = self.hotswap app = self.app try: print("Attempting hotswap....") with hotswap.active(): hotswap.update(app.view) except: #: Display the error app.send_event(Command.ERROR, traceback.format_exc())
python
def do_hotswap(self, msg): """ Attempt to hotswap the code """ #: Show hotswap tooltip try: self.app.widget.showTooltip("Hot swapping...", now=True) except: pass self.save_changed_files(msg) hotswap = self.hotswap app = self.app try: print("Attempting hotswap....") with hotswap.active(): hotswap.update(app.view) except: #: Display the error app.send_event(Command.ERROR, traceback.format_exc())
[ "def", "do_hotswap", "(", "self", ",", "msg", ")", ":", "#: Show hotswap tooltip", "try", ":", "self", ".", "app", ".", "widget", ".", "showTooltip", "(", "\"Hot swapping...\"", ",", "now", "=", "True", ")", "except", ":", "pass", "self", ".", "save_change...
Attempt to hotswap the code
[ "Attempt", "to", "hotswap", "the", "code" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/dev.py#L902-L919
train
38,281
codelv/enaml-native
src/enamlnative/android/android_popup_window.py
AndroidPopupWindow.update
def update(self): """ Update the PopupWindow if it is currently showing. This avoids calling update during initialization. """ if not self.showing: return d = self.declaration self.set_show(d.show)
python
def update(self): """ Update the PopupWindow if it is currently showing. This avoids calling update during initialization. """ if not self.showing: return d = self.declaration self.set_show(d.show)
[ "def", "update", "(", "self", ")", ":", "if", "not", "self", ".", "showing", ":", "return", "d", "=", "self", ".", "declaration", "self", ".", "set_show", "(", "d", ".", "show", ")" ]
Update the PopupWindow if it is currently showing. This avoids calling update during initialization.
[ "Update", "the", "PopupWindow", "if", "it", "is", "currently", "showing", ".", "This", "avoids", "calling", "update", "during", "initialization", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_popup_window.py#L144-L151
train
38,282
codelv/enaml-native
src/enamlnative/widgets/fragment.py
Fragment.refresh_items
def refresh_items(self): """ Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this. """ items = [] if self.condition: for nodes, key, f_locals in self.pattern_nodes: with new_scope(key, f_locals): for node in nodes: child = node(None) if isinstance(child, list): items.extend(child) else: items.append(child) for old in self.items: if not old.is_destroyed: old.destroy() #: Insert items into THIS node, NOT the PARENT #if len(items) > 0: # self.parent.insert_children(self, items) self.items = items
python
def refresh_items(self): """ Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this. """ items = [] if self.condition: for nodes, key, f_locals in self.pattern_nodes: with new_scope(key, f_locals): for node in nodes: child = node(None) if isinstance(child, list): items.extend(child) else: items.append(child) for old in self.items: if not old.is_destroyed: old.destroy() #: Insert items into THIS node, NOT the PARENT #if len(items) > 0: # self.parent.insert_children(self, items) self.items = items
[ "def", "refresh_items", "(", "self", ")", ":", "items", "=", "[", "]", "if", "self", ".", "condition", ":", "for", "nodes", ",", "key", ",", "f_locals", "in", "self", ".", "pattern_nodes", ":", "with", "new_scope", "(", "key", ",", "f_locals", ")", "...
Refresh the items of the pattern. This method destroys the old items and creates and initializes the new items. It is overridden to NOT insert the children to the parent. The Fragment adapter handles this.
[ "Refresh", "the", "items", "of", "the", "pattern", ".", "This", "method", "destroys", "the", "old", "items", "and", "creates", "and", "initializes", "the", "new", "items", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/widgets/fragment.py#L49-L76
train
38,283
codelv/enaml-native
src/enamlnative/core/import_hooks.py
ExtensionImporter.load_module
def load_module(self, mod): """ Load the extension using the load_dynamic method. """ try: return sys.modules[mod] except KeyError: pass lib = ExtensionImporter.extension_modules[mod] m = imp.load_dynamic(mod, lib) sys.modules[mod] = m return m
python
def load_module(self, mod): """ Load the extension using the load_dynamic method. """ try: return sys.modules[mod] except KeyError: pass lib = ExtensionImporter.extension_modules[mod] m = imp.load_dynamic(mod, lib) sys.modules[mod] = m return m
[ "def", "load_module", "(", "self", ",", "mod", ")", ":", "try", ":", "return", "sys", ".", "modules", "[", "mod", "]", "except", "KeyError", ":", "pass", "lib", "=", "ExtensionImporter", ".", "extension_modules", "[", "mod", "]", "m", "=", "imp", ".", ...
Load the extension using the load_dynamic method.
[ "Load", "the", "extension", "using", "the", "load_dynamic", "method", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/import_hooks.py#L41-L51
train
38,284
codelv/enaml-native
src/enamlnative/android/android_tab_layout.py
AndroidTabLayout.destroy
def destroy(self): """ Destroy all tabs when destroyed """ super(AndroidTabLayout, self).destroy() if self.tabs: del self.tabs
python
def destroy(self): """ Destroy all tabs when destroyed """ super(AndroidTabLayout, self).destroy() if self.tabs: del self.tabs
[ "def", "destroy", "(", "self", ")", ":", "super", "(", "AndroidTabLayout", ",", "self", ")", ".", "destroy", "(", ")", "if", "self", ".", "tabs", ":", "del", "self", ".", "tabs" ]
Destroy all tabs when destroyed
[ "Destroy", "all", "tabs", "when", "destroyed" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_tab_layout.py#L123-L129
train
38,285
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
update_atom_members
def update_atom_members(old, new): """ Update an atom member """ old_keys = old.members().keys() new_keys = new.members().keys() for key in old_keys: old_obj = getattr(old, key) try: new_obj = getattr(new, key) if old_obj == new_obj: continue except AttributeError: # Remove any obsolete members try: delattr(old, key) except (AttributeError, TypeError): pass continue try: #: Update any changed members #: TODO: We have to somehow know if this was changed by the user or the code! #: and ONLY update if it's due to the code changing! Without this, the entire concept #: is broken and useless... setattr(old, key, getattr(new, key)) except (AttributeError, TypeError): pass # skip non-writable attributes #: Add any new members for key in set(new_keys)-set(old_keys): try: setattr(old, key, getattr(new, key)) except (AttributeError, TypeError): pass
python
def update_atom_members(old, new): """ Update an atom member """ old_keys = old.members().keys() new_keys = new.members().keys() for key in old_keys: old_obj = getattr(old, key) try: new_obj = getattr(new, key) if old_obj == new_obj: continue except AttributeError: # Remove any obsolete members try: delattr(old, key) except (AttributeError, TypeError): pass continue try: #: Update any changed members #: TODO: We have to somehow know if this was changed by the user or the code! #: and ONLY update if it's due to the code changing! Without this, the entire concept #: is broken and useless... setattr(old, key, getattr(new, key)) except (AttributeError, TypeError): pass # skip non-writable attributes #: Add any new members for key in set(new_keys)-set(old_keys): try: setattr(old, key, getattr(new, key)) except (AttributeError, TypeError): pass
[ "def", "update_atom_members", "(", "old", ",", "new", ")", ":", "old_keys", "=", "old", ".", "members", "(", ")", ".", "keys", "(", ")", "new_keys", "=", "new", ".", "members", "(", ")", ".", "keys", "(", ")", "for", "key", "in", "old_keys", ":", ...
Update an atom member
[ "Update", "an", "atom", "member" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L44-L76
train
38,286
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
update_class_by_type
def update_class_by_type(old, new): """ Update declarative classes or fallback on default """ autoreload.update_class(old, new) if isinstance2(old, new, AtomMeta): update_atom_members(old, new)
python
def update_class_by_type(old, new): """ Update declarative classes or fallback on default """ autoreload.update_class(old, new) if isinstance2(old, new, AtomMeta): update_atom_members(old, new)
[ "def", "update_class_by_type", "(", "old", ",", "new", ")", ":", "autoreload", ".", "update_class", "(", "old", ",", "new", ")", "if", "isinstance2", "(", "old", ",", "new", ",", "AtomMeta", ")", ":", "update_atom_members", "(", "old", ",", "new", ")" ]
Update declarative classes or fallback on default
[ "Update", "declarative", "classes", "or", "fallback", "on", "default" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L79-L83
train
38,287
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update
def update(self, old, new=None): """ Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be used to update the existing view. If none is given, one of the same type as old will be created and initialized with no attributes passed. """ #: Create and initialize if not new: new = type(old)() if not new.is_initialized: new.initialize() if self.debug: print("Updating {} with {}".format(old, new)) #: Update attrs, funcs, and bindings of this node self.update_attrs(old, new) self.update_funcs(old, new) self.update_bindings(old, new) #: Update any child pattern nodes before the children self.update_pattern_nodes(old, new) #: Now update any children self.update_children(old, new)
python
def update(self, old, new=None): """ Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be used to update the existing view. If none is given, one of the same type as old will be created and initialized with no attributes passed. """ #: Create and initialize if not new: new = type(old)() if not new.is_initialized: new.initialize() if self.debug: print("Updating {} with {}".format(old, new)) #: Update attrs, funcs, and bindings of this node self.update_attrs(old, new) self.update_funcs(old, new) self.update_bindings(old, new) #: Update any child pattern nodes before the children self.update_pattern_nodes(old, new) #: Now update any children self.update_children(old, new)
[ "def", "update", "(", "self", ",", "old", ",", "new", "=", "None", ")", ":", "#: Create and initialize", "if", "not", "new", ":", "new", "=", "type", "(", "old", ")", "(", ")", "if", "not", "new", ".", "is_initialized", ":", "new", ".", "initialize",...
Update given view declaration with new declaration Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative or None The new or reloaded view instance to that will be used to update the existing view. If none is given, one of the same type as old will be created and initialized with no attributes passed.
[ "Update", "given", "view", "declaration", "with", "new", "declaration" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L129-L159
train
38,288
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.find_best_matching_node
def find_best_matching_node(self, new, old_nodes): """ Find the node that best matches the new node given the old nodes. If no good match exists return `None`. """ name = new.__class__.__name__ #: TODO: We should pick the BEST one from this list #: based on some "matching" criteria (such as matching ref name or params) matches = [c for c in old_nodes if name == c.__class__.__name__] if self.debug: print("Found matches for {}: {} ".format(new, matches)) return matches[0] if matches else None
python
def find_best_matching_node(self, new, old_nodes): """ Find the node that best matches the new node given the old nodes. If no good match exists return `None`. """ name = new.__class__.__name__ #: TODO: We should pick the BEST one from this list #: based on some "matching" criteria (such as matching ref name or params) matches = [c for c in old_nodes if name == c.__class__.__name__] if self.debug: print("Found matches for {}: {} ".format(new, matches)) return matches[0] if matches else None
[ "def", "find_best_matching_node", "(", "self", ",", "new", ",", "old_nodes", ")", ":", "name", "=", "new", ".", "__class__", ".", "__name__", "#: TODO: We should pick the BEST one from this list", "#: based on some \"matching\" criteria (such as matching ref name or params)", "...
Find the node that best matches the new node given the old nodes. If no good match exists return `None`.
[ "Find", "the", "node", "that", "best", "matches", "the", "new", "node", "given", "the", "old", "nodes", ".", "If", "no", "good", "match", "exists", "return", "None", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L161-L172
train
38,289
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update_attrs
def update_attrs(self, old, new): """ Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating """ #: Copy in storage from new node if new._d_storage: old._d_storage = new._d_storage
python
def update_attrs(self, old, new): """ Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating """ #: Copy in storage from new node if new._d_storage: old._d_storage = new._d_storage
[ "def", "update_attrs", "(", "self", ",", "old", ",", "new", ")", ":", "#: Copy in storage from new node", "if", "new", ".", "_d_storage", ":", "old", ".", "_d_storage", "=", "new", ".", "_d_storage" ]
Update any `attr` members. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating
[ "Update", "any", "attr", "members", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L248-L261
train
38,290
codelv/enaml-native
src/enamlnative/core/hotswap/core.py
Hotswapper.update_bindings
def update_bindings(self, old, new): """ Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating """ #: Copy the Expression Engine if new._d_engine: old._d_engine = new._d_engine engine = old._d_engine #: Rerun any read expressions which should trigger #: any dependent writes for k in engine._handlers.keys(): try: engine.update(old, k) except: if self.debug: print(traceback.format_exc()) pass
python
def update_bindings(self, old, new): """ Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating """ #: Copy the Expression Engine if new._d_engine: old._d_engine = new._d_engine engine = old._d_engine #: Rerun any read expressions which should trigger #: any dependent writes for k in engine._handlers.keys(): try: engine.update(old, k) except: if self.debug: print(traceback.format_exc()) pass
[ "def", "update_bindings", "(", "self", ",", "old", ",", "new", ")", ":", "#: Copy the Expression Engine", "if", "new", ".", "_d_engine", ":", "old", ".", "_d_engine", "=", "new", ".", "_d_engine", "engine", "=", "old", ".", "_d_engine", "#: Rerun any read expr...
Update any enaml operator bindings. Parameters ----------- old: Declarative The existing view instance that needs to be updated new: Declarative The new view instance that should be used for updating
[ "Update", "any", "enaml", "operator", "bindings", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/hotswap/core.py#L280-L304
train
38,291
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.init_widget
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties that need to be overridden from defaults thus greatly reducing the number of initialization checks, saving time and memory. If you don't want this to happen override `get_declared_keys` to return an empty list. """ super(AndroidView, self).init_widget() # Initialize the widget by updating only the members that # have read expressions declared. This saves a lot of time and # simplifies widget initialization code for k, v in self.get_declared_items(): handler = getattr(self, 'set_'+k, None) if handler: handler(v)
python
def init_widget(self): """ Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties that need to be overridden from defaults thus greatly reducing the number of initialization checks, saving time and memory. If you don't want this to happen override `get_declared_keys` to return an empty list. """ super(AndroidView, self).init_widget() # Initialize the widget by updating only the members that # have read expressions declared. This saves a lot of time and # simplifies widget initialization code for k, v in self.get_declared_items(): handler = getattr(self, 'set_'+k, None) if handler: handler(v)
[ "def", "init_widget", "(", "self", ")", ":", "super", "(", "AndroidView", ",", "self", ")", ".", "init_widget", "(", ")", "# Initialize the widget by updating only the members that", "# have read expressions declared. This saves a lot of time and", "# simplifies widget initializa...
Initialize the underlying widget. This reads all items declared in the enamldef block for this node and sets only the values that have been specified. All other values will be left as default. Doing it this way makes atom to only create the properties that need to be overridden from defaults thus greatly reducing the number of initialization checks, saving time and memory. If you don't want this to happen override `get_declared_keys` to return an empty list.
[ "Initialize", "the", "underlying", "widget", ".", "This", "reads", "all", "items", "declared", "in", "the", "enamldef", "block", "for", "this", "node", "and", "sets", "only", "the", "values", "that", "have", "been", "specified", ".", "All", "other", "values"...
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L147-L168
train
38,292
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.on_key
def on_key(self, view, key, event): """ Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event """ d = self.declaration r = {'key': key, 'result': False} d.key_event(r) return r['result']
python
def on_key(self, view, key, event): """ Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event """ d = self.declaration r = {'key': key, 'result': False} d.key_event(r) return r['result']
[ "def", "on_key", "(", "self", ",", "view", ",", "key", ",", "event", ")", ":", "d", "=", "self", ".", "declaration", "r", "=", "{", "'key'", ":", "key", ",", "'result'", ":", "False", "}", "d", ".", "key_event", "(", "r", ")", "return", "r", "[...
Trigger the key event Parameters ---------- view: int The ID of the view that sent this event key: int The code of the key that was pressed data: bytes The msgpack encoded key event
[ "Trigger", "the", "key", "event" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L221-L237
train
38,293
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.on_touch
def on_touch(self, view, event): """ Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event """ d = self.declaration r = {'event': event, 'result': False} d.touch_event(r) return r['result']
python
def on_touch(self, view, event): """ Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event """ d = self.declaration r = {'event': event, 'result': False} d.touch_event(r) return r['result']
[ "def", "on_touch", "(", "self", ",", "view", ",", "event", ")", ":", "d", "=", "self", ".", "declaration", "r", "=", "{", "'event'", ":", "event", ",", "'result'", ":", "False", "}", "d", ".", "touch_event", "(", "r", ")", "return", "r", "[", "'r...
Trigger the touch event Parameters ---------- view: int The ID of the view that sent this event data: bytes The msgpack encoded key event
[ "Trigger", "the", "touch", "event" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L242-L256
train
38,294
codelv/enaml-native
src/enamlnative/android/android_view.py
AndroidView.set_visible
def set_visible(self, visible): """ Set the visibility of the widget. """ v = View.VISIBILITY_VISIBLE if visible else View.VISIBILITY_GONE self.widget.setVisibility(v)
python
def set_visible(self, visible): """ Set the visibility of the widget. """ v = View.VISIBILITY_VISIBLE if visible else View.VISIBILITY_GONE self.widget.setVisibility(v)
[ "def", "set_visible", "(", "self", ",", "visible", ")", ":", "v", "=", "View", ".", "VISIBILITY_VISIBLE", "if", "visible", "else", "View", ".", "VISIBILITY_GONE", "self", ".", "widget", ".", "setVisibility", "(", "v", ")" ]
Set the visibility of the widget.
[ "Set", "the", "visibility", "of", "the", "widget", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view.py#L301-L306
train
38,295
codelv/enaml-native
src/enamlnative/core/loop.py
EventLoop.default
def default(cls): """ Get the first available event loop implementation based on which packages are installed. """ with enamlnative.imports(): for impl in [ TornadoEventLoop, TwistedEventLoop, BuiltinEventLoop, ]: if impl.available(): print("Using {} event loop!".format(impl)) return impl() raise RuntimeError("No event loop implementation is available. " "Install tornado or twisted.")
python
def default(cls): """ Get the first available event loop implementation based on which packages are installed. """ with enamlnative.imports(): for impl in [ TornadoEventLoop, TwistedEventLoop, BuiltinEventLoop, ]: if impl.available(): print("Using {} event loop!".format(impl)) return impl() raise RuntimeError("No event loop implementation is available. " "Install tornado or twisted.")
[ "def", "default", "(", "cls", ")", ":", "with", "enamlnative", ".", "imports", "(", ")", ":", "for", "impl", "in", "[", "TornadoEventLoop", ",", "TwistedEventLoop", ",", "BuiltinEventLoop", ",", "]", ":", "if", "impl", ".", "available", "(", ")", ":", ...
Get the first available event loop implementation based on which packages are installed.
[ "Get", "the", "first", "available", "event", "loop", "implementation", "based", "on", "which", "packages", "are", "installed", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L34-L49
train
38,296
codelv/enaml-native
src/enamlnative/core/loop.py
EventLoop.log_error
def log_error(self, callback, error=None): """ Log the error that occurred when running the given callback. """ print("Uncaught error during callback: {}".format(callback)) print("Error: {}".format(error))
python
def log_error(self, callback, error=None): """ Log the error that occurred when running the given callback. """ print("Uncaught error during callback: {}".format(callback)) print("Error: {}".format(error))
[ "def", "log_error", "(", "self", ",", "callback", ",", "error", "=", "None", ")", ":", "print", "(", "\"Uncaught error during callback: {}\"", ".", "format", "(", "callback", ")", ")", "print", "(", "\"Error: {}\"", ".", "format", "(", "error", ")", ")" ]
Log the error that occurred when running the given callback.
[ "Log", "the", "error", "that", "occurred", "when", "running", "the", "given", "callback", "." ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/loop.py#L117-L120
train
38,297
codelv/enaml-native
src/enamlnative/ios/uikit_view.py
UiKitView.update_frame
def update_frame(self): """ Define the view frame for this widgets""" d = self.declaration if d.x or d.y or d.width or d.height: self.frame = (d.x, d.y, d.width, d.height)
python
def update_frame(self): """ Define the view frame for this widgets""" d = self.declaration if d.x or d.y or d.width or d.height: self.frame = (d.x, d.y, d.width, d.height)
[ "def", "update_frame", "(", "self", ")", ":", "d", "=", "self", ".", "declaration", "if", "d", ".", "x", "or", "d", ".", "y", "or", "d", ".", "width", "or", "d", ".", "height", ":", "self", ".", "frame", "=", "(", "d", ".", "x", ",", "d", "...
Define the view frame for this widgets
[ "Define", "the", "view", "frame", "for", "this", "widgets" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/ios/uikit_view.py#L171-L175
train
38,298
codelv/enaml-native
src/enamlnative/android/android_view_pager.py
AndroidViewPager.child_added
def child_added(self, child): """ When a child is added, schedule a data changed notification """ super(AndroidViewPager, self).child_added(child) self._notify_count += 1 self.get_context().timed_call( self._notify_delay, self._notify_change)
python
def child_added(self, child): """ When a child is added, schedule a data changed notification """ super(AndroidViewPager, self).child_added(child) self._notify_count += 1 self.get_context().timed_call( self._notify_delay, self._notify_change)
[ "def", "child_added", "(", "self", ",", "child", ")", ":", "super", "(", "AndroidViewPager", ",", "self", ")", ".", "child_added", "(", "child", ")", "self", ".", "_notify_count", "+=", "1", "self", ".", "get_context", "(", ")", ".", "timed_call", "(", ...
When a child is added, schedule a data changed notification
[ "When", "a", "child", "is", "added", "schedule", "a", "data", "changed", "notification" ]
c33986e9eda468c508806e0a3e73c771401e5718
https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L163-L168
train
38,299