partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Index.query | Query a fulltext index by key and query or just a plain Lucene query,
i1 = gdb.nodes.indexes.get('people',type='fulltext', provider='lucene')
i1.query('name','do*')
i1.query('name:do*')
In this example, the last two line are equivalent. | neo4jrestclient/client.py | def query(self, *args):
"""
Query a fulltext index by key and query or just a plain Lucene query,
i1 = gdb.nodes.indexes.get('people',type='fulltext', provider='lucene')
i1.query('name','do*')
i1.query('name:do*')
In this example, the last two line are equivalent.
... | def query(self, *args):
"""
Query a fulltext index by key and query or just a plain Lucene query,
i1 = gdb.nodes.indexes.get('people',type='fulltext', provider='lucene')
i1.query('name','do*')
i1.query('name:do*')
In this example, the last two line are equivalent.
... | [
"Query",
"a",
"fulltext",
"index",
"by",
"key",
"and",
"query",
"or",
"just",
"a",
"plain",
"Lucene",
"query"
] | versae/neo4j-rest-client | python | https://github.com/versae/neo4j-rest-client/blob/b03c09c8f598fa4dbad8ea8998ffb1c885805074/neo4jrestclient/client.py#L1788-L1813 | [
"def",
"query",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
"or",
"len",
"(",
"args",
")",
">",
"2",
":",
"raise",
"TypeError",
"(",
"'query() takes 2 or 3 arguments (a query or a key '",
"'and a query) (%d given)'",
"%",
"(",
"len",
"(",
"... | b03c09c8f598fa4dbad8ea8998ffb1c885805074 |
train | QuerySequence._plot_graph | Return a HTML representation for a particular QuerySequence.
Mainly for IPython Notebook. | neo4jrestclient/query.py | def _plot_graph(self, graph, title=None, width=None, height=None):
"""
Return a HTML representation for a particular QuerySequence.
Mainly for IPython Notebook.
"""
if not self._elements_row and not self._elements_graph:
raise ValueError('Unable to display the graph o... | def _plot_graph(self, graph, title=None, width=None, height=None):
"""
Return a HTML representation for a particular QuerySequence.
Mainly for IPython Notebook.
"""
if not self._elements_row and not self._elements_graph:
raise ValueError('Unable to display the graph o... | [
"Return",
"a",
"HTML",
"representation",
"for",
"a",
"particular",
"QuerySequence",
".",
"Mainly",
"for",
"IPython",
"Notebook",
"."
] | versae/neo4j-rest-client | python | https://github.com/versae/neo4j-rest-client/blob/b03c09c8f598fa4dbad8ea8998ffb1c885805074/neo4jrestclient/query.py#L422-L642 | [
"def",
"_plot_graph",
"(",
"self",
",",
"graph",
",",
"title",
"=",
"None",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_elements_row",
"and",
"not",
"self",
".",
"_elements_graph",
":",
"raise",
"ValueEr... | b03c09c8f598fa4dbad8ea8998ffb1c885805074 |
train | HTTPClient.do_call | Send an HTTP request to the REST API.
:param string path: A URL
:param string method: The HTTP method (GET, POST, etc.) to use
in the request.
:param string body: A string representing any data to be sent in the
body of the HTTP request.
:param dictionary headers... | pyrabbit/http.py | def do_call(self, path, method, body=None, headers=None):
"""
Send an HTTP request to the REST API.
:param string path: A URL
:param string method: The HTTP method (GET, POST, etc.) to use
in the request.
:param string body: A string representing any data to be sent ... | def do_call(self, path, method, body=None, headers=None):
"""
Send an HTTP request to the REST API.
:param string path: A URL
:param string method: The HTTP method (GET, POST, etc.) to use
in the request.
:param string body: A string representing any data to be sent ... | [
"Send",
"an",
"HTTP",
"request",
"to",
"the",
"REST",
"API",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/http.py#L72-L107 | [
"def",
"do_call",
"(",
"self",
",",
"path",
",",
"method",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"path",
")",
"try",
":",
"resp",
"=",
"requests",
".",
"request",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client._call | Wrapper around http.do_call that transforms some HTTPError into
our own exceptions | pyrabbit/api.py | def _call(self, path, method, body=None, headers=None):
"""
Wrapper around http.do_call that transforms some HTTPError into
our own exceptions
"""
try:
resp = self.http.do_call(path, method, body, headers)
except http.HTTPError as err:
if err.statu... | def _call(self, path, method, body=None, headers=None):
"""
Wrapper around http.do_call that transforms some HTTPError into
our own exceptions
"""
try:
resp = self.http.do_call(path, method, body, headers)
except http.HTTPError as err:
if err.statu... | [
"Wrapper",
"around",
"http",
".",
"do_call",
"that",
"transforms",
"some",
"HTTPError",
"into",
"our",
"own",
"exceptions"
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L102-L114 | [
"def",
"_call",
"(",
"self",
",",
"path",
",",
"method",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"try",
":",
"resp",
"=",
"self",
".",
"http",
".",
"do_call",
"(",
"path",
",",
"method",
",",
"body",
",",
"headers",
")",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.is_alive | Uses the aliveness-test API call to determine if the
server is alive and the vhost is active. The broker (not this code)
creates a queue and then sends/consumes a message from it.
:param string vhost: There should be no real reason to ever change
this from the default value, but it'... | pyrabbit/api.py | def is_alive(self, vhost='%2F'):
"""
Uses the aliveness-test API call to determine if the
server is alive and the vhost is active. The broker (not this code)
creates a queue and then sends/consumes a message from it.
:param string vhost: There should be no real reason to ever ch... | def is_alive(self, vhost='%2F'):
"""
Uses the aliveness-test API call to determine if the
server is alive and the vhost is active. The broker (not this code)
creates a queue and then sends/consumes a message from it.
:param string vhost: There should be no real reason to ever ch... | [
"Uses",
"the",
"aliveness",
"-",
"test",
"API",
"call",
"to",
"determine",
"if",
"the",
"server",
"is",
"alive",
"and",
"the",
"vhost",
"is",
"active",
".",
"The",
"broker",
"(",
"not",
"this",
"code",
")",
"creates",
"a",
"queue",
"and",
"then",
"send... | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L117-L141 | [
"def",
"is_alive",
"(",
"self",
",",
"vhost",
"=",
"'%2F'",
")",
":",
"uri",
"=",
"Client",
".",
"urls",
"[",
"'live_test'",
"]",
"%",
"vhost",
"try",
":",
"resp",
"=",
"self",
".",
"_call",
"(",
"uri",
",",
"'GET'",
")",
"except",
"http",
".",
"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_whoami | A convenience function used in the event that you need to confirm that
the broker thinks you are who you think you are.
:returns dict whoami: Dict structure contains:
* administrator: whether the user is has admin privileges
* name: user name
* auth_backend: backend ... | pyrabbit/api.py | def get_whoami(self):
"""
A convenience function used in the event that you need to confirm that
the broker thinks you are who you think you are.
:returns dict whoami: Dict structure contains:
* administrator: whether the user is has admin privileges
* name: user... | def get_whoami(self):
"""
A convenience function used in the event that you need to confirm that
the broker thinks you are who you think you are.
:returns dict whoami: Dict structure contains:
* administrator: whether the user is has admin privileges
* name: user... | [
"A",
"convenience",
"function",
"used",
"in",
"the",
"event",
"that",
"you",
"need",
"to",
"confirm",
"that",
"the",
"broker",
"thinks",
"you",
"are",
"who",
"you",
"think",
"you",
"are",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L143-L155 | [
"def",
"get_whoami",
"(",
"self",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'whoami'",
"]",
"whoami",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"whoami"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_vhost_names | A convenience function for getting back only the vhost names instead of
the larger vhost dicts.
:returns list vhost_names: A list of just the vhost names. | pyrabbit/api.py | def get_vhost_names(self):
"""
A convenience function for getting back only the vhost names instead of
the larger vhost dicts.
:returns list vhost_names: A list of just the vhost names.
"""
vhosts = self.get_all_vhosts()
vhost_names = [i['name'] for i in vhosts]
... | def get_vhost_names(self):
"""
A convenience function for getting back only the vhost names instead of
the larger vhost dicts.
:returns list vhost_names: A list of just the vhost names.
"""
vhosts = self.get_all_vhosts()
vhost_names = [i['name'] for i in vhosts]
... | [
"A",
"convenience",
"function",
"for",
"getting",
"back",
"only",
"the",
"vhost",
"names",
"instead",
"of",
"the",
"larger",
"vhost",
"dicts",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L207-L216 | [
"def",
"get_vhost_names",
"(",
"self",
")",
":",
"vhosts",
"=",
"self",
".",
"get_all_vhosts",
"(",
")",
"vhost_names",
"=",
"[",
"i",
"[",
"'name'",
"]",
"for",
"i",
"in",
"vhosts",
"]",
"return",
"vhost_names"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_vhost | Returns the attributes of a single named vhost in a dict.
:param string vname: Name of the vhost to get.
:returns dict vhost: Attribute dict for the named vhost | pyrabbit/api.py | def get_vhost(self, vname):
"""
Returns the attributes of a single named vhost in a dict.
:param string vname: Name of the vhost to get.
:returns dict vhost: Attribute dict for the named vhost
"""
vname = quote(vname, '')
path = Client.urls['vhosts_by_name'] % ... | def get_vhost(self, vname):
"""
Returns the attributes of a single named vhost in a dict.
:param string vname: Name of the vhost to get.
:returns dict vhost: Attribute dict for the named vhost
"""
vname = quote(vname, '')
path = Client.urls['vhosts_by_name'] % ... | [
"Returns",
"the",
"attributes",
"of",
"a",
"single",
"named",
"vhost",
"in",
"a",
"dict",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L218-L230 | [
"def",
"get_vhost",
"(",
"self",
",",
"vname",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'vhosts_by_name'",
"]",
"%",
"vname",
"vhost",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GE... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.create_vhost | Creates a vhost on the server to house exchanges.
:param string vname: The name to give to the vhost on the server
:returns: boolean | pyrabbit/api.py | def create_vhost(self, vname):
"""
Creates a vhost on the server to house exchanges.
:param string vname: The name to give to the vhost on the server
:returns: boolean
"""
vname = quote(vname, '')
path = Client.urls['vhosts_by_name'] % vname
return self._... | def create_vhost(self, vname):
"""
Creates a vhost on the server to house exchanges.
:param string vname: The name to give to the vhost on the server
:returns: boolean
"""
vname = quote(vname, '')
path = Client.urls['vhosts_by_name'] % vname
return self._... | [
"Creates",
"a",
"vhost",
"on",
"the",
"server",
"to",
"house",
"exchanges",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L232-L242 | [
"def",
"create_vhost",
"(",
"self",
",",
"vname",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'vhosts_by_name'",
"]",
"%",
"vname",
"return",
"self",
".",
"_call",
"(",
"path",
",",
"'PUT'"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_vhost | Deletes a vhost from the server. Note that this also deletes any
exchanges or queues that belong to this vhost.
:param string vname: Name of the vhost to delete from the server. | pyrabbit/api.py | def delete_vhost(self, vname):
"""
Deletes a vhost from the server. Note that this also deletes any
exchanges or queues that belong to this vhost.
:param string vname: Name of the vhost to delete from the server.
"""
vname = quote(vname, '')
path = Client.urls['v... | def delete_vhost(self, vname):
"""
Deletes a vhost from the server. Note that this also deletes any
exchanges or queues that belong to this vhost.
:param string vname: Name of the vhost to delete from the server.
"""
vname = quote(vname, '')
path = Client.urls['v... | [
"Deletes",
"a",
"vhost",
"from",
"the",
"server",
".",
"Note",
"that",
"this",
"also",
"deletes",
"any",
"exchanges",
"or",
"queues",
"that",
"belong",
"to",
"this",
"vhost",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L244-L253 | [
"def",
"delete_vhost",
"(",
"self",
",",
"vname",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'vhosts_by_name'",
"]",
"%",
"vname",
"return",
"self",
".",
"_call",
"(",
"path",
",",
"'DELET... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_permissions | :returns: list of dicts, or an empty list if there are no permissions. | pyrabbit/api.py | def get_permissions(self):
"""
:returns: list of dicts, or an empty list if there are no permissions.
"""
path = Client.urls['all_permissions']
conns = self._call(path, 'GET')
return conns | def get_permissions(self):
"""
:returns: list of dicts, or an empty list if there are no permissions.
"""
path = Client.urls['all_permissions']
conns = self._call(path, 'GET')
return conns | [
":",
"returns",
":",
"list",
"of",
"dicts",
"or",
"an",
"empty",
"list",
"if",
"there",
"are",
"no",
"permissions",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L258-L264 | [
"def",
"get_permissions",
"(",
"self",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'all_permissions'",
"]",
"conns",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"conns"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_vhost_permissions | :returns: list of dicts, or an empty list if there are no permissions.
:param string vname: Name of the vhost to set perms on. | pyrabbit/api.py | def get_vhost_permissions(self, vname):
"""
:returns: list of dicts, or an empty list if there are no permissions.
:param string vname: Name of the vhost to set perms on.
"""
vname = quote(vname, '')
path = Client.urls['vhost_permissions_get'] % (vname,)
conns = ... | def get_vhost_permissions(self, vname):
"""
:returns: list of dicts, or an empty list if there are no permissions.
:param string vname: Name of the vhost to set perms on.
"""
vname = quote(vname, '')
path = Client.urls['vhost_permissions_get'] % (vname,)
conns = ... | [
":",
"returns",
":",
"list",
"of",
"dicts",
"or",
"an",
"empty",
"list",
"if",
"there",
"are",
"no",
"permissions",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L266-L275 | [
"def",
"get_vhost_permissions",
"(",
"self",
",",
"vname",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'vhost_permissions_get'",
"]",
"%",
"(",
"vname",
",",
")",
"conns",
"=",
"self",
".",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_user_permissions | :returns: list of dicts, or an empty list if there are no permissions.
:param string username: User to set permissions for. | pyrabbit/api.py | def get_user_permissions(self, username):
"""
:returns: list of dicts, or an empty list if there are no permissions.
:param string username: User to set permissions for.
"""
path = Client.urls['user_permissions'] % (username,)
conns = self._call(path, 'GET')
ret... | def get_user_permissions(self, username):
"""
:returns: list of dicts, or an empty list if there are no permissions.
:param string username: User to set permissions for.
"""
path = Client.urls['user_permissions'] % (username,)
conns = self._call(path, 'GET')
ret... | [
":",
"returns",
":",
"list",
"of",
"dicts",
"or",
"an",
"empty",
"list",
"if",
"there",
"are",
"no",
"permissions",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L277-L286 | [
"def",
"get_user_permissions",
"(",
"self",
",",
"username",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'user_permissions'",
"]",
"%",
"(",
"username",
",",
")",
"conns",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"co... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.set_vhost_permissions | Set permissions for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for.
:param string config: Permission pattern for configuration operations
for this user in... | pyrabbit/api.py | def set_vhost_permissions(self, vname, username, config, rd, wr):
"""
Set permissions for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for.
:param strin... | def set_vhost_permissions(self, vname, username, config, rd, wr):
"""
Set permissions for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for.
:param strin... | [
"Set",
"permissions",
"for",
"a",
"given",
"username",
"on",
"a",
"given",
"vhost",
".",
"Both",
"must",
"already",
"exist",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L288-L311 | [
"def",
"set_vhost_permissions",
"(",
"self",
",",
"vname",
",",
"username",
",",
"config",
",",
"rd",
",",
"wr",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"body",
"=",
"json",
".",
"dumps",
"(",
"{",
"\"configure\"",
":",
"config... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_permission | Delete permission for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for. | pyrabbit/api.py | def delete_permission(self, vname, username):
"""
Delete permission for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for.
"""
vname = quote(vnam... | def delete_permission(self, vname, username):
"""
Delete permission for a given username on a given vhost. Both
must already exist.
:param string vname: Name of the vhost to set perms on.
:param string username: User to set permissions for.
"""
vname = quote(vnam... | [
"Delete",
"permission",
"for",
"a",
"given",
"username",
"on",
"a",
"given",
"vhost",
".",
"Both",
"must",
"already",
"exist",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L313-L323 | [
"def",
"delete_permission",
"(",
"self",
",",
"vname",
",",
"username",
")",
":",
"vname",
"=",
"quote",
"(",
"vname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'vhost_permissions'",
"]",
"%",
"(",
"vname",
",",
"username",
")",
"return... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_exchanges | :returns: A list of dicts
:param string vhost: A vhost to query for exchanges, or None (default),
which triggers a query for all exchanges in all vhosts. | pyrabbit/api.py | def get_exchanges(self, vhost=None):
"""
:returns: A list of dicts
:param string vhost: A vhost to query for exchanges, or None (default),
which triggers a query for all exchanges in all vhosts.
"""
if vhost:
vhost = quote(vhost, '')
path = Cl... | def get_exchanges(self, vhost=None):
"""
:returns: A list of dicts
:param string vhost: A vhost to query for exchanges, or None (default),
which triggers a query for all exchanges in all vhosts.
"""
if vhost:
vhost = quote(vhost, '')
path = Cl... | [
":",
"returns",
":",
"A",
"list",
"of",
"dicts",
":",
"param",
"string",
"vhost",
":",
"A",
"vhost",
"to",
"query",
"for",
"exchanges",
"or",
"None",
"(",
"default",
")",
"which",
"triggers",
"a",
"query",
"for",
"all",
"exchanges",
"in",
"all",
"vhost... | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L339-L353 | [
"def",
"get_exchanges",
"(",
"self",
",",
"vhost",
"=",
"None",
")",
":",
"if",
"vhost",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'exchanges_by_vhost'",
"]",
"%",
"vhost",
"else",
":",
"path"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_exchange | Gets a single exchange which requires a vhost and name.
:param string vhost: The vhost containing the target exchange
:param string name: The name of the exchange
:returns: dict | pyrabbit/api.py | def get_exchange(self, vhost, name):
"""
Gets a single exchange which requires a vhost and name.
:param string vhost: The vhost containing the target exchange
:param string name: The name of the exchange
:returns: dict
"""
vhost = quote(vhost, '')
name =... | def get_exchange(self, vhost, name):
"""
Gets a single exchange which requires a vhost and name.
:param string vhost: The vhost containing the target exchange
:param string name: The name of the exchange
:returns: dict
"""
vhost = quote(vhost, '')
name =... | [
"Gets",
"a",
"single",
"exchange",
"which",
"requires",
"a",
"vhost",
"and",
"name",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L355-L368 | [
"def",
"get_exchange",
"(",
"self",
",",
"vhost",
",",
"name",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'exchange_by_name'",
"]",
"%"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.create_exchange | Creates an exchange in the given vhost with the given name. As per the
RabbitMQ API documentation, a JSON body also needs to be included that
"looks something like this":
{"type":"direct",
"auto_delete":false,
"durable":true,
"internal":false,
"arguments":[]}
... | pyrabbit/api.py | def create_exchange(self,
vhost,
name,
xtype,
auto_delete=False,
durable=True,
internal=False,
arguments=None):
"""
Creates an exchange ... | def create_exchange(self,
vhost,
name,
xtype,
auto_delete=False,
durable=True,
internal=False,
arguments=None):
"""
Creates an exchange ... | [
"Creates",
"an",
"exchange",
"in",
"the",
"given",
"vhost",
"with",
"the",
"given",
"name",
".",
"As",
"per",
"the",
"RabbitMQ",
"API",
"documentation",
"a",
"JSON",
"body",
"also",
"needs",
"to",
"be",
"included",
"that",
"looks",
"something",
"like",
"th... | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L370-L416 | [
"def",
"create_exchange",
"(",
"self",
",",
"vhost",
",",
"name",
",",
"xtype",
",",
"auto_delete",
"=",
"False",
",",
"durable",
"=",
"True",
",",
"internal",
"=",
"False",
",",
"arguments",
"=",
"None",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.publish | Publish a message to an exchange.
:param string vhost: vhost housing the target exchange
:param string xname: name of the target exchange
:param string rt_key: routing key for message
:param string payload: the message body for publishing
:param string payload_enc: encoding of t... | pyrabbit/api.py | def publish(self, vhost, xname, rt_key, payload, payload_enc='string',
properties=None):
"""
Publish a message to an exchange.
:param string vhost: vhost housing the target exchange
:param string xname: name of the target exchange
:param string rt_key: routing ke... | def publish(self, vhost, xname, rt_key, payload, payload_enc='string',
properties=None):
"""
Publish a message to an exchange.
:param string vhost: vhost housing the target exchange
:param string xname: name of the target exchange
:param string rt_key: routing ke... | [
"Publish",
"a",
"message",
"to",
"an",
"exchange",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L418-L439 | [
"def",
"publish",
"(",
"self",
",",
"vhost",
",",
"xname",
",",
"rt_key",
",",
"payload",
",",
"payload_enc",
"=",
"'string'",
",",
"properties",
"=",
"None",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"xname",
"=",
"quote",
"(",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_exchange | Delete the named exchange from the named vhost. The API returns a 204
on success, in which case this method returns True, otherwise the
error is raised.
:param string vhost: Vhost where target exchange was created
:param string name: The name of the exchange to delete.
:returns ... | pyrabbit/api.py | def delete_exchange(self, vhost, name):
"""
Delete the named exchange from the named vhost. The API returns a 204
on success, in which case this method returns True, otherwise the
error is raised.
:param string vhost: Vhost where target exchange was created
:param string... | def delete_exchange(self, vhost, name):
"""
Delete the named exchange from the named vhost. The API returns a 204
on success, in which case this method returns True, otherwise the
error is raised.
:param string vhost: Vhost where target exchange was created
:param string... | [
"Delete",
"the",
"named",
"exchange",
"from",
"the",
"named",
"vhost",
".",
"The",
"API",
"returns",
"a",
"204",
"on",
"success",
"in",
"which",
"case",
"this",
"method",
"returns",
"True",
"otherwise",
"the",
"error",
"is",
"raised",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L441-L455 | [
"def",
"delete_exchange",
"(",
"self",
",",
"vhost",
",",
"name",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'exchange_by_name'",
"]",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_queues | Get all queues, or all queues in a vhost if vhost is not None.
Returns a list.
:param string vhost: The virtual host to list queues for. If This is
None (the default), all queues for the broker instance
are returned.
:returns: A list of dicts, each repres... | pyrabbit/api.py | def get_queues(self, vhost=None):
"""
Get all queues, or all queues in a vhost if vhost is not None.
Returns a list.
:param string vhost: The virtual host to list queues for. If This is
None (the default), all queues for the broker instance
are re... | def get_queues(self, vhost=None):
"""
Get all queues, or all queues in a vhost if vhost is not None.
Returns a list.
:param string vhost: The virtual host to list queues for. If This is
None (the default), all queues for the broker instance
are re... | [
"Get",
"all",
"queues",
"or",
"all",
"queues",
"in",
"a",
"vhost",
"if",
"vhost",
"is",
"not",
"None",
".",
"Returns",
"a",
"list",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L460-L479 | [
"def",
"get_queues",
"(",
"self",
",",
"vhost",
"=",
"None",
")",
":",
"if",
"vhost",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'queues_by_vhost'",
"]",
"%",
"vhost",
"else",
":",
"path",
"=... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_queue | Get a single queue, which requires both vhost and name.
:param string vhost: The virtual host for the queue being requested.
If the vhost is '/', note that it will be translated to '%2F' to
conform to URL encoding requirements.
:param string name: The name of the queue being req... | pyrabbit/api.py | def get_queue(self, vhost, name):
"""
Get a single queue, which requires both vhost and name.
:param string vhost: The virtual host for the queue being requested.
If the vhost is '/', note that it will be translated to '%2F' to
conform to URL encoding requirements.
... | def get_queue(self, vhost, name):
"""
Get a single queue, which requires both vhost and name.
:param string vhost: The virtual host for the queue being requested.
If the vhost is '/', note that it will be translated to '%2F' to
conform to URL encoding requirements.
... | [
"Get",
"a",
"single",
"queue",
"which",
"requires",
"both",
"vhost",
"and",
"name",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L481-L497 | [
"def",
"get_queue",
"(",
"self",
",",
"vhost",
",",
"name",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'queues_by_name'",
"]",
"%",
"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_queue_depth | Get the number of messages currently in a queue. This is a convenience
function that just calls :meth:`Client.get_queue` and pulls
out/returns the 'messages' field from the dictionary it returns.
:param string vhost: The vhost of the queue being queried.
:param string name: The name o... | pyrabbit/api.py | def get_queue_depth(self, vhost, name):
"""
Get the number of messages currently in a queue. This is a convenience
function that just calls :meth:`Client.get_queue` and pulls
out/returns the 'messages' field from the dictionary it returns.
:param string vhost: The vhost of the... | def get_queue_depth(self, vhost, name):
"""
Get the number of messages currently in a queue. This is a convenience
function that just calls :meth:`Client.get_queue` and pulls
out/returns the 'messages' field from the dictionary it returns.
:param string vhost: The vhost of the... | [
"Get",
"the",
"number",
"of",
"messages",
"currently",
"in",
"a",
"queue",
".",
"This",
"is",
"a",
"convenience",
"function",
"that",
"just",
"calls",
":",
"meth",
":",
"Client",
".",
"get_queue",
"and",
"pulls",
"out",
"/",
"returns",
"the",
"messages",
... | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L499-L517 | [
"def",
"get_queue_depth",
"(",
"self",
",",
"vhost",
",",
"name",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'queues_by_name'",
"]",
"%... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_queue_depths | Get the number of messages currently sitting in either the queue
names listed in 'names', or all queues in 'vhost' if no 'names' are
given.
:param str vhost: Vhost where queues in 'names' live.
:param list names: OPTIONAL - Specific queues to show depths for. If
None, sh... | pyrabbit/api.py | def get_queue_depths(self, vhost, names=None):
"""
Get the number of messages currently sitting in either the queue
names listed in 'names', or all queues in 'vhost' if no 'names' are
given.
:param str vhost: Vhost where queues in 'names' live.
:param list names: OPTIONA... | def get_queue_depths(self, vhost, names=None):
"""
Get the number of messages currently sitting in either the queue
names listed in 'names', or all queues in 'vhost' if no 'names' are
given.
:param str vhost: Vhost where queues in 'names' live.
:param list names: OPTIONA... | [
"Get",
"the",
"number",
"of",
"messages",
"currently",
"sitting",
"in",
"either",
"the",
"queue",
"names",
"listed",
"in",
"names",
"or",
"all",
"queues",
"in",
"vhost",
"if",
"no",
"names",
"are",
"given",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L519-L542 | [
"def",
"get_queue_depths",
"(",
"self",
",",
"vhost",
",",
"names",
"=",
"None",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"if",
"not",
"names",
":",
"# get all queues in vhost",
"path",
"=",
"Client",
".",
"urls",
"[",
"'queues_by_v... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.purge_queues | Purge all messages from one or more queues.
:param list queues: A list of ('qname', 'vhost') tuples.
:returns: True on success | pyrabbit/api.py | def purge_queues(self, queues):
"""
Purge all messages from one or more queues.
:param list queues: A list of ('qname', 'vhost') tuples.
:returns: True on success
"""
for name, vhost in queues:
vhost = quote(vhost, '')
name = quote(name, '')
... | def purge_queues(self, queues):
"""
Purge all messages from one or more queues.
:param list queues: A list of ('qname', 'vhost') tuples.
:returns: True on success
"""
for name, vhost in queues:
vhost = quote(vhost, '')
name = quote(name, '')
... | [
"Purge",
"all",
"messages",
"from",
"one",
"or",
"more",
"queues",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L544-L557 | [
"def",
"purge_queues",
"(",
"self",
",",
"queues",
")",
":",
"for",
"name",
",",
"vhost",
"in",
"queues",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"ur... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.purge_queue | Purge all messages from a single queue. This is a convenience method
so you aren't forced to supply a list containing a single tuple to
the purge_queues method.
:param string vhost: The vhost of the queue being purged.
:param string name: The name of the queue being purged.
:rty... | pyrabbit/api.py | def purge_queue(self, vhost, name):
"""
Purge all messages from a single queue. This is a convenience method
so you aren't forced to supply a list containing a single tuple to
the purge_queues method.
:param string vhost: The vhost of the queue being purged.
:param strin... | def purge_queue(self, vhost, name):
"""
Purge all messages from a single queue. This is a convenience method
so you aren't forced to supply a list containing a single tuple to
the purge_queues method.
:param string vhost: The vhost of the queue being purged.
:param strin... | [
"Purge",
"all",
"messages",
"from",
"a",
"single",
"queue",
".",
"This",
"is",
"a",
"convenience",
"method",
"so",
"you",
"aren",
"t",
"forced",
"to",
"supply",
"a",
"list",
"containing",
"a",
"single",
"tuple",
"to",
"the",
"purge_queues",
"method",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L559-L573 | [
"def",
"purge_queue",
"(",
"self",
",",
"vhost",
",",
"name",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'purge_queue'",
"]",
"%",
"(... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.create_queue | Create a queue. The API documentation specifies that all of the body
elements are optional, so this method only requires arguments needed
to form the URI
:param string vhost: The vhost to create the queue in.
:param string name: The name of the queue
More on these operations ca... | pyrabbit/api.py | def create_queue(self, vhost, name, **kwargs):
"""
Create a queue. The API documentation specifies that all of the body
elements are optional, so this method only requires arguments needed
to form the URI
:param string vhost: The vhost to create the queue in.
:param stri... | def create_queue(self, vhost, name, **kwargs):
"""
Create a queue. The API documentation specifies that all of the body
elements are optional, so this method only requires arguments needed
to form the URI
:param string vhost: The vhost to create the queue in.
:param stri... | [
"Create",
"a",
"queue",
".",
"The",
"API",
"documentation",
"specifies",
"that",
"all",
"of",
"the",
"body",
"elements",
"are",
"optional",
"so",
"this",
"method",
"only",
"requires",
"arguments",
"needed",
"to",
"form",
"the",
"URI"
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L575-L598 | [
"def",
"create_queue",
"(",
"self",
",",
"vhost",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_queue | Deletes the named queue from the named vhost.
:param string vhost: Vhost housing the queue to be deleted.
:param string qname: Name of the queue to delete.
Note that if you just want to delete the messages from a queue, you
should use purge_queue instead of deleting/recreating a queue. | pyrabbit/api.py | def delete_queue(self, vhost, qname):
"""
Deletes the named queue from the named vhost.
:param string vhost: Vhost housing the queue to be deleted.
:param string qname: Name of the queue to delete.
Note that if you just want to delete the messages from a queue, you
shou... | def delete_queue(self, vhost, qname):
"""
Deletes the named queue from the named vhost.
:param string vhost: Vhost housing the queue to be deleted.
:param string qname: Name of the queue to delete.
Note that if you just want to delete the messages from a queue, you
shou... | [
"Deletes",
"the",
"named",
"queue",
"from",
"the",
"named",
"vhost",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L600-L613 | [
"def",
"delete_queue",
"(",
"self",
",",
"vhost",
",",
"qname",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"qname",
"=",
"quote",
"(",
"qname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'queues_by_name'",
"]",
"%... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_messages | Gets <count> messages from the queue.
:param string vhost: Name of vhost containing the queue
:param string qname: Name of the queue to consume from
:param int count: Number of messages to get.
:param bool requeue: Whether to requeue the message after getting it.
This will c... | pyrabbit/api.py | def get_messages(self, vhost, qname, count=1,
requeue=False, truncate=None, encoding='auto'):
"""
Gets <count> messages from the queue.
:param string vhost: Name of vhost containing the queue
:param string qname: Name of the queue to consume from
:param int ... | def get_messages(self, vhost, qname, count=1,
requeue=False, truncate=None, encoding='auto'):
"""
Gets <count> messages from the queue.
:param string vhost: Name of vhost containing the queue
:param string qname: Name of the queue to consume from
:param int ... | [
"Gets",
"<count",
">",
"messages",
"from",
"the",
"queue",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L615-L642 | [
"def",
"get_messages",
"(",
"self",
",",
"vhost",
",",
"qname",
",",
"count",
"=",
"1",
",",
"requeue",
"=",
"False",
",",
"truncate",
"=",
"None",
",",
"encoding",
"=",
"'auto'",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"base... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_connections | :returns: list of dicts, or an empty list if there are no connections. | pyrabbit/api.py | def get_connections(self):
"""
:returns: list of dicts, or an empty list if there are no connections.
"""
path = Client.urls['all_connections']
conns = self._call(path, 'GET')
return conns | def get_connections(self):
"""
:returns: list of dicts, or an empty list if there are no connections.
"""
path = Client.urls['all_connections']
conns = self._call(path, 'GET')
return conns | [
":",
"returns",
":",
"list",
"of",
"dicts",
"or",
"an",
"empty",
"list",
"if",
"there",
"are",
"no",
"connections",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L647-L653 | [
"def",
"get_connections",
"(",
"self",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'all_connections'",
"]",
"conns",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"conns"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_connection | Get a connection by name. To get the names, use get_connections.
:param string name: Name of connection to get
:returns dict conn: A connection attribute dictionary. | pyrabbit/api.py | def get_connection(self, name):
"""
Get a connection by name. To get the names, use get_connections.
:param string name: Name of connection to get
:returns dict conn: A connection attribute dictionary.
"""
name = quote(name, '')
path = Client.urls['connections_b... | def get_connection(self, name):
"""
Get a connection by name. To get the names, use get_connections.
:param string name: Name of connection to get
:returns dict conn: A connection attribute dictionary.
"""
name = quote(name, '')
path = Client.urls['connections_b... | [
"Get",
"a",
"connection",
"by",
"name",
".",
"To",
"get",
"the",
"names",
"use",
"get_connections",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L655-L666 | [
"def",
"get_connection",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'connections_by_name'",
"]",
"%",
"name",
"conn",
"=",
"self",
".",
"_call",
"(",
"path",
",",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_connection | Close the named connection. The API returns a 204 on success,
in which case this method returns True, otherwise the
error is raised.
:param string name: The name of the connection to delete.
:returns bool: True on success. | pyrabbit/api.py | def delete_connection(self, name):
"""
Close the named connection. The API returns a 204 on success,
in which case this method returns True, otherwise the
error is raised.
:param string name: The name of the connection to delete.
:returns bool: True on success.
"... | def delete_connection(self, name):
"""
Close the named connection. The API returns a 204 on success,
in which case this method returns True, otherwise the
error is raised.
:param string name: The name of the connection to delete.
:returns bool: True on success.
"... | [
"Close",
"the",
"named",
"connection",
".",
"The",
"API",
"returns",
"a",
"204",
"on",
"success",
"in",
"which",
"case",
"this",
"method",
"returns",
"True",
"otherwise",
"the",
"error",
"is",
"raised",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L668-L680 | [
"def",
"delete_connection",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'connections_by_name'",
"]",
"%",
"name",
"self",
".",
"_call",
"(",
"path",
",",
"'DELETE'",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_channels | Return a list of dicts containing details about broker connections.
:returns: list of dicts | pyrabbit/api.py | def get_channels(self):
"""
Return a list of dicts containing details about broker connections.
:returns: list of dicts
"""
path = Client.urls['all_channels']
chans = self._call(path, 'GET')
return chans | def get_channels(self):
"""
Return a list of dicts containing details about broker connections.
:returns: list of dicts
"""
path = Client.urls['all_channels']
chans = self._call(path, 'GET')
return chans | [
"Return",
"a",
"list",
"of",
"dicts",
"containing",
"details",
"about",
"broker",
"connections",
".",
":",
"returns",
":",
"list",
"of",
"dicts"
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L682-L689 | [
"def",
"get_channels",
"(",
"self",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'all_channels'",
"]",
"chans",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"chans"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_channel | Get a channel by name. To get the names, use get_channels.
:param string name: Name of channel to get
:returns dict conn: A channel attribute dictionary. | pyrabbit/api.py | def get_channel(self, name):
"""
Get a channel by name. To get the names, use get_channels.
:param string name: Name of channel to get
:returns dict conn: A channel attribute dictionary.
"""
name = quote(name, '')
path = Client.urls['channels_by_name'] % name
... | def get_channel(self, name):
"""
Get a channel by name. To get the names, use get_channels.
:param string name: Name of channel to get
:returns dict conn: A channel attribute dictionary.
"""
name = quote(name, '')
path = Client.urls['channels_by_name'] % name
... | [
"Get",
"a",
"channel",
"by",
"name",
".",
"To",
"get",
"the",
"names",
"use",
"get_channels",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L691-L702 | [
"def",
"get_channel",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"quote",
"(",
"name",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'channels_by_name'",
"]",
"%",
"name",
"chan",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_bindings | :returns: list of dicts | pyrabbit/api.py | def get_bindings(self):
"""
:returns: list of dicts
"""
path = Client.urls['all_bindings']
bindings = self._call(path, 'GET')
return bindings | def get_bindings(self):
"""
:returns: list of dicts
"""
path = Client.urls['all_bindings']
bindings = self._call(path, 'GET')
return bindings | [
":",
"returns",
":",
"list",
"of",
"dicts"
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L704-L711 | [
"def",
"get_bindings",
"(",
"self",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'all_bindings'",
"]",
"bindings",
"=",
"self",
".",
"_call",
"(",
"path",
",",
"'GET'",
")",
"return",
"bindings"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.get_queue_bindings | Return a list of dicts, one dict per binding. The dict format coming
from RabbitMQ for queue named 'testq' is:
{"source":"sourceExch","vhost":"/","destination":"testq",
"destination_type":"queue","routing_key":"*.*","arguments":{},
"properties_key":"%2A.%2A"} | pyrabbit/api.py | def get_queue_bindings(self, vhost, qname):
"""
Return a list of dicts, one dict per binding. The dict format coming
from RabbitMQ for queue named 'testq' is:
{"source":"sourceExch","vhost":"/","destination":"testq",
"destination_type":"queue","routing_key":"*.*","arguments":{}... | def get_queue_bindings(self, vhost, qname):
"""
Return a list of dicts, one dict per binding. The dict format coming
from RabbitMQ for queue named 'testq' is:
{"source":"sourceExch","vhost":"/","destination":"testq",
"destination_type":"queue","routing_key":"*.*","arguments":{}... | [
"Return",
"a",
"list",
"of",
"dicts",
"one",
"dict",
"per",
"binding",
".",
"The",
"dict",
"format",
"coming",
"from",
"RabbitMQ",
"for",
"queue",
"named",
"testq",
"is",
":"
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L713-L726 | [
"def",
"get_queue_bindings",
"(",
"self",
",",
"vhost",
",",
"qname",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"qname",
"=",
"quote",
"(",
"qname",
",",
"''",
")",
"path",
"=",
"Client",
".",
"urls",
"[",
"'bindings_on_queue'",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.create_binding | Creates a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param string queue: the queue to bind to the exchange
:param string rt_key: the routing key to us... | pyrabbit/api.py | def create_binding(self, vhost, exchange, queue, rt_key=None, args=None):
"""
Creates a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param strin... | def create_binding(self, vhost, exchange, queue, rt_key=None, args=None):
"""
Creates a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param strin... | [
"Creates",
"a",
"binding",
"between",
"an",
"exchange",
"and",
"a",
"queue",
"on",
"a",
"given",
"vhost",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L737-L758 | [
"def",
"create_binding",
"(",
"self",
",",
"vhost",
",",
"exchange",
",",
"queue",
",",
"rt_key",
"=",
"None",
",",
"args",
"=",
"None",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"exchange",
"=",
"quote",
"(",
"exchange",
",",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_binding | Deletes a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param string queue: the queue to bind to the exchange
:param string rt_key: the routing key to us... | pyrabbit/api.py | def delete_binding(self, vhost, exchange, queue, rt_key):
"""
Deletes a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param string queue: the que... | def delete_binding(self, vhost, exchange, queue, rt_key):
"""
Deletes a binding between an exchange and a queue on a given vhost.
:param string vhost: vhost housing the exchange/queue to bind
:param string exchange: the target exchange of the binding
:param string queue: the que... | [
"Deletes",
"a",
"binding",
"between",
"an",
"exchange",
"and",
"a",
"queue",
"on",
"a",
"given",
"vhost",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L760-L778 | [
"def",
"delete_binding",
"(",
"self",
",",
"vhost",
",",
"exchange",
",",
"queue",
",",
"rt_key",
")",
":",
"vhost",
"=",
"quote",
"(",
"vhost",
",",
"''",
")",
"exchange",
"=",
"quote",
"(",
"exchange",
",",
"''",
")",
"queue",
"=",
"quote",
"(",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.create_user | Creates a user.
:param string username: The name to give to the new user
:param string password: Password for the new user
:param string tags: Comma-separated list of tags for the user
:returns: boolean | pyrabbit/api.py | def create_user(self, username, password, tags=""):
"""
Creates a user.
:param string username: The name to give to the new user
:param string password: Password for the new user
:param string tags: Comma-separated list of tags for the user
:returns: boolean
"""
... | def create_user(self, username, password, tags=""):
"""
Creates a user.
:param string username: The name to give to the new user
:param string password: Password for the new user
:param string tags: Comma-separated list of tags for the user
:returns: boolean
"""
... | [
"Creates",
"a",
"user",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L780-L792 | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"password",
",",
"tags",
"=",
"\"\"",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'users_by_name'",
"]",
"%",
"username",
"body",
"=",
"json",
".",
"dumps",
"(",
"{",
"'password'",
":",
... | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | Client.delete_user | Deletes a user from the server.
:param string username: Name of the user to delete from the server. | pyrabbit/api.py | def delete_user(self, username):
"""
Deletes a user from the server.
:param string username: Name of the user to delete from the server.
"""
path = Client.urls['users_by_name'] % username
return self._call(path, 'DELETE') | def delete_user(self, username):
"""
Deletes a user from the server.
:param string username: Name of the user to delete from the server.
"""
path = Client.urls['users_by_name'] % username
return self._call(path, 'DELETE') | [
"Deletes",
"a",
"user",
"from",
"the",
"server",
"."
] | bkjones/pyrabbit | python | https://github.com/bkjones/pyrabbit/blob/e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f/pyrabbit/api.py#L794-L801 | [
"def",
"delete_user",
"(",
"self",
",",
"username",
")",
":",
"path",
"=",
"Client",
".",
"urls",
"[",
"'users_by_name'",
"]",
"%",
"username",
"return",
"self",
".",
"_call",
"(",
"path",
",",
"'DELETE'",
")"
] | e8a9f74ed5c6bba958994fb9a72c396e6a99ea0f |
train | index | Redirects to the default wiki index name. | wakawaka/views.py | def index(request):
"""
Redirects to the default wiki index name.
"""
kwargs = {'slug': getattr(settings, 'WAKAWAKA_DEFAULT_INDEX', 'WikiIndex')}
redirect_to = reverse('wakawaka_page', kwargs=kwargs)
return HttpResponseRedirect(redirect_to) | def index(request):
"""
Redirects to the default wiki index name.
"""
kwargs = {'slug': getattr(settings, 'WAKAWAKA_DEFAULT_INDEX', 'WikiIndex')}
redirect_to = reverse('wakawaka_page', kwargs=kwargs)
return HttpResponseRedirect(redirect_to) | [
"Redirects",
"to",
"the",
"default",
"wiki",
"index",
"name",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L21-L27 | [
"def",
"index",
"(",
"request",
")",
":",
"kwargs",
"=",
"{",
"'slug'",
":",
"getattr",
"(",
"settings",
",",
"'WAKAWAKA_DEFAULT_INDEX'",
",",
"'WikiIndex'",
")",
"}",
"redirect_to",
"=",
"reverse",
"(",
"'wakawaka_page'",
",",
"kwargs",
"=",
"kwargs",
")",
... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | page | Displays a wiki page. Redirects to the edit view if the page doesn't exist. | wakawaka/views.py | def page(
request,
slug,
rev_id=None,
template_name='wakawaka/page.html',
extra_context=None,
):
"""
Displays a wiki page. Redirects to the edit view if the page doesn't exist.
"""
try:
queryset = WikiPage.objects.all()
page = queryset.get(slug=slug)
rev = pag... | def page(
request,
slug,
rev_id=None,
template_name='wakawaka/page.html',
extra_context=None,
):
"""
Displays a wiki page. Redirects to the edit view if the page doesn't exist.
"""
try:
queryset = WikiPage.objects.all()
page = queryset.get(slug=slug)
rev = pag... | [
"Displays",
"a",
"wiki",
"page",
".",
"Redirects",
"to",
"the",
"edit",
"view",
"if",
"the",
"page",
"doesn",
"t",
"exist",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L30-L63 | [
"def",
"page",
"(",
"request",
",",
"slug",
",",
"rev_id",
"=",
"None",
",",
"template_name",
"=",
"'wakawaka/page.html'",
",",
"extra_context",
"=",
"None",
",",
")",
":",
"try",
":",
"queryset",
"=",
"WikiPage",
".",
"objects",
".",
"all",
"(",
")",
... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | edit | Displays the form for editing and deleting a page. | wakawaka/views.py | def edit(
request,
slug,
rev_id=None,
template_name='wakawaka/edit.html',
extra_context=None,
wiki_page_form=WikiPageForm,
wiki_delete_form=DeleteWikiPageForm,
):
"""
Displays the form for editing and deleting a page.
"""
# Get the page for slug and get a specific revision, i... | def edit(
request,
slug,
rev_id=None,
template_name='wakawaka/edit.html',
extra_context=None,
wiki_page_form=WikiPageForm,
wiki_delete_form=DeleteWikiPageForm,
):
"""
Displays the form for editing and deleting a page.
"""
# Get the page for slug and get a specific revision, i... | [
"Displays",
"the",
"form",
"for",
"editing",
"and",
"deleting",
"a",
"page",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L66-L178 | [
"def",
"edit",
"(",
"request",
",",
"slug",
",",
"rev_id",
"=",
"None",
",",
"template_name",
"=",
"'wakawaka/edit.html'",
",",
"extra_context",
"=",
"None",
",",
"wiki_page_form",
"=",
"WikiPageForm",
",",
"wiki_delete_form",
"=",
"DeleteWikiPageForm",
",",
")"... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | revisions | Displays the list of all revisions for a specific WikiPage | wakawaka/views.py | def revisions(
request, slug, template_name='wakawaka/revisions.html', extra_context=None
):
"""
Displays the list of all revisions for a specific WikiPage
"""
queryset = WikiPage.objects.all()
page = get_object_or_404(queryset, slug=slug)
template_context = {'page': page}
template_cont... | def revisions(
request, slug, template_name='wakawaka/revisions.html', extra_context=None
):
"""
Displays the list of all revisions for a specific WikiPage
"""
queryset = WikiPage.objects.all()
page = get_object_or_404(queryset, slug=slug)
template_context = {'page': page}
template_cont... | [
"Displays",
"the",
"list",
"of",
"all",
"revisions",
"for",
"a",
"specific",
"WikiPage"
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L181-L192 | [
"def",
"revisions",
"(",
"request",
",",
"slug",
",",
"template_name",
"=",
"'wakawaka/revisions.html'",
",",
"extra_context",
"=",
"None",
")",
":",
"queryset",
"=",
"WikiPage",
".",
"objects",
".",
"all",
"(",
")",
"page",
"=",
"get_object_or_404",
"(",
"q... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | changes | Displays the changes between two revisions. | wakawaka/views.py | def changes(
request, slug, template_name='wakawaka/changes.html', extra_context=None
):
"""
Displays the changes between two revisions.
"""
rev_a_id = request.GET.get('a', None)
rev_b_id = request.GET.get('b', None)
# Some stinky fingers manipulated the url
if not rev_a_id or not rev_b... | def changes(
request, slug, template_name='wakawaka/changes.html', extra_context=None
):
"""
Displays the changes between two revisions.
"""
rev_a_id = request.GET.get('a', None)
rev_b_id = request.GET.get('b', None)
# Some stinky fingers manipulated the url
if not rev_a_id or not rev_b... | [
"Displays",
"the",
"changes",
"between",
"two",
"revisions",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L195-L236 | [
"def",
"changes",
"(",
"request",
",",
"slug",
",",
"template_name",
"=",
"'wakawaka/changes.html'",
",",
"extra_context",
"=",
"None",
")",
":",
"rev_a_id",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'a'",
",",
"None",
")",
"rev_b_id",
"=",
"request",
... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | revision_list | Displays a list of all recent revisions. | wakawaka/views.py | def revision_list(
request, template_name='wakawaka/revision_list.html', extra_context=None
):
"""
Displays a list of all recent revisions.
"""
revision_list = Revision.objects.all()
template_context = {'revision_list': revision_list}
template_context.update(extra_context or {})
return r... | def revision_list(
request, template_name='wakawaka/revision_list.html', extra_context=None
):
"""
Displays a list of all recent revisions.
"""
revision_list = Revision.objects.all()
template_context = {'revision_list': revision_list}
template_context.update(extra_context or {})
return r... | [
"Displays",
"a",
"list",
"of",
"all",
"recent",
"revisions",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L240-L249 | [
"def",
"revision_list",
"(",
"request",
",",
"template_name",
"=",
"'wakawaka/revision_list.html'",
",",
"extra_context",
"=",
"None",
")",
":",
"revision_list",
"=",
"Revision",
".",
"objects",
".",
"all",
"(",
")",
"template_context",
"=",
"{",
"'revision_list'"... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | page_list | Displays all Pages | wakawaka/views.py | def page_list(
request, template_name='wakawaka/page_list.html', extra_context=None
):
"""
Displays all Pages
"""
page_list = WikiPage.objects.all()
page_list = page_list.order_by('slug')
template_context = {
'page_list': page_list,
'index_slug': getattr(settings, 'WAKAWAKA_... | def page_list(
request, template_name='wakawaka/page_list.html', extra_context=None
):
"""
Displays all Pages
"""
page_list = WikiPage.objects.all()
page_list = page_list.order_by('slug')
template_context = {
'page_list': page_list,
'index_slug': getattr(settings, 'WAKAWAKA_... | [
"Displays",
"all",
"Pages"
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/views.py#L252-L266 | [
"def",
"page_list",
"(",
"request",
",",
"template_name",
"=",
"'wakawaka/page_list.html'",
",",
"extra_context",
"=",
"None",
")",
":",
"page_list",
"=",
"WikiPage",
".",
"objects",
".",
"all",
"(",
")",
"page_list",
"=",
"page_list",
".",
"order_by",
"(",
... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | DeleteWikiPageForm.delete_wiki | Deletes the page with all revisions or the revision, based on the
users choice.
Returns a HttpResponseRedirect. | wakawaka/forms.py | def delete_wiki(self, request, page, rev):
"""
Deletes the page with all revisions or the revision, based on the
users choice.
Returns a HttpResponseRedirect.
"""
# Delete the page
if (
self.cleaned_data.get('delete') == 'page'
and reques... | def delete_wiki(self, request, page, rev):
"""
Deletes the page with all revisions or the revision, based on the
users choice.
Returns a HttpResponseRedirect.
"""
# Delete the page
if (
self.cleaned_data.get('delete') == 'page'
and reques... | [
"Deletes",
"the",
"page",
"with",
"all",
"revisions",
"or",
"the",
"revision",
"based",
"on",
"the",
"users",
"choice",
"."
] | bartTC/django-wakawaka | python | https://github.com/bartTC/django-wakawaka/blob/95daff9703a1de07d3393e4b2145bcb903f80e72/wakawaka/forms.py#L62-L131 | [
"def",
"delete_wiki",
"(",
"self",
",",
"request",
",",
"page",
",",
"rev",
")",
":",
"# Delete the page",
"if",
"(",
"self",
".",
"cleaned_data",
".",
"get",
"(",
"'delete'",
")",
"==",
"'page'",
"and",
"request",
".",
"user",
".",
"has_perm",
"(",
"'... | 95daff9703a1de07d3393e4b2145bcb903f80e72 |
train | get_real_field | Get the real field from a model given its name.
Handle nested models recursively (aka. ``__`` lookups) | eztables/views.py | def get_real_field(model, field_name):
'''
Get the real field from a model given its name.
Handle nested models recursively (aka. ``__`` lookups)
'''
parts = field_name.split('__')
field = model._meta.get_field(parts[0])
if len(parts) == 1:
return model._meta.get_field(field_name)
... | def get_real_field(model, field_name):
'''
Get the real field from a model given its name.
Handle nested models recursively (aka. ``__`` lookups)
'''
parts = field_name.split('__')
field = model._meta.get_field(parts[0])
if len(parts) == 1:
return model._meta.get_field(field_name)
... | [
"Get",
"the",
"real",
"field",
"from",
"a",
"model",
"given",
"its",
"name",
"."
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L35-L48 | [
"def",
"get_real_field",
"(",
"model",
",",
"field_name",
")",
":",
"parts",
"=",
"field_name",
".",
"split",
"(",
"'__'",
")",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"parts",
"[",
"0",
"]",
")",
"if",
"len",
"(",
"parts",
")",
... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.can_regex | Test if a given field supports regex lookups | eztables/views.py | def can_regex(self, field):
'''Test if a given field supports regex lookups'''
from django.conf import settings
if settings.DATABASES['default']['ENGINE'].endswith('sqlite3'):
return not isinstance(get_real_field(self.model, field), UNSUPPORTED_REGEX_FIELDS)
else:
... | def can_regex(self, field):
'''Test if a given field supports regex lookups'''
from django.conf import settings
if settings.DATABASES['default']['ENGINE'].endswith('sqlite3'):
return not isinstance(get_real_field(self.model, field), UNSUPPORTED_REGEX_FIELDS)
else:
... | [
"Test",
"if",
"a",
"given",
"field",
"supports",
"regex",
"lookups"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L95-L101 | [
"def",
"can_regex",
"(",
"self",
",",
"field",
")",
":",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"settings",
".",
"DATABASES",
"[",
"'default'",
"]",
"[",
"'ENGINE'",
"]",
".",
"endswith",
"(",
"'sqlite3'",
")",
":",
"return",
"not",
... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.get_orders | Get ordering fields for ``QuerySet.order_by`` | eztables/views.py | def get_orders(self):
'''Get ordering fields for ``QuerySet.order_by``'''
orders = []
iSortingCols = self.dt_data['iSortingCols']
dt_orders = [(self.dt_data['iSortCol_%s' % i], self.dt_data['sSortDir_%s' % i]) for i in xrange(iSortingCols)]
for field_idx, field_dir in dt_orders:
... | def get_orders(self):
'''Get ordering fields for ``QuerySet.order_by``'''
orders = []
iSortingCols = self.dt_data['iSortingCols']
dt_orders = [(self.dt_data['iSortCol_%s' % i], self.dt_data['sSortDir_%s' % i]) for i in xrange(iSortingCols)]
for field_idx, field_dir in dt_orders:
... | [
"Get",
"ordering",
"fields",
"for",
"QuerySet",
".",
"order_by"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L103-L124 | [
"def",
"get_orders",
"(",
"self",
")",
":",
"orders",
"=",
"[",
"]",
"iSortingCols",
"=",
"self",
".",
"dt_data",
"[",
"'iSortingCols'",
"]",
"dt_orders",
"=",
"[",
"(",
"self",
".",
"dt_data",
"[",
"'iSortCol_%s'",
"%",
"i",
"]",
",",
"self",
".",
"... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.global_search | Filter a queryset with global search | eztables/views.py | def global_search(self, queryset):
'''Filter a queryset with global search'''
search = self.dt_data['sSearch']
if search:
if self.dt_data['bRegex']:
criterions = [
Q(**{'%s__iregex' % field: search})
for field in self.get_db_fie... | def global_search(self, queryset):
'''Filter a queryset with global search'''
search = self.dt_data['sSearch']
if search:
if self.dt_data['bRegex']:
criterions = [
Q(**{'%s__iregex' % field: search})
for field in self.get_db_fie... | [
"Filter",
"a",
"queryset",
"with",
"global",
"search"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L126-L144 | [
"def",
"global_search",
"(",
"self",
",",
"queryset",
")",
":",
"search",
"=",
"self",
".",
"dt_data",
"[",
"'sSearch'",
"]",
"if",
"search",
":",
"if",
"self",
".",
"dt_data",
"[",
"'bRegex'",
"]",
":",
"criterions",
"=",
"[",
"Q",
"(",
"*",
"*",
... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.column_search | Filter a queryset with column search | eztables/views.py | def column_search(self, queryset):
'''Filter a queryset with column search'''
for idx in xrange(self.dt_data['iColumns']):
search = self.dt_data['sSearch_%s' % idx]
if search:
if hasattr(self, 'search_col_%s' % idx):
custom_search = getattr(sel... | def column_search(self, queryset):
'''Filter a queryset with column search'''
for idx in xrange(self.dt_data['iColumns']):
search = self.dt_data['sSearch_%s' % idx]
if search:
if hasattr(self, 'search_col_%s' % idx):
custom_search = getattr(sel... | [
"Filter",
"a",
"queryset",
"with",
"column",
"search"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L146-L167 | [
"def",
"column_search",
"(",
"self",
",",
"queryset",
")",
":",
"for",
"idx",
"in",
"xrange",
"(",
"self",
".",
"dt_data",
"[",
"'iColumns'",
"]",
")",
":",
"search",
"=",
"self",
".",
"dt_data",
"[",
"'sSearch_%s'",
"%",
"idx",
"]",
"if",
"search",
... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.get_queryset | Apply Datatables sort and search criterion to QuerySet | eztables/views.py | def get_queryset(self):
'''Apply Datatables sort and search criterion to QuerySet'''
qs = super(DatatablesView, self).get_queryset()
# Perform global search
qs = self.global_search(qs)
# Perform column search
qs = self.column_search(qs)
# Return the ordered querys... | def get_queryset(self):
'''Apply Datatables sort and search criterion to QuerySet'''
qs = super(DatatablesView, self).get_queryset()
# Perform global search
qs = self.global_search(qs)
# Perform column search
qs = self.column_search(qs)
# Return the ordered querys... | [
"Apply",
"Datatables",
"sort",
"and",
"search",
"criterion",
"to",
"QuerySet"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L169-L177 | [
"def",
"get_queryset",
"(",
"self",
")",
":",
"qs",
"=",
"super",
"(",
"DatatablesView",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"# Perform global search",
"qs",
"=",
"self",
".",
"global_search",
"(",
"qs",
")",
"# Perform column search",
"qs",
"="... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.get_page | Get the requested page | eztables/views.py | def get_page(self, form):
'''Get the requested page'''
page_size = form.cleaned_data['iDisplayLength']
start_index = form.cleaned_data['iDisplayStart']
paginator = Paginator(self.object_list, page_size)
num_page = (start_index / page_size) + 1
return paginator.page(num_pa... | def get_page(self, form):
'''Get the requested page'''
page_size = form.cleaned_data['iDisplayLength']
start_index = form.cleaned_data['iDisplayStart']
paginator = Paginator(self.object_list, page_size)
num_page = (start_index / page_size) + 1
return paginator.page(num_pa... | [
"Get",
"the",
"requested",
"page"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L179-L185 | [
"def",
"get_page",
"(",
"self",
",",
"form",
")",
":",
"page_size",
"=",
"form",
".",
"cleaned_data",
"[",
"'iDisplayLength'",
"]",
"start_index",
"=",
"form",
".",
"cleaned_data",
"[",
"'iDisplayStart'",
"]",
"paginator",
"=",
"Paginator",
"(",
"self",
".",... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.get_row | Format a single row (if necessary) | eztables/views.py | def get_row(self, row):
'''Format a single row (if necessary)'''
if isinstance(self.fields, dict):
return dict([
(key, text_type(value).format(**row) if RE_FORMATTED.match(value) else row[value])
for key, value in self.fields.items()
])
el... | def get_row(self, row):
'''Format a single row (if necessary)'''
if isinstance(self.fields, dict):
return dict([
(key, text_type(value).format(**row) if RE_FORMATTED.match(value) else row[value])
for key, value in self.fields.items()
])
el... | [
"Format",
"a",
"single",
"row",
"(",
"if",
"necessary",
")"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L191-L202 | [
"def",
"get_row",
"(",
"self",
",",
"row",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"fields",
",",
"dict",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"key",
",",
"text_type",
"(",
"value",
")",
".",
"format",
"(",
"*",
"*",
"row",
")",
"... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | DatatablesView.render_to_response | Render Datatables expected JSON format | eztables/views.py | def render_to_response(self, form, **kwargs):
'''Render Datatables expected JSON format'''
page = self.get_page(form)
data = {
'iTotalRecords': page.paginator.count,
'iTotalDisplayRecords': page.paginator.count,
'sEcho': form.cleaned_data['sEcho'],
... | def render_to_response(self, form, **kwargs):
'''Render Datatables expected JSON format'''
page = self.get_page(form)
data = {
'iTotalRecords': page.paginator.count,
'iTotalDisplayRecords': page.paginator.count,
'sEcho': form.cleaned_data['sEcho'],
... | [
"Render",
"Datatables",
"expected",
"JSON",
"format"
] | noirbizarre/django-eztables | python | https://github.com/noirbizarre/django-eztables/blob/347e74dcc08121d20f4cf942181d873dbe33b995/eztables/views.py#L204-L213 | [
"def",
"render_to_response",
"(",
"self",
",",
"form",
",",
"*",
"*",
"kwargs",
")",
":",
"page",
"=",
"self",
".",
"get_page",
"(",
"form",
")",
"data",
"=",
"{",
"'iTotalRecords'",
":",
"page",
".",
"paginator",
".",
"count",
",",
"'iTotalDisplayRecord... | 347e74dcc08121d20f4cf942181d873dbe33b995 |
train | Dailymotion.set_grant_type | Grant types:
- token:
An authorization is requested to the end-user by redirecting it to an authorization page hosted
on Dailymotion. Once authorized, a refresh token is requested by the API client to the token
server and stored in the end-user's cookie (or other storage tec... | dailymotion.py | def set_grant_type(self, grant_type = 'client_credentials', api_key=None, api_secret=None, scope=None, info=None):
"""
Grant types:
- token:
An authorization is requested to the end-user by redirecting it to an authorization page hosted
on Dailymotion. Once authorized, ... | def set_grant_type(self, grant_type = 'client_credentials', api_key=None, api_secret=None, scope=None, info=None):
"""
Grant types:
- token:
An authorization is requested to the end-user by redirecting it to an authorization page hosted
on Dailymotion. Once authorized, ... | [
"Grant",
"types",
":",
"-",
"token",
":",
"An",
"authorization",
"is",
"requested",
"to",
"the",
"end",
"-",
"user",
"by",
"redirecting",
"it",
"to",
"an",
"authorization",
"page",
"hosted",
"on",
"Dailymotion",
".",
"Once",
"authorized",
"a",
"refresh",
"... | dailymotion/dailymotion-sdk-python | python | https://github.com/dailymotion/dailymotion-sdk-python/blob/944a8a474119c87d351504b0865e21216e286559/dailymotion.py#L164-L215 | [
"def",
"set_grant_type",
"(",
"self",
",",
"grant_type",
"=",
"'client_credentials'",
",",
"api_key",
"=",
"None",
",",
"api_secret",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"info",
"=",
"None",
")",
":",
"self",
".",
"access_token",
"=",
"None",
"i... | 944a8a474119c87d351504b0865e21216e286559 |
train | authenticated | Decorator to check if Smappee's access token has expired.
If it has, use the refresh token to request a new access token | smappy/smappy.py | def authenticated(func):
"""
Decorator to check if Smappee's access token has expired.
If it has, use the refresh token to request a new access token
"""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.refresh_token is not None and \
self.token_expira... | def authenticated(func):
"""
Decorator to check if Smappee's access token has expired.
If it has, use the refresh token to request a new access token
"""
@wraps(func)
def wrapper(*args, **kwargs):
self = args[0]
if self.refresh_token is not None and \
self.token_expira... | [
"Decorator",
"to",
"check",
"if",
"Smappee",
"s",
"access",
"token",
"has",
"expired",
".",
"If",
"it",
"has",
"use",
"the",
"refresh",
"token",
"to",
"request",
"a",
"new",
"access",
"token"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L18-L30 | [
"def",
"authenticated",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
"=",
"args",
"[",
"0",
"]",
"if",
"self",
".",
"refresh_token",
"is",
"not",
"None",
"an... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | urljoin | Join terms together with forward slashes
Parameters
----------
parts
Returns
-------
str | smappy/smappy.py | def urljoin(*parts):
"""
Join terms together with forward slashes
Parameters
----------
parts
Returns
-------
str
"""
# first strip extra forward slashes (except http:// and the likes) and
# create list
part_list = []
for part in parts:
p = str(part)
... | def urljoin(*parts):
"""
Join terms together with forward slashes
Parameters
----------
parts
Returns
-------
str
"""
# first strip extra forward slashes (except http:// and the likes) and
# create list
part_list = []
for part in parts:
p = str(part)
... | [
"Join",
"terms",
"together",
"with",
"forward",
"slashes"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L806-L830 | [
"def",
"urljoin",
"(",
"*",
"parts",
")",
":",
"# first strip extra forward slashes (except http:// and the likes) and",
"# create list",
"part_list",
"=",
"[",
"]",
"for",
"part",
"in",
"parts",
":",
"p",
"=",
"str",
"(",
"part",
")",
"if",
"p",
".",
"endswith"... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.authenticate | Uses a Smappee username and password to request an access token,
refresh token and expiry date.
Parameters
----------
username : str
password : str
Returns
-------
requests.Response
access token is saved in self.access_token
refre... | smappy/smappy.py | def authenticate(self, username, password):
"""
Uses a Smappee username and password to request an access token,
refresh token and expiry date.
Parameters
----------
username : str
password : str
Returns
-------
requests.Response
... | def authenticate(self, username, password):
"""
Uses a Smappee username and password to request an access token,
refresh token and expiry date.
Parameters
----------
username : str
password : str
Returns
-------
requests.Response
... | [
"Uses",
"a",
"Smappee",
"username",
"and",
"password",
"to",
"request",
"an",
"access",
"token",
"refresh",
"token",
"and",
"expiry",
"date",
"."
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L57-L89 | [
"def",
"authenticate",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"url",
"=",
"URLS",
"[",
"'token'",
"]",
"data",
"=",
"{",
"\"grant_type\"",
":",
"\"password\"",
",",
"\"client_id\"",
":",
"self",
".",
"client_id",
",",
"\"client_secret\"",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee._set_token_expiration_time | Saves the token expiration time by adding the 'expires in' parameter
to the current datetime (in utc).
Parameters
----------
expires_in : int
number of seconds from the time of the request until expiration
Returns
-------
nothing
saves ex... | smappy/smappy.py | def _set_token_expiration_time(self, expires_in):
"""
Saves the token expiration time by adding the 'expires in' parameter
to the current datetime (in utc).
Parameters
----------
expires_in : int
number of seconds from the time of the request until expiration... | def _set_token_expiration_time(self, expires_in):
"""
Saves the token expiration time by adding the 'expires in' parameter
to the current datetime (in utc).
Parameters
----------
expires_in : int
number of seconds from the time of the request until expiration... | [
"Saves",
"the",
"token",
"expiration",
"time",
"by",
"adding",
"the",
"expires",
"in",
"parameter",
"to",
"the",
"current",
"datetime",
"(",
"in",
"utc",
")",
"."
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L91-L108 | [
"def",
"_set_token_expiration_time",
"(",
"self",
",",
"expires_in",
")",
":",
"self",
".",
"token_expiration_time",
"=",
"dt",
".",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"dt",
".",
"timedelta",
"(",
"0",
",",
"expires_in",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_service_locations | Request service locations
Returns
-------
dict | smappy/smappy.py | def get_service_locations(self):
"""
Request service locations
Returns
-------
dict
"""
url = URLS['servicelocation']
headers = {"Authorization": "Bearer {}".format(self.access_token)}
r = requests.get(url, headers=headers)
r.raise_for_sta... | def get_service_locations(self):
"""
Request service locations
Returns
-------
dict
"""
url = URLS['servicelocation']
headers = {"Authorization": "Bearer {}".format(self.access_token)}
r = requests.get(url, headers=headers)
r.raise_for_sta... | [
"Request",
"service",
"locations"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L139-L151 | [
"def",
"get_service_locations",
"(",
"self",
")",
":",
"url",
"=",
"URLS",
"[",
"'servicelocation'",
"]",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"\"Bearer {}\"",
".",
"format",
"(",
"self",
".",
"access_token",
")",
"}",
"r",
"=",
"requests",
".",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_service_location_info | Request service location info
Parameters
----------
service_location_id : int
Returns
-------
dict | smappy/smappy.py | def get_service_location_info(self, service_location_id):
"""
Request service location info
Parameters
----------
service_location_id : int
Returns
-------
dict
"""
url = urljoin(URLS['servicelocation'], service_location_id, "info")
... | def get_service_location_info(self, service_location_id):
"""
Request service location info
Parameters
----------
service_location_id : int
Returns
-------
dict
"""
url = urljoin(URLS['servicelocation'], service_location_id, "info")
... | [
"Request",
"service",
"location",
"info"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L154-L170 | [
"def",
"get_service_location_info",
"(",
"self",
",",
"service_location_id",
")",
":",
"url",
"=",
"urljoin",
"(",
"URLS",
"[",
"'servicelocation'",
"]",
",",
"service_location_id",
",",
"\"info\"",
")",
"headers",
"=",
"{",
"\"Authorization\"",
":",
"\"Bearer {}\... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_consumption | Request Elektricity consumption and Solar production
for a given service location.
Parameters
----------
service_location_id : int
start : int | dt.datetime | pd.Timestamp
end : int | dt.datetime | pd.Timestamp
start and end support epoch (in milliseconds),
... | smappy/smappy.py | def get_consumption(self, service_location_id, start, end, aggregation, raw=False):
"""
Request Elektricity consumption and Solar production
for a given service location.
Parameters
----------
service_location_id : int
start : int | dt.datetime | pd.Timestamp
... | def get_consumption(self, service_location_id, start, end, aggregation, raw=False):
"""
Request Elektricity consumption and Solar production
for a given service location.
Parameters
----------
service_location_id : int
start : int | dt.datetime | pd.Timestamp
... | [
"Request",
"Elektricity",
"consumption",
"and",
"Solar",
"production",
"for",
"a",
"given",
"service",
"location",
"."
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L173-L213 | [
"def",
"get_consumption",
"(",
"self",
",",
"service_location_id",
",",
"start",
",",
"end",
",",
"aggregation",
",",
"raw",
"=",
"False",
")",
":",
"url",
"=",
"urljoin",
"(",
"URLS",
"[",
"'servicelocation'",
"]",
",",
"service_location_id",
",",
"\"consum... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_sensor_consumption | Request consumption for a given sensor in a given service location
Parameters
----------
service_location_id : int
sensor_id : int
start : int | dt.datetime | pd.Timestamp
end : int | dt.datetime | pd.Timestamp
start and end support epoch (in milliseconds),
... | smappy/smappy.py | def get_sensor_consumption(self, service_location_id, sensor_id, start,
end, aggregation):
"""
Request consumption for a given sensor in a given service location
Parameters
----------
service_location_id : int
sensor_id : int
start ... | def get_sensor_consumption(self, service_location_id, sensor_id, start,
end, aggregation):
"""
Request consumption for a given sensor in a given service location
Parameters
----------
service_location_id : int
sensor_id : int
start ... | [
"Request",
"consumption",
"for",
"a",
"given",
"sensor",
"in",
"a",
"given",
"service",
"location"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L216-L244 | [
"def",
"get_sensor_consumption",
"(",
"self",
",",
"service_location_id",
",",
"sensor_id",
",",
"start",
",",
"end",
",",
"aggregation",
")",
":",
"url",
"=",
"urljoin",
"(",
"URLS",
"[",
"'servicelocation'",
"]",
",",
"service_location_id",
",",
"\"sensor\"",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee._get_consumption | Request for both the get_consumption and
get_sensor_consumption methods.
Parameters
----------
url : str
start : dt.datetime
end : dt.datetime
aggregation : int
Returns
-------
dict | smappy/smappy.py | def _get_consumption(self, url, start, end, aggregation):
"""
Request for both the get_consumption and
get_sensor_consumption methods.
Parameters
----------
url : str
start : dt.datetime
end : dt.datetime
aggregation : int
Returns
... | def _get_consumption(self, url, start, end, aggregation):
"""
Request for both the get_consumption and
get_sensor_consumption methods.
Parameters
----------
url : str
start : dt.datetime
end : dt.datetime
aggregation : int
Returns
... | [
"Request",
"for",
"both",
"the",
"get_consumption",
"and",
"get_sensor_consumption",
"methods",
"."
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L246-L273 | [
"def",
"_get_consumption",
"(",
"self",
",",
"url",
",",
"start",
",",
"end",
",",
"aggregation",
")",
":",
"start",
"=",
"self",
".",
"_to_milliseconds",
"(",
"start",
")",
"end",
"=",
"self",
".",
"_to_milliseconds",
"(",
"end",
")",
"headers",
"=",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_events | Request events for a given appliance
Parameters
----------
service_location_id : int
appliance_id : int
start : int | dt.datetime | pd.Timestamp
end : int | dt.datetime | pd.Timestamp
start and end support epoch (in milliseconds),
datetime and Pan... | smappy/smappy.py | def get_events(self, service_location_id, appliance_id, start, end,
max_number=None):
"""
Request events for a given appliance
Parameters
----------
service_location_id : int
appliance_id : int
start : int | dt.datetime | pd.Timestamp
e... | def get_events(self, service_location_id, appliance_id, start, end,
max_number=None):
"""
Request events for a given appliance
Parameters
----------
service_location_id : int
appliance_id : int
start : int | dt.datetime | pd.Timestamp
e... | [
"Request",
"events",
"for",
"a",
"given",
"appliance"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L276-L311 | [
"def",
"get_events",
"(",
"self",
",",
"service_location_id",
",",
"appliance_id",
",",
"start",
",",
"end",
",",
"max_number",
"=",
"None",
")",
":",
"start",
"=",
"self",
".",
"_to_milliseconds",
"(",
"start",
")",
"end",
"=",
"self",
".",
"_to_milliseco... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.actuator_on | Turn actuator on
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuator
should be turned on. Any other value results in turning on for an
un... | smappy/smappy.py | def actuator_on(self, service_location_id, actuator_id, duration=None):
"""
Turn actuator on
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuator
... | def actuator_on(self, service_location_id, actuator_id, duration=None):
"""
Turn actuator on
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuator
... | [
"Turn",
"actuator",
"on"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L314-L333 | [
"def",
"actuator_on",
"(",
"self",
",",
"service_location_id",
",",
"actuator_id",
",",
"duration",
"=",
"None",
")",
":",
"return",
"self",
".",
"_actuator_on_off",
"(",
"on_off",
"=",
"'on'",
",",
"service_location_id",
"=",
"service_location_id",
",",
"actuat... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.actuator_off | Turn actuator off
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuator
should be turned on. Any other value results in turning on for an
u... | smappy/smappy.py | def actuator_off(self, service_location_id, actuator_id, duration=None):
"""
Turn actuator off
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuato... | def actuator_off(self, service_location_id, actuator_id, duration=None):
"""
Turn actuator off
Parameters
----------
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuato... | [
"Turn",
"actuator",
"off"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L336-L355 | [
"def",
"actuator_off",
"(",
"self",
",",
"service_location_id",
",",
"actuator_id",
",",
"duration",
"=",
"None",
")",
":",
"return",
"self",
".",
"_actuator_on_off",
"(",
"on_off",
"=",
"'off'",
",",
"service_location_id",
"=",
"service_location_id",
",",
"actu... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee._actuator_on_off | Turn actuator on or off
Parameters
----------
on_off : str
'on' or 'off'
service_location_id : int
actuator_id : int
duration : int, optional
300,900,1800 or 3600 , specifying the time in seconds the actuator
should be turned on. Any o... | smappy/smappy.py | def _actuator_on_off(self, on_off, service_location_id, actuator_id,
duration=None):
"""
Turn actuator on or off
Parameters
----------
on_off : str
'on' or 'off'
service_location_id : int
actuator_id : int
duration : i... | def _actuator_on_off(self, on_off, service_location_id, actuator_id,
duration=None):
"""
Turn actuator on or off
Parameters
----------
on_off : str
'on' or 'off'
service_location_id : int
actuator_id : int
duration : i... | [
"Turn",
"actuator",
"on",
"or",
"off"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L357-L386 | [
"def",
"_actuator_on_off",
"(",
"self",
",",
"on_off",
",",
"service_location_id",
",",
"actuator_id",
",",
"duration",
"=",
"None",
")",
":",
"url",
"=",
"urljoin",
"(",
"URLS",
"[",
"'servicelocation'",
"]",
",",
"service_location_id",
",",
"\"actuator\"",
"... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee.get_consumption_dataframe | Extends get_consumption() AND get_sensor_consumption(),
parses the results in a Pandas DataFrame
Parameters
----------
service_location_id : int
start : dt.datetime | int
end : dt.datetime | int
timezone-naive datetimes are assumed to be in UTC
ep... | smappy/smappy.py | def get_consumption_dataframe(self, service_location_id, start, end,
aggregation, sensor_id=None, localize=False,
raw=False):
"""
Extends get_consumption() AND get_sensor_consumption(),
parses the results in a Pandas DataFrame
... | def get_consumption_dataframe(self, service_location_id, start, end,
aggregation, sensor_id=None, localize=False,
raw=False):
"""
Extends get_consumption() AND get_sensor_consumption(),
parses the results in a Pandas DataFrame
... | [
"Extends",
"get_consumption",
"()",
"AND",
"get_sensor_consumption",
"()",
"parses",
"the",
"results",
"in",
"a",
"Pandas",
"DataFrame"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L388-L450 | [
"def",
"get_consumption_dataframe",
"(",
"self",
",",
"service_location_id",
",",
"start",
",",
"end",
",",
"aggregation",
",",
"sensor_id",
"=",
"None",
",",
"localize",
"=",
"False",
",",
"raw",
"=",
"False",
")",
":",
"import",
"pandas",
"as",
"pd",
"if... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | Smappee._to_milliseconds | Converts a datetime-like object to epoch, in milliseconds
Timezone-naive datetime objects are assumed to be in UTC
Parameters
----------
time : dt.datetime | pd.Timestamp | int
Returns
-------
int
epoch milliseconds | smappy/smappy.py | def _to_milliseconds(self, time):
"""
Converts a datetime-like object to epoch, in milliseconds
Timezone-naive datetime objects are assumed to be in UTC
Parameters
----------
time : dt.datetime | pd.Timestamp | int
Returns
-------
int
... | def _to_milliseconds(self, time):
"""
Converts a datetime-like object to epoch, in milliseconds
Timezone-naive datetime objects are assumed to be in UTC
Parameters
----------
time : dt.datetime | pd.Timestamp | int
Returns
-------
int
... | [
"Converts",
"a",
"datetime",
"-",
"like",
"object",
"to",
"epoch",
"in",
"milliseconds",
"Timezone",
"-",
"naive",
"datetime",
"objects",
"are",
"assumed",
"to",
"be",
"in",
"UTC"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L452-L474 | [
"def",
"_to_milliseconds",
"(",
"self",
",",
"time",
")",
":",
"if",
"isinstance",
"(",
"time",
",",
"dt",
".",
"datetime",
")",
":",
"if",
"time",
".",
"tzinfo",
"is",
"None",
":",
"time",
"=",
"time",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
"... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee._basic_post | Because basically every post request is the same
Parameters
----------
url : str
data : str, optional
Returns
-------
requests.Response | smappy/smappy.py | def _basic_post(self, url, data=None):
"""
Because basically every post request is the same
Parameters
----------
url : str
data : str, optional
Returns
-------
requests.Response
"""
_url = urljoin(self.base_url, url)
r = ... | def _basic_post(self, url, data=None):
"""
Because basically every post request is the same
Parameters
----------
url : str
data : str, optional
Returns
-------
requests.Response
"""
_url = urljoin(self.base_url, url)
r = ... | [
"Because",
"basically",
"every",
"post",
"request",
"is",
"the",
"same"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L516-L532 | [
"def",
"_basic_post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
")",
":",
"_url",
"=",
"urljoin",
"(",
"self",
".",
"base_url",
",",
"url",
")",
"r",
"=",
"self",
".",
"session",
".",
"post",
"(",
"_url",
",",
"data",
"=",
"data",
",",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.logon | Parameters
----------
password : str
default 'admin'
Returns
-------
dict | smappy/smappy.py | def logon(self, password='admin'):
"""
Parameters
----------
password : str
default 'admin'
Returns
-------
dict
"""
r = self._basic_post(url='logon', data=password)
return r.json() | def logon(self, password='admin'):
"""
Parameters
----------
password : str
default 'admin'
Returns
-------
dict
"""
r = self._basic_post(url='logon', data=password)
return r.json() | [
"Parameters",
"----------",
"password",
":",
"str",
"default",
"admin"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L541-L553 | [
"def",
"logon",
"(",
"self",
",",
"password",
"=",
"'admin'",
")",
":",
"r",
"=",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'logon'",
",",
"data",
"=",
"password",
")",
"return",
"r",
".",
"json",
"(",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.active_power | Takes the sum of all instantaneous active power values
Returns them in kWh
Returns
-------
float | smappy/smappy.py | def active_power(self):
"""
Takes the sum of all instantaneous active power values
Returns them in kWh
Returns
-------
float
"""
inst = self.load_instantaneous()
values = [float(i['value']) for i in inst if i['key'].endswith('ActivePower')]
... | def active_power(self):
"""
Takes the sum of all instantaneous active power values
Returns them in kWh
Returns
-------
float
"""
inst = self.load_instantaneous()
values = [float(i['value']) for i in inst if i['key'].endswith('ActivePower')]
... | [
"Takes",
"the",
"sum",
"of",
"all",
"instantaneous",
"active",
"power",
"values",
"Returns",
"them",
"in",
"kWh"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L573-L584 | [
"def",
"active_power",
"(",
"self",
")",
":",
"inst",
"=",
"self",
".",
"load_instantaneous",
"(",
")",
"values",
"=",
"[",
"float",
"(",
"i",
"[",
"'value'",
"]",
")",
"for",
"i",
"in",
"inst",
"if",
"i",
"[",
"'key'",
"]",
".",
"endswith",
"(",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.active_cosfi | Takes the average of all instantaneous cosfi values
Returns
-------
float | smappy/smappy.py | def active_cosfi(self):
"""
Takes the average of all instantaneous cosfi values
Returns
-------
float
"""
inst = self.load_instantaneous()
values = [float(i['value']) for i in inst if i['key'].endswith('Cosfi')]
return sum(values) / len(values) | def active_cosfi(self):
"""
Takes the average of all instantaneous cosfi values
Returns
-------
float
"""
inst = self.load_instantaneous()
values = [float(i['value']) for i in inst if i['key'].endswith('Cosfi')]
return sum(values) / len(values) | [
"Takes",
"the",
"average",
"of",
"all",
"instantaneous",
"cosfi",
"values"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L586-L596 | [
"def",
"active_cosfi",
"(",
"self",
")",
":",
"inst",
"=",
"self",
".",
"load_instantaneous",
"(",
")",
"values",
"=",
"[",
"float",
"(",
"i",
"[",
"'value'",
"]",
")",
"for",
"i",
"in",
"inst",
"if",
"i",
"[",
"'key'",
"]",
".",
"endswith",
"(",
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.on_command_control | Parameters
----------
val_id : str
Returns
-------
requests.Response | smappy/smappy.py | def on_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "control,controlId=1|" + val_id
return self._basic_post(url='commandControlPublic', data=data) | def on_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "control,controlId=1|" + val_id
return self._basic_post(url='commandControlPublic', data=data) | [
"Parameters",
"----------",
"val_id",
":",
"str"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L697-L708 | [
"def",
"on_command_control",
"(",
"self",
",",
"val_id",
")",
":",
"data",
"=",
"\"control,controlId=1|\"",
"+",
"val_id",
"return",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'commandControlPublic'",
",",
"data",
"=",
"data",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.off_command_control | Parameters
----------
val_id : str
Returns
-------
requests.Response | smappy/smappy.py | def off_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "control,controlId=0|" + val_id
return self._basic_post(url='commandControlPublic', data=data) | def off_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "control,controlId=0|" + val_id
return self._basic_post(url='commandControlPublic', data=data) | [
"Parameters",
"----------",
"val_id",
":",
"str"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L710-L721 | [
"def",
"off_command_control",
"(",
"self",
",",
"val_id",
")",
":",
"data",
"=",
"\"control,controlId=0|\"",
"+",
"val_id",
"return",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'commandControlPublic'",
",",
"data",
"=",
"data",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.delete_command_control | Parameters
----------
val_id : str
Returns
-------
requests.Response | smappy/smappy.py | def delete_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "delete,controlId=" + val_id
return self._basic_post(url='commandControlPublic', data=data) | def delete_command_control(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "delete,controlId=" + val_id
return self._basic_post(url='commandControlPublic', data=data) | [
"Parameters",
"----------",
"val_id",
":",
"str"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L739-L751 | [
"def",
"delete_command_control",
"(",
"self",
",",
"val_id",
")",
":",
"data",
"=",
"\"delete,controlId=\"",
"+",
"val_id",
"return",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'commandControlPublic'",
",",
"data",
"=",
"data",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.delete_command_control_timers | Parameters
----------
val_id : str
Returns
-------
requests.Response | smappy/smappy.py | def delete_command_control_timers(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "deleteTimers,controlId=" + val_id
return self._basic_post(url='commandControlPublic', data=data) | def delete_command_control_timers(self, val_id):
"""
Parameters
----------
val_id : str
Returns
-------
requests.Response
"""
data = "deleteTimers,controlId=" + val_id
return self._basic_post(url='commandControlPublic', data=data) | [
"Parameters",
"----------",
"val_id",
":",
"str"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L753-L764 | [
"def",
"delete_command_control_timers",
"(",
"self",
",",
"val_id",
")",
":",
"data",
"=",
"\"deleteTimers,controlId=\"",
"+",
"val_id",
"return",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'commandControlPublic'",
",",
"data",
"=",
"data",
")"
] | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | LocalSmappee.select_logfile | Parameters
----------
logfile : str
Returns
-------
dict | smappy/smappy.py | def select_logfile(self, logfile):
"""
Parameters
----------
logfile : str
Returns
-------
dict
"""
data = 'logFileSelect,' + logfile
r = self._basic_post(url='logBrowser', data=data)
return r.json() | def select_logfile(self, logfile):
"""
Parameters
----------
logfile : str
Returns
-------
dict
"""
data = 'logFileSelect,' + logfile
r = self._basic_post(url='logBrowser', data=data)
return r.json() | [
"Parameters",
"----------",
"logfile",
":",
"str"
] | EnergieID/smappy | python | https://github.com/EnergieID/smappy/blob/1ada3abc9a51c76205c072369258f6f4f4e8fd0f/smappy/smappy.py#L791-L803 | [
"def",
"select_logfile",
"(",
"self",
",",
"logfile",
")",
":",
"data",
"=",
"'logFileSelect,'",
"+",
"logfile",
"r",
"=",
"self",
".",
"_basic_post",
"(",
"url",
"=",
"'logBrowser'",
",",
"data",
"=",
"data",
")",
"return",
"r",
".",
"json",
"(",
")"
... | 1ada3abc9a51c76205c072369258f6f4f4e8fd0f |
train | getInterfaceInAllSpeeds | Produce similar fs, hs and ss interface and endpoints descriptors.
Should be useful for devices desiring to work in all 3 speeds with maximum
endpoint wMaxPacketSize. Reduces data duplication from descriptor
declarations.
Not intended to cover fancy combinations.
interface (dict):
Keyword arg... | functionfs/__init__.py | def getInterfaceInAllSpeeds(interface, endpoint_list, class_descriptor_list=()):
"""
Produce similar fs, hs and ss interface and endpoints descriptors.
Should be useful for devices desiring to work in all 3 speeds with maximum
endpoint wMaxPacketSize. Reduces data duplication from descriptor
declara... | def getInterfaceInAllSpeeds(interface, endpoint_list, class_descriptor_list=()):
"""
Produce similar fs, hs and ss interface and endpoints descriptors.
Should be useful for devices desiring to work in all 3 speeds with maximum
endpoint wMaxPacketSize. Reduces data duplication from descriptor
declara... | [
"Produce",
"similar",
"fs",
"hs",
"and",
"ss",
"interface",
"and",
"endpoints",
"descriptors",
".",
"Should",
"be",
"useful",
"for",
"devices",
"desiring",
"to",
"work",
"in",
"all",
"3",
"speeds",
"with",
"maximum",
"endpoint",
"wMaxPacketSize",
".",
"Reduces... | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L120-L260 | [
"def",
"getInterfaceInAllSpeeds",
"(",
"interface",
",",
"endpoint_list",
",",
"class_descriptor_list",
"=",
"(",
")",
")",
":",
"interface",
"=",
"getDescriptor",
"(",
"USBInterfaceDescriptor",
",",
"bNumEndpoints",
"=",
"len",
"(",
"endpoint_list",
")",
",",
"*"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | getDescriptor | Automatically fills bLength and bDescriptorType. | functionfs/__init__.py | def getDescriptor(klass, **kw):
"""
Automatically fills bLength and bDescriptorType.
"""
# XXX: ctypes Structure.__init__ ignores arguments which do not exist
# as structure fields. So check it.
# This is annoying, but not doing it is a huge waste of time for the
# developer.
empty = kla... | def getDescriptor(klass, **kw):
"""
Automatically fills bLength and bDescriptorType.
"""
# XXX: ctypes Structure.__init__ ignores arguments which do not exist
# as structure fields. So check it.
# This is annoying, but not doing it is a huge waste of time for the
# developer.
empty = kla... | [
"Automatically",
"fills",
"bLength",
"and",
"bDescriptorType",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L262-L283 | [
"def",
"getDescriptor",
"(",
"klass",
",",
"*",
"*",
"kw",
")",
":",
"# XXX: ctypes Structure.__init__ ignores arguments which do not exist",
"# as structure fields. So check it.",
"# This is annoying, but not doing it is a huge waste of time for the",
"# developer.",
"empty",
"=",
"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | getOSDesc | Return an OS description header.
interface (int)
Related interface number.
ext_list (list of OSExtCompatDesc or OSExtPropDesc)
List of instances of extended descriptors. | functionfs/__init__.py | def getOSDesc(interface, ext_list):
"""
Return an OS description header.
interface (int)
Related interface number.
ext_list (list of OSExtCompatDesc or OSExtPropDesc)
List of instances of extended descriptors.
"""
try:
ext_type, = {type(x) for x in ext_list}
except Va... | def getOSDesc(interface, ext_list):
"""
Return an OS description header.
interface (int)
Related interface number.
ext_list (list of OSExtCompatDesc or OSExtPropDesc)
List of instances of extended descriptors.
"""
try:
ext_type, = {type(x) for x in ext_list}
except Va... | [
"Return",
"an",
"OS",
"description",
"header",
".",
"interface",
"(",
"int",
")",
"Related",
"interface",
"number",
".",
"ext_list",
"(",
"list",
"of",
"OSExtCompatDesc",
"or",
"OSExtPropDesc",
")",
"List",
"of",
"instances",
"of",
"extended",
"descriptors",
"... | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L285-L329 | [
"def",
"getOSDesc",
"(",
"interface",
",",
"ext_list",
")",
":",
"try",
":",
"ext_type",
",",
"=",
"{",
"type",
"(",
"x",
")",
"for",
"x",
"in",
"ext_list",
"}",
"except",
"ValueError",
":",
"raise",
"TypeError",
"(",
"'Extensions of a single type are requir... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | getOSExtPropDesc | Returns an OS extension property descriptor.
data_type (int)
See wPropertyDataType documentation.
name (string)
See PropertyName documentation.
value (string)
See PropertyData documentation.
NULL chars must be explicitely included in the value when needed,
this functi... | functionfs/__init__.py | def getOSExtPropDesc(data_type, name, value):
"""
Returns an OS extension property descriptor.
data_type (int)
See wPropertyDataType documentation.
name (string)
See PropertyName documentation.
value (string)
See PropertyData documentation.
NULL chars must be explicit... | def getOSExtPropDesc(data_type, name, value):
"""
Returns an OS extension property descriptor.
data_type (int)
See wPropertyDataType documentation.
name (string)
See PropertyName documentation.
value (string)
See PropertyData documentation.
NULL chars must be explicit... | [
"Returns",
"an",
"OS",
"extension",
"property",
"descriptor",
".",
"data_type",
"(",
"int",
")",
"See",
"wPropertyDataType",
"documentation",
".",
"name",
"(",
"string",
")",
"See",
"PropertyName",
"documentation",
".",
"value",
"(",
"string",
")",
"See",
"Pro... | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L331-L361 | [
"def",
"getOSExtPropDesc",
"(",
"data_type",
",",
"name",
",",
"value",
")",
":",
"klass",
"=",
"type",
"(",
"'OSExtPropDesc'",
",",
"(",
"OSExtPropDescHead",
",",
")",
",",
"{",
"'_fields_'",
":",
"[",
"(",
"'bPropertyName'",
",",
"ctypes",
".",
"c_char",... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | getDescsV2 | Return a FunctionFS descriptor suitable for serialisation.
flags (int)
Any combination of VIRTUAL_ADDR, EVENTFD, ALL_CTRL_RECIP,
CONFIG0_SETUP.
{fs,hs,ss,os}_list (list of descriptors)
Instances of the following classes:
{fs,hs,ss}_list:
USBInterfaceDescriptor
... | functionfs/__init__.py | def getDescsV2(flags, fs_list=(), hs_list=(), ss_list=(), os_list=()):
"""
Return a FunctionFS descriptor suitable for serialisation.
flags (int)
Any combination of VIRTUAL_ADDR, EVENTFD, ALL_CTRL_RECIP,
CONFIG0_SETUP.
{fs,hs,ss,os}_list (list of descriptors)
Instances of the fo... | def getDescsV2(flags, fs_list=(), hs_list=(), ss_list=(), os_list=()):
"""
Return a FunctionFS descriptor suitable for serialisation.
flags (int)
Any combination of VIRTUAL_ADDR, EVENTFD, ALL_CTRL_RECIP,
CONFIG0_SETUP.
{fs,hs,ss,os}_list (list of descriptors)
Instances of the fo... | [
"Return",
"a",
"FunctionFS",
"descriptor",
"suitable",
"for",
"serialisation",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L389-L480 | [
"def",
"getDescsV2",
"(",
"flags",
",",
"fs_list",
"=",
"(",
")",
",",
"hs_list",
"=",
"(",
")",
",",
"ss_list",
"=",
"(",
")",
",",
"os_list",
"=",
"(",
")",
")",
":",
"count_field_list",
"=",
"[",
"]",
"descr_field_list",
"=",
"[",
"]",
"kw",
"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | getStrings | Return a FunctionFS descriptor suitable for serialisation.
lang_dict (dict)
Key: language ID (ex: 0x0409 for en-us)
Value: list of unicode objects
All values must have the same number of items. | functionfs/__init__.py | def getStrings(lang_dict):
"""
Return a FunctionFS descriptor suitable for serialisation.
lang_dict (dict)
Key: language ID (ex: 0x0409 for en-us)
Value: list of unicode objects
All values must have the same number of items.
"""
field_list = []
kw = {}
try:
s... | def getStrings(lang_dict):
"""
Return a FunctionFS descriptor suitable for serialisation.
lang_dict (dict)
Key: language ID (ex: 0x0409 for en-us)
Value: list of unicode objects
All values must have the same number of items.
"""
field_list = []
kw = {}
try:
s... | [
"Return",
"a",
"FunctionFS",
"descriptor",
"suitable",
"for",
"serialisation",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L482-L530 | [
"def",
"getStrings",
"(",
"lang_dict",
")",
":",
"field_list",
"=",
"[",
"]",
"kw",
"=",
"{",
"}",
"try",
":",
"str_count",
"=",
"len",
"(",
"next",
"(",
"iter",
"(",
"lang_dict",
".",
"values",
"(",
")",
")",
")",
")",
"except",
"StopIteration",
"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | serialise | structure (ctypes.Structure)
The structure to serialise.
Returns a ctypes.c_char array.
Does not copy memory. | functionfs/__init__.py | def serialise(structure):
"""
structure (ctypes.Structure)
The structure to serialise.
Returns a ctypes.c_char array.
Does not copy memory.
"""
return ctypes.cast(
ctypes.pointer(structure),
ctypes.POINTER(ctypes.c_char * ctypes.sizeof(structure)),
).contents | def serialise(structure):
"""
structure (ctypes.Structure)
The structure to serialise.
Returns a ctypes.c_char array.
Does not copy memory.
"""
return ctypes.cast(
ctypes.pointer(structure),
ctypes.POINTER(ctypes.c_char * ctypes.sizeof(structure)),
).contents | [
"structure",
"(",
"ctypes",
".",
"Structure",
")",
"The",
"structure",
"to",
"serialise",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L532-L543 | [
"def",
"serialise",
"(",
"structure",
")",
":",
"return",
"ctypes",
".",
"cast",
"(",
"ctypes",
".",
"pointer",
"(",
"structure",
")",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char",
"*",
"ctypes",
".",
"sizeof",
"(",
"structure",
")",
")"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | Endpoint0File.halt | Halt current endpoint. | functionfs/__init__.py | def halt(self, request_type):
"""
Halt current endpoint.
"""
try:
if request_type & ch9.USB_DIR_IN:
self.read(0)
else:
self.write(b'')
except IOError as exc:
if exc.errno != errno.EL2HLT:
raise
... | def halt(self, request_type):
"""
Halt current endpoint.
"""
try:
if request_type & ch9.USB_DIR_IN:
self.read(0)
else:
self.write(b'')
except IOError as exc:
if exc.errno != errno.EL2HLT:
raise
... | [
"Halt",
"current",
"endpoint",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L559-L572 | [
"def",
"halt",
"(",
"self",
",",
"request_type",
")",
":",
"try",
":",
"if",
"request_type",
"&",
"ch9",
".",
"USB_DIR_IN",
":",
"self",
".",
"read",
"(",
"0",
")",
"else",
":",
"self",
".",
"write",
"(",
"b''",
")",
"except",
"IOError",
"as",
"exc... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | Endpoint0File.getRealInterfaceNumber | Returns the host-visible interface number, or None if there is no such
interface. | functionfs/__init__.py | def getRealInterfaceNumber(self, interface):
"""
Returns the host-visible interface number, or None if there is no such
interface.
"""
try:
return self._ioctl(INTERFACE_REVMAP, interface)
except IOError as exc:
if exc.errno == errno.EDOM:
... | def getRealInterfaceNumber(self, interface):
"""
Returns the host-visible interface number, or None if there is no such
interface.
"""
try:
return self._ioctl(INTERFACE_REVMAP, interface)
except IOError as exc:
if exc.errno == errno.EDOM:
... | [
"Returns",
"the",
"host",
"-",
"visible",
"interface",
"number",
"or",
"None",
"if",
"there",
"is",
"no",
"such",
"interface",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L574-L584 | [
"def",
"getRealInterfaceNumber",
"(",
"self",
",",
"interface",
")",
":",
"try",
":",
"return",
"self",
".",
"_ioctl",
"(",
"INTERFACE_REVMAP",
",",
"interface",
")",
"except",
"IOError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"==",
"errno",
".",
"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | EndpointFile.getDescriptor | Returns the currently active endpoint descriptor
(depending on current USB speed). | functionfs/__init__.py | def getDescriptor(self):
"""
Returns the currently active endpoint descriptor
(depending on current USB speed).
"""
result = USBEndpointDescriptor()
self._ioctl(ENDPOINT_DESC, result, True)
return result | def getDescriptor(self):
"""
Returns the currently active endpoint descriptor
(depending on current USB speed).
"""
result = USBEndpointDescriptor()
self._ioctl(ENDPOINT_DESC, result, True)
return result | [
"Returns",
"the",
"currently",
"active",
"endpoint",
"descriptor",
"(",
"depending",
"on",
"current",
"USB",
"speed",
")",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L621-L628 | [
"def",
"getDescriptor",
"(",
"self",
")",
":",
"result",
"=",
"USBEndpointDescriptor",
"(",
")",
"self",
".",
"_ioctl",
"(",
"ENDPOINT_DESC",
",",
"result",
",",
"True",
")",
"return",
"result"
] | e19f729bb47a7d1edd2488531af24551bb86726f |
train | EndpointFile.halt | Halt current endpoint. | functionfs/__init__.py | def halt(self):
"""
Halt current endpoint.
"""
try:
self._halt()
except IOError as exc:
if exc.errno != errno.EBADMSG:
raise
else:
raise ValueError('halt did not return EBADMSG ?')
self._halted = True | def halt(self):
"""
Halt current endpoint.
"""
try:
self._halt()
except IOError as exc:
if exc.errno != errno.EBADMSG:
raise
else:
raise ValueError('halt did not return EBADMSG ?')
self._halted = True | [
"Halt",
"current",
"endpoint",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L633-L644 | [
"def",
"halt",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_halt",
"(",
")",
"except",
"IOError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"!=",
"errno",
".",
"EBADMSG",
":",
"raise",
"else",
":",
"raise",
"ValueError",
"(",
"'halt did not r... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | Function.close | Close all endpoint file descriptors. | functionfs/__init__.py | def close(self):
"""
Close all endpoint file descriptors.
"""
ep_list = self._ep_list
while ep_list:
ep_list.pop().close()
self._closed = True | def close(self):
"""
Close all endpoint file descriptors.
"""
ep_list = self._ep_list
while ep_list:
ep_list.pop().close()
self._closed = True | [
"Close",
"all",
"endpoint",
"file",
"descriptors",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L800-L807 | [
"def",
"close",
"(",
"self",
")",
":",
"ep_list",
"=",
"self",
".",
"_ep_list",
"while",
"ep_list",
":",
"ep_list",
".",
"pop",
"(",
")",
".",
"close",
"(",
")",
"self",
".",
"_closed",
"=",
"True"
] | e19f729bb47a7d1edd2488531af24551bb86726f |
train | Function.onSetup | Called when a setup USB transaction was received.
Default implementation:
- handles USB_REQ_GET_STATUS on interface and endpoints
- handles USB_REQ_CLEAR_FEATURE(USB_ENDPOINT_HALT) on endpoints
- handles USB_REQ_SET_FEATURE(USB_ENDPOINT_HALT) on endpoints
- halts on everything e... | functionfs/__init__.py | def onSetup(self, request_type, request, value, index, length):
"""
Called when a setup USB transaction was received.
Default implementation:
- handles USB_REQ_GET_STATUS on interface and endpoints
- handles USB_REQ_CLEAR_FEATURE(USB_ENDPOINT_HALT) on endpoints
- handles... | def onSetup(self, request_type, request, value, index, length):
"""
Called when a setup USB transaction was received.
Default implementation:
- handles USB_REQ_GET_STATUS on interface and endpoints
- handles USB_REQ_CLEAR_FEATURE(USB_ENDPOINT_HALT) on endpoints
- handles... | [
"Called",
"when",
"a",
"setup",
"USB",
"transaction",
"was",
"received",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L956-L1036 | [
"def",
"onSetup",
"(",
"self",
",",
"request_type",
",",
"request",
",",
"value",
",",
"index",
",",
"length",
")",
":",
"if",
"(",
"request_type",
"&",
"ch9",
".",
"USB_TYPE_MASK",
")",
"==",
"ch9",
".",
"USB_TYPE_STANDARD",
":",
"recipient",
"=",
"requ... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | main | Slowly writes to stdout, without emitting a newline so any output
buffering (or input for next pipeline command) can be detected. | examples/usbcat/slowprinter.py | def main():
"""
Slowly writes to stdout, without emitting a newline so any output
buffering (or input for next pipeline command) can be detected.
"""
now = datetime.datetime.now
try:
while True:
sys.stdout.write(str(now()) + ' ')
time.sleep(1)
except KeyboardI... | def main():
"""
Slowly writes to stdout, without emitting a newline so any output
buffering (or input for next pipeline command) can be detected.
"""
now = datetime.datetime.now
try:
while True:
sys.stdout.write(str(now()) + ' ')
time.sleep(1)
except KeyboardI... | [
"Slowly",
"writes",
"to",
"stdout",
"without",
"emitting",
"a",
"newline",
"so",
"any",
"output",
"buffering",
"(",
"or",
"input",
"for",
"next",
"pipeline",
"command",
")",
"can",
"be",
"detected",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/examples/usbcat/slowprinter.py#L22-L36 | [
"def",
"main",
"(",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"try",
":",
"while",
"True",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"str",
"(",
"now",
"(",
")",
")",
"+",
"' '",
")",
"time",
".",
"sleep",
"(",
"1",
"... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | USBCat.onEnable | The configuration containing this function has been enabled by host.
Endpoints become working files, so submit some read operations. | examples/usbcat/device.py | def onEnable(self):
"""
The configuration containing this function has been enabled by host.
Endpoints become working files, so submit some read operations.
"""
trace('onEnable')
self._disable()
self._aio_context.submit(self._aio_recv_block_list)
self._rea... | def onEnable(self):
"""
The configuration containing this function has been enabled by host.
Endpoints become working files, so submit some read operations.
"""
trace('onEnable')
self._disable()
self._aio_context.submit(self._aio_recv_block_list)
self._rea... | [
"The",
"configuration",
"containing",
"this",
"function",
"has",
"been",
"enabled",
"by",
"host",
".",
"Endpoints",
"become",
"working",
"files",
"so",
"submit",
"some",
"read",
"operations",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/examples/usbcat/device.py#L121-L130 | [
"def",
"onEnable",
"(",
"self",
")",
":",
"trace",
"(",
"'onEnable'",
")",
"self",
".",
"_disable",
"(",
")",
"self",
".",
"_aio_context",
".",
"submit",
"(",
"self",
".",
"_aio_recv_block_list",
")",
"self",
".",
"_real_onCanSend",
"(",
")",
"self",
"."... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | USBCat._disable | The configuration containing this function has been disabled by host.
Endpoint do not work anymore, so cancel AIO operation blocks. | examples/usbcat/device.py | def _disable(self):
"""
The configuration containing this function has been disabled by host.
Endpoint do not work anymore, so cancel AIO operation blocks.
"""
if self._enabled:
self._real_onCannotSend()
has_cancelled = 0
for block in self._aio... | def _disable(self):
"""
The configuration containing this function has been disabled by host.
Endpoint do not work anymore, so cancel AIO operation blocks.
"""
if self._enabled:
self._real_onCannotSend()
has_cancelled = 0
for block in self._aio... | [
"The",
"configuration",
"containing",
"this",
"function",
"has",
"been",
"disabled",
"by",
"host",
".",
"Endpoint",
"do",
"not",
"work",
"anymore",
"so",
"cancel",
"AIO",
"operation",
"blocks",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/examples/usbcat/device.py#L136-L155 | [
"def",
"_disable",
"(",
"self",
")",
":",
"if",
"self",
".",
"_enabled",
":",
"self",
".",
"_real_onCannotSend",
"(",
")",
"has_cancelled",
"=",
"0",
"for",
"block",
"in",
"self",
".",
"_aio_recv_block_list",
"+",
"self",
".",
"_aio_send_block_list",
":",
... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | USBCat.onAIOCompletion | Call when eventfd notified events are available. | examples/usbcat/device.py | def onAIOCompletion(self):
"""
Call when eventfd notified events are available.
"""
event_count = self.eventfd.read()
trace('eventfd reports %i events' % event_count)
# Even though eventfd signaled activity, even though it may give us
# some number of pending even... | def onAIOCompletion(self):
"""
Call when eventfd notified events are available.
"""
event_count = self.eventfd.read()
trace('eventfd reports %i events' % event_count)
# Even though eventfd signaled activity, even though it may give us
# some number of pending even... | [
"Call",
"when",
"eventfd",
"notified",
"events",
"are",
"available",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/examples/usbcat/device.py#L157-L168 | [
"def",
"onAIOCompletion",
"(",
"self",
")",
":",
"event_count",
"=",
"self",
".",
"eventfd",
".",
"read",
"(",
")",
"trace",
"(",
"'eventfd reports %i events'",
"%",
"event_count",
")",
"# Even though eventfd signaled activity, even though it may give us",
"# some number ... | e19f729bb47a7d1edd2488531af24551bb86726f |
train | USBCat.write | Queue write in kernel.
value (bytes)
Value to send. | examples/usbcat/device.py | def write(self, value):
"""
Queue write in kernel.
value (bytes)
Value to send.
"""
aio_block = libaio.AIOBlock(
mode=libaio.AIOBLOCK_MODE_WRITE,
target_file=self.getEndpoint(1),
buffer_list=[bytearray(value)],
offset=0,... | def write(self, value):
"""
Queue write in kernel.
value (bytes)
Value to send.
"""
aio_block = libaio.AIOBlock(
mode=libaio.AIOBLOCK_MODE_WRITE,
target_file=self.getEndpoint(1),
buffer_list=[bytearray(value)],
offset=0,... | [
"Queue",
"write",
"in",
"kernel",
".",
"value",
"(",
"bytes",
")",
"Value",
"to",
"send",
"."
] | vpelletier/python-functionfs | python | https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/examples/usbcat/device.py#L196-L213 | [
"def",
"write",
"(",
"self",
",",
"value",
")",
":",
"aio_block",
"=",
"libaio",
".",
"AIOBlock",
"(",
"mode",
"=",
"libaio",
".",
"AIOBLOCK_MODE_WRITE",
",",
"target_file",
"=",
"self",
".",
"getEndpoint",
"(",
"1",
")",
",",
"buffer_list",
"=",
"[",
... | e19f729bb47a7d1edd2488531af24551bb86726f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.