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
test
Collection.add_device
Method for `Add device to collection <https://m2x.att.com/developer/documentation/v2/collections#Add-device-to-collection>`_ endpoint. :param device_id: ID of the Device being added to Collection :type device_id: str :raises: :class:`~requests.exceptions.HTTPError` if an error occurs when send...
m2x/v2/collections.py
def add_device(self, device_id): """ Method for `Add device to collection <https://m2x.att.com/developer/documentation/v2/collections#Add-device-to-collection>`_ endpoint. :param device_id: ID of the Device being added to Collection :type device_id: str :raises: :class:`~requests.excep...
def add_device(self, device_id): """ Method for `Add device to collection <https://m2x.att.com/developer/documentation/v2/collections#Add-device-to-collection>`_ endpoint. :param device_id: ID of the Device being added to Collection :type device_id: str :raises: :class:`~requests.excep...
[ "Method", "for", "Add", "device", "to", "collection", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "collections#Add", "-", "device", "-", "to", "-", "collection", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/collections.py#L28-L37
[ "def", "add_device", "(", "self", ",", "device_id", ")", ":", "path", "=", "self", ".", "subpath", "(", "'/devices/{device_id}'", ".", "format", "(", "device_id", "=", "device_id", ")", ")", "return", "self", ".", "api", ".", "put", "(", "path", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Collection.remove_device
Method for `Remove device from collection <https://m2x.att.com/developer/documentation/v2/collections#Remove-device-from-collection>`_ endpoint. :param device_id: ID of the Device being removed from Collection :type device_id: str :raises: :class:`~requests.exceptions.HTTPError` if an error oc...
m2x/v2/collections.py
def remove_device(self, device_id): """ Method for `Remove device from collection <https://m2x.att.com/developer/documentation/v2/collections#Remove-device-from-collection>`_ endpoint. :param device_id: ID of the Device being removed from Collection :type device_id: str :raises: :class...
def remove_device(self, device_id): """ Method for `Remove device from collection <https://m2x.att.com/developer/documentation/v2/collections#Remove-device-from-collection>`_ endpoint. :param device_id: ID of the Device being removed from Collection :type device_id: str :raises: :class...
[ "Method", "for", "Remove", "device", "from", "collection", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "collections#Remove", "-", "device", "-", "from", "-", "collection", ">", "_", "endpoint"...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/collections.py#L39-L48
[ "def", "remove_device", "(", "self", ",", "device_id", ")", ":", "path", "=", "self", ".", "subpath", "(", "'/devices/{device_id}'", ".", "format", "(", "device_id", "=", "device_id", ")", ")", "return", "self", ".", "api", ".", "delete", "(", "path", ")...
df83f590114692b1f96577148b7ba260065905bb
test
Device.create_stream
Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be created :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
m2x/v2/devices.py
def create_stream(self, name, **params): """ Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be created :param params: Query parameters passed as keyword arguments. View M2X AP...
def create_stream(self, name, **params): """ Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be created :param params: Query parameters passed as keyword arguments. View M2X AP...
[ "Method", "for", "Create", "/", "Update", "Data", "Stream", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Create", "-", "Update", "-", "Data", "-", "Stream", ">", "_", "endpoint", "....
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L37-L48
[ "def", "create_stream", "(", "self", ",", "name", ",", "*", "*", "params", ")", ":", "return", "Stream", ".", "create", "(", "self", ".", "api", ",", "self", ",", "name", ",", "*", "*", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.update_stream
Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be updated :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
m2x/v2/devices.py
def update_stream(self, name, **params): """ Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be updated :param params: Query parameters passed as keyword arguments. View M2X AP...
def update_stream(self, name, **params): """ Method for `Create/Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param name: Name of the stream to be updated :param params: Query parameters passed as keyword arguments. View M2X AP...
[ "Method", "for", "Create", "/", "Update", "Data", "Stream", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Create", "-", "Update", "-", "Data", "-", "Stream", ">", "_", "endpoint", "....
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L50-L61
[ "def", "update_stream", "(", "self", ",", "name", ",", "*", "*", "params", ")", ":", "return", "Stream", ".", "item_update", "(", "self", ".", "api", ",", "self", ",", "name", ",", "*", "*", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.create_key
Create an API Key for this Device via the `Create Key <https://m2x.att.com/developer/documentation/v2/keys#Create-Key>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The newly created Key :rtype: Key ...
m2x/v2/devices.py
def create_key(self, **params): """ Create an API Key for this Device via the `Create Key <https://m2x.att.com/developer/documentation/v2/keys#Create-Key>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: Th...
def create_key(self, **params): """ Create an API Key for this Device via the `Create Key <https://m2x.att.com/developer/documentation/v2/keys#Create-Key>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: Th...
[ "Create", "an", "API", "Key", "for", "this", "Device", "via", "the", "Create", "Key", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "keys#Create", "-", "Key", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L74-L84
[ "def", "create_key", "(", "self", ",", "*", "*", "params", ")", ":", "return", "Key", ".", "create", "(", "self", ".", "api", ",", "device", "=", "self", ".", "id", ",", "*", "*", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.location
Method for `Read Device Location <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location>`_ endpoint. :return: Most recently logged location of the Device, see M2X API docs for details :rtype: dict :raises: :class:`~requests.exceptions.HTTPError` if an error occurs when sen...
m2x/v2/devices.py
def location(self): """ Method for `Read Device Location <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location>`_ endpoint. :return: Most recently logged location of the Device, see M2X API docs for details :rtype: dict :raises: :class:`~requests.exceptions.HTTPEr...
def location(self): """ Method for `Read Device Location <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location>`_ endpoint. :return: Most recently logged location of the Device, see M2X API docs for details :rtype: dict :raises: :class:`~requests.exceptions.HTTPEr...
[ "Method", "for", "Read", "Device", "Location", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Read", "-", "Device", "-", "Location", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L86-L95
[ "def", "location", "(", "self", ")", ":", "return", "self", ".", "data", ".", "get", "(", "'location'", ")", "or", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/location'", ")", ")", "or", "{", "}" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.location_history
Method for `Read Device Location History <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location-History>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: Location history of the Device ...
m2x/v2/devices.py
def location_history(self, **params): """ Method for `Read Device Location History <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location-History>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
def location_history(self, **params): """ Method for `Read Device Location History <https://m2x.att.com/developer/documentation/v2/device#Read-Device-Location-History>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
[ "Method", "for", "Read", "Device", "Location", "History", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Read", "-", "Device", "-", "Location", "-", "History", ">", "_", "endpoint", "."...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L97-L107
[ "def", "location_history", "(", "self", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/location/waypoints'", ")", ",", "params", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.update_location
Method for `Update Device Location <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Location>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2X API docs for details ...
m2x/v2/devices.py
def update_location(self, **params): """ Method for `Update Device Location <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Location>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: Th...
def update_location(self, **params): """ Method for `Update Device Location <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Location>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: Th...
[ "Method", "for", "Update", "Device", "Location", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Update", "-", "Device", "-", "Location", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L109-L119
[ "def", "update_location", "(", "self", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "put", "(", "self", ".", "subpath", "(", "'/location'", ")", ",", "data", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.post_updates
Method for `Post Device Updates (Multiple Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Updates--Multiple-Values-to-Multiple-Streams->`_ endpoint. :param values: The values being posted, formatted according to the API docs :type values: dict :re...
m2x/v2/devices.py
def post_updates(self, **values): """ Method for `Post Device Updates (Multiple Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Updates--Multiple-Values-to-Multiple-Streams->`_ endpoint. :param values: The values being posted, formatted according to the AP...
def post_updates(self, **values): """ Method for `Post Device Updates (Multiple Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Updates--Multiple-Values-to-Multiple-Streams->`_ endpoint. :param values: The values being posted, formatted according to the AP...
[ "Method", "for", "Post", "Device", "Updates", "(", "Multiple", "Values", "to", "Multiple", "Streams", ")", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Post", "-", "Device", "-", "Upd...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L143-L154
[ "def", "post_updates", "(", "self", ",", "*", "*", "values", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/updates'", ")", ",", "data", "=", "values", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.post_update
Method for `Post Device Update (Single Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Update--Single-Values-to-Multiple-Streams->` endpoint. :param values: The values being posted, formatted according to the API docs :type values: dict :return: T...
m2x/v2/devices.py
def post_update(self, **values): """ Method for `Post Device Update (Single Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Update--Single-Values-to-Multiple-Streams->` endpoint. :param values: The values being posted, formatted according to the API docs ...
def post_update(self, **values): """ Method for `Post Device Update (Single Values to Multiple Streams) <https://m2x.att.com/developer/documentation/v2/device#Post-Device-Update--Single-Values-to-Multiple-Streams->` endpoint. :param values: The values being posted, formatted according to the API docs ...
[ "Method", "for", "Post", "Device", "Update", "(", "Single", "Values", "to", "Multiple", "Streams", ")", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Post", "-", "Device", "-", "Update...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L156-L167
[ "def", "post_update", "(", "self", ",", "*", "*", "values", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/update'", ")", ",", "data", "=", "values", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.values
Method for `List Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#List-Data-Stream-Values>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2X API docs for details ...
m2x/v2/devices.py
def values(self, **params): """ Method for `List Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#List-Data-Stream-Values>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API r...
def values(self, **params): """ Method for `List Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#List-Data-Stream-Values>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API r...
[ "Method", "for", "List", "Data", "Stream", "Values", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#List", "-", "Data", "-", "Stream", "-", "Values", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L169-L179
[ "def", "values", "(", "self", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/values'", ")", ",", "params", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.values_export
Method for `Export Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Export-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: T...
m2x/v2/devices.py
def values_export(self, **params): """ Method for `Export Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Export-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listi...
def values_export(self, **params): """ Method for `Export Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Export-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listi...
[ "Method", "for", "Export", "Values", "from", "all", "Data", "Streams", "of", "a", "Device", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Export", "-", "Values", "-", "from", "-", "a...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L181-L192
[ "def", "values_export", "(", "self", ",", "*", "*", "params", ")", ":", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/values/export.csv'", ")", ",", "params", "=", "params", ")", "return", "self", ".", "api", ".", "last_response"...
df83f590114692b1f96577148b7ba260065905bb
test
Device.values_search
Method for `Search Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Search-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: T...
m2x/v2/devices.py
def values_search(self, **params): """ Method for `Search Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Search-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listi...
def values_search(self, **params): """ Method for `Search Values from all Data Streams of a Device <https://m2x.att.com/developer/documentation/v2/device#Search-Values-from-all-Data-Streams-of-a-Device>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listi...
[ "Method", "for", "Search", "Values", "from", "all", "Data", "Streams", "of", "a", "Device", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Search", "-", "Values", "-", "from", "-", "a...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L194-L204
[ "def", "values_search", "(", "self", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/values/search'", ")", ",", "data", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.commands
Method for `Device's List of Received Commands <https://m2x.att.com/developer/documentation/v2/commands#Device-s-List-of-Received-Commands>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2X...
m2x/v2/devices.py
def commands(self, **params): """ Method for `Device's List of Received Commands <https://m2x.att.com/developer/documentation/v2/commands#Device-s-List-of-Received-Commands>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
def commands(self, **params): """ Method for `Device's List of Received Commands <https://m2x.att.com/developer/documentation/v2/commands#Device-s-List-of-Received-Commands>`_ endpoint. :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. ...
[ "Method", "for", "Device", "s", "List", "of", "Received", "Commands", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "commands#Device", "-", "s", "-", "List", "-", "of", "-", "Received", "-",...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L206-L216
[ "def", "commands", "(", "self", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/commands'", ")", ",", "params", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.process_command
Method for `Device Marks a Command as Processed <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Processed>`_ endpoint. :param id: ID of the Command being marked as processed :param params: Optional data to be associated with the processed command, see API docs for det...
m2x/v2/devices.py
def process_command(self, id, **params): """ Method for `Device Marks a Command as Processed <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Processed>`_ endpoint. :param id: ID of the Command being marked as processed :param params: Optional data to be associ...
def process_command(self, id, **params): """ Method for `Device Marks a Command as Processed <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Processed>`_ endpoint. :param id: ID of the Command being marked as processed :param params: Optional data to be associ...
[ "Method", "for", "Device", "Marks", "a", "Command", "as", "Processed", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "commands#Device", "-", "Marks", "-", "a", "-", "Command", "-", "as", "-"...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L230-L241
[ "def", "process_command", "(", "self", ",", "id", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/commands/%s/process'", "%", "id", ")", ",", "data", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Device.reject_command
Method for `Device Marks a Command as Rejected <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Rejected>`_ endpoint. :param id: ID of the Command being marked as rejected :param params: Optional data to be associated with the rejected command, see API docs for details...
m2x/v2/devices.py
def reject_command(self, id, **params): """ Method for `Device Marks a Command as Rejected <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Rejected>`_ endpoint. :param id: ID of the Command being marked as rejected :param params: Optional data to be associated...
def reject_command(self, id, **params): """ Method for `Device Marks a Command as Rejected <https://m2x.att.com/developer/documentation/v2/commands#Device-Marks-a-Command-as-Rejected>`_ endpoint. :param id: ID of the Command being marked as rejected :param params: Optional data to be associated...
[ "Method", "for", "Device", "Marks", "a", "Command", "as", "Rejected", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "commands#Device", "-", "Marks", "-", "a", "-", "Command", "-", "as", "-",...
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/devices.py#L243-L254
[ "def", "reject_command", "(", "self", ",", "id", ",", "*", "*", "params", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/commands/%s/reject'", "%", "id", ")", ",", "data", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Metadata.update_metadata
Generic method for a resource's Update Metadata endpoint. Example endpoints: * `Update Device Metadata <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata>`_ * `Update Distribution Metadata <https://m2x.att.com/developer/documentation/v2/distribution#Update-Distribution-Metadata>...
m2x/v2/metadata.py
def update_metadata(self, params): """ Generic method for a resource's Update Metadata endpoint. Example endpoints: * `Update Device Metadata <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata>`_ * `Update Distribution Metadata <https://m2x.att.com/developer/documentation/v2...
def update_metadata(self, params): """ Generic method for a resource's Update Metadata endpoint. Example endpoints: * `Update Device Metadata <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata>`_ * `Update Distribution Metadata <https://m2x.att.com/developer/documentation/v2...
[ "Generic", "method", "for", "a", "resource", "s", "Update", "Metadata", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/metadata.py#L39-L55
[ "def", "update_metadata", "(", "self", ",", "params", ")", ":", "return", "self", ".", "api", ".", "put", "(", "self", ".", "metadata_path", "(", ")", ",", "data", "=", "params", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Metadata.update_metadata_field
Generic method for a resource's Update Metadata Field endpoint. Example endpoints: * `Update Device Metadata Field <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata-Field>`_ * `Update Distribution Metadata Field <https://m2x.att.com/developer/documentation/v2/distribution#Updat...
m2x/v2/metadata.py
def update_metadata_field(self, field, value): """ Generic method for a resource's Update Metadata Field endpoint. Example endpoints: * `Update Device Metadata Field <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata-Field>`_ * `Update Distribution Metadata Field <https://m2...
def update_metadata_field(self, field, value): """ Generic method for a resource's Update Metadata Field endpoint. Example endpoints: * `Update Device Metadata Field <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Metadata-Field>`_ * `Update Distribution Metadata Field <https://m2...
[ "Generic", "method", "for", "a", "resource", "s", "Update", "Metadata", "Field", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/metadata.py#L57-L74
[ "def", "update_metadata_field", "(", "self", ",", "field", ",", "value", ")", ":", "return", "self", ".", "api", ".", "put", "(", "self", ".", "metadata_field_path", "(", "field", ")", ",", "data", "=", "{", "\"value\"", ":", "value", "}", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Resource.update
Generic method for a resource's Update endpoint. Example endpoints: * `Update Device Details <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Details>`_ * `Update Distribution Details <https://m2x.att.com/developer/documentation/v2/distribution#Update-Distribution-Details>`...
m2x/v2/resource.py
def update(self, **attrs): """ Generic method for a resource's Update endpoint. Example endpoints: * `Update Device Details <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Details>`_ * `Update Distribution Details <https://m2x.att.com/developer/documentation/v2/dis...
def update(self, **attrs): """ Generic method for a resource's Update endpoint. Example endpoints: * `Update Device Details <https://m2x.att.com/developer/documentation/v2/device#Update-Device-Details>`_ * `Update Distribution Details <https://m2x.att.com/developer/documentation/v2/dis...
[ "Generic", "method", "for", "a", "resource", "s", "Update", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/resource.py#L17-L34
[ "def", "update", "(", "self", ",", "*", "*", "attrs", ")", ":", "self", ".", "data", ".", "update", "(", "self", ".", "item_update", "(", "self", ".", "api", ",", "self", ".", "id", ",", "*", "*", "attrs", ")", ")", "return", "self", ".", "data...
df83f590114692b1f96577148b7ba260065905bb
test
Stream.update
Method for `Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The Stream being updated :rtype: Stream ...
m2x/v2/streams.py
def update(self, **attrs): """ Method for `Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The Stream bei...
def update(self, **attrs): """ Method for `Update Data Stream <https://m2x.att.com/developer/documentation/v2/device#Create-Update-Data-Stream>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The Stream bei...
[ "Method", "for", "Update", "Data", "Stream", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Create", "-", "Update", "-", "Data", "-", "Stream", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L15-L26
[ "def", "update", "(", "self", ",", "*", "*", "attrs", ")", ":", "self", ".", "data", ".", "update", "(", "self", ".", "item_update", "(", "self", ".", "api", ",", "self", ".", "device", ",", "self", ".", "name", ",", "*", "*", "attrs", ")", ")"...
df83f590114692b1f96577148b7ba260065905bb
test
Stream.sampling
Method for `Data Stream Sampling <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Sampling>`_ endpoint. :param interval: the sampling interval, see API docs for supported interval types :param params: Query parameters passed as keyword arguments. View M2X API Docs for listing of avail...
m2x/v2/streams.py
def sampling(self, interval, **params): """ Method for `Data Stream Sampling <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Sampling>`_ endpoint. :param interval: the sampling interval, see API docs for supported interval types :param params: Query parameters passed as keywo...
def sampling(self, interval, **params): """ Method for `Data Stream Sampling <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Sampling>`_ endpoint. :param interval: the sampling interval, see API docs for supported interval types :param params: Query parameters passed as keywo...
[ "Method", "for", "Data", "Stream", "Sampling", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Data", "-", "Stream", "-", "Sampling", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L50-L62
[ "def", "sampling", "(", "self", ",", "interval", ",", "*", "*", "params", ")", ":", "params", "[", "'interval'", "]", "=", "interval", "return", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/sampling'", ")", ",", "params", "=",...
df83f590114692b1f96577148b7ba260065905bb
test
Stream.stats
Method for `Data Stream Stats <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Stats>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2X API docs for details :rtype:...
m2x/v2/streams.py
def stats(self, **attrs): """ Method for `Data Stream Stats <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Stats>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2...
def stats(self, **attrs): """ Method for `Data Stream Stats <https://m2x.att.com/developer/documentation/v2/device#Data-Stream-Stats>`_ endpoint. :param attrs: Query parameters passed as keyword arguments. View M2X API Docs for listing of available parameters. :return: The API response, see M2...
[ "Method", "for", "Data", "Stream", "Stats", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Data", "-", "Stream", "-", "Stats", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L64-L74
[ "def", "stats", "(", "self", ",", "*", "*", "attrs", ")", ":", "return", "self", ".", "api", ".", "get", "(", "self", ".", "subpath", "(", "'/stats'", ")", ",", "data", "=", "attrs", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Stream.add_value
Method for `Update Data Stream Value <https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value>`_ endpoint. :param value: The updated stream value :param timestamp: The (optional) timestamp for the upadted value :return: The API response, see M2X API docs for details ...
m2x/v2/streams.py
def add_value(self, value, timestamp=None): """ Method for `Update Data Stream Value <https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value>`_ endpoint. :param value: The updated stream value :param timestamp: The (optional) timestamp for the upadted value :ret...
def add_value(self, value, timestamp=None): """ Method for `Update Data Stream Value <https://m2x.att.com/developer/documentation/v2/device#Update-Data-Stream-Value>`_ endpoint. :param value: The updated stream value :param timestamp: The (optional) timestamp for the upadted value :ret...
[ "Method", "for", "Update", "Data", "Stream", "Value", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Update", "-", "Data", "-", "Stream", "-", "Value", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L76-L90
[ "def", "add_value", "(", "self", ",", "value", ",", "timestamp", "=", "None", ")", ":", "data", "=", "{", "'value'", ":", "value", "}", "if", "timestamp", ":", "data", "[", "'timestamp'", "]", "=", "timestamp", "return", "self", ".", "api", ".", "put...
df83f590114692b1f96577148b7ba260065905bb
test
Stream.post_values
Method for `Post Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Post-Data-Stream-Values>`_ endpoint. :param values: Values to post, see M2X API docs for details :type values: dict :return: The API response, see M2X API docs for details :rtype: dict :...
m2x/v2/streams.py
def post_values(self, values): """ Method for `Post Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Post-Data-Stream-Values>`_ endpoint. :param values: Values to post, see M2X API docs for details :type values: dict :return: The API response, see M2X API docs ...
def post_values(self, values): """ Method for `Post Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Post-Data-Stream-Values>`_ endpoint. :param values: Values to post, see M2X API docs for details :type values: dict :return: The API response, see M2X API docs ...
[ "Method", "for", "Post", "Data", "Stream", "Values", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Post", "-", "Data", "-", "Stream", "-", "Values", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L94-L107
[ "def", "post_values", "(", "self", ",", "values", ")", ":", "return", "self", ".", "api", ".", "post", "(", "self", ".", "subpath", "(", "'/values'", ")", ",", "data", "=", "{", "'values'", ":", "values", "}", ")" ]
df83f590114692b1f96577148b7ba260065905bb
test
Stream.delete_values
Method for `Delete Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Delete-Data-Stream-Values>`_ endpoint. :param start: ISO8601 timestamp for starting timerange for values to be deleted :param stop: ISO8601 timestamp for ending timerange for values to be deleted :retu...
m2x/v2/streams.py
def delete_values(self, start, stop): """ Method for `Delete Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Delete-Data-Stream-Values>`_ endpoint. :param start: ISO8601 timestamp for starting timerange for values to be deleted :param stop: ISO8601 timestamp for ending...
def delete_values(self, start, stop): """ Method for `Delete Data Stream Values <https://m2x.att.com/developer/documentation/v2/device#Delete-Data-Stream-Values>`_ endpoint. :param start: ISO8601 timestamp for starting timerange for values to be deleted :param stop: ISO8601 timestamp for ending...
[ "Method", "for", "Delete", "Data", "Stream", "Values", "<https", ":", "//", "m2x", ".", "att", ".", "com", "/", "developer", "/", "documentation", "/", "v2", "/", "device#Delete", "-", "Data", "-", "Stream", "-", "Values", ">", "_", "endpoint", "." ]
attm2x/m2x-python
python
https://github.com/attm2x/m2x-python/blob/df83f590114692b1f96577148b7ba260065905bb/m2x/v2/streams.py#L109-L123
[ "def", "delete_values", "(", "self", ",", "start", ",", "stop", ")", ":", "return", "self", ".", "api", ".", "delete", "(", "self", ".", "subpath", "(", "'/values'", ")", ",", "data", "=", "self", ".", "to_server", "(", "{", "'from'", ":", "start", ...
df83f590114692b1f96577148b7ba260065905bb
test
loads
Load a list of trees from a Newick formatted string. :param s: Newick formatted string. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. :return: List of Node objects.
src/newick.py
def loads(s, strip_comments=False, **kw): """ Load a list of trees from a Newick formatted string. :param s: Newick formatted string. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. ...
def loads(s, strip_comments=False, **kw): """ Load a list of trees from a Newick formatted string. :param s: Newick formatted string. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. ...
[ "Load", "a", "list", "of", "trees", "from", "a", "Newick", "formatted", "string", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L360-L371
[ "def", "loads", "(", "s", ",", "strip_comments", "=", "False", ",", "*", "*", "kw", ")", ":", "kw", "[", "'strip_comments'", "]", "=", "strip_comments", "return", "[", "parse_node", "(", "ss", ".", "strip", "(", ")", ",", "*", "*", "kw", ")", "for"...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
dumps
Serialize a list of trees in Newick format. :param trees: List of Node objects or a single Node object. :return: Newick formatted string.
src/newick.py
def dumps(trees): """ Serialize a list of trees in Newick format. :param trees: List of Node objects or a single Node object. :return: Newick formatted string. """ if isinstance(trees, Node): trees = [trees] return ';\n'.join([tree.newick for tree in trees]) + ';'
def dumps(trees): """ Serialize a list of trees in Newick format. :param trees: List of Node objects or a single Node object. :return: Newick formatted string. """ if isinstance(trees, Node): trees = [trees] return ';\n'.join([tree.newick for tree in trees]) + ';'
[ "Serialize", "a", "list", "of", "trees", "in", "Newick", "format", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L374-L383
[ "def", "dumps", "(", "trees", ")", ":", "if", "isinstance", "(", "trees", ",", "Node", ")", ":", "trees", "=", "[", "trees", "]", "return", "';\\n'", ".", "join", "(", "[", "tree", ".", "newick", "for", "tree", "in", "trees", "]", ")", "+", "';'"...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
load
Load a list of trees from an open Newick formatted file. :param fp: open file handle. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. :return: List of Node objects.
src/newick.py
def load(fp, strip_comments=False, **kw): """ Load a list of trees from an open Newick formatted file. :param fp: open file handle. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. ...
def load(fp, strip_comments=False, **kw): """ Load a list of trees from an open Newick formatted file. :param fp: open file handle. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. ...
[ "Load", "a", "list", "of", "trees", "from", "an", "open", "Newick", "formatted", "file", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L386-L397
[ "def", "load", "(", "fp", ",", "strip_comments", "=", "False", ",", "*", "*", "kw", ")", ":", "kw", "[", "'strip_comments'", "]", "=", "strip_comments", "return", "loads", "(", "fp", ".", "read", "(", ")", ",", "*", "*", "kw", ")" ]
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
read
Load a list of trees from a Newick formatted file. :param fname: file path. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. :return: List of Node objects.
src/newick.py
def read(fname, encoding='utf8', strip_comments=False, **kw): """ Load a list of trees from a Newick formatted file. :param fname: file path. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.c...
def read(fname, encoding='utf8', strip_comments=False, **kw): """ Load a list of trees from a Newick formatted file. :param fname: file path. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.c...
[ "Load", "a", "list", "of", "trees", "from", "a", "Newick", "formatted", "file", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L404-L416
[ "def", "read", "(", "fname", ",", "encoding", "=", "'utf8'", ",", "strip_comments", "=", "False", ",", "*", "*", "kw", ")", ":", "kw", "[", "'strip_comments'", "]", "=", "strip_comments", "with", "io", ".", "open", "(", "fname", ",", "encoding", "=", ...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
_parse_siblings
http://stackoverflow.com/a/26809037
src/newick.py
def _parse_siblings(s, **kw): """ http://stackoverflow.com/a/26809037 """ bracket_level = 0 current = [] # trick to remove special-case of trailing chars for c in (s + ","): if c == "," and bracket_level == 0: yield parse_node("".join(current), **kw) current ...
def _parse_siblings(s, **kw): """ http://stackoverflow.com/a/26809037 """ bracket_level = 0 current = [] # trick to remove special-case of trailing chars for c in (s + ","): if c == "," and bracket_level == 0: yield parse_node("".join(current), **kw) current ...
[ "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "26809037" ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L431-L448
[ "def", "_parse_siblings", "(", "s", ",", "*", "*", "kw", ")", ":", "bracket_level", "=", "0", "current", "=", "[", "]", "# trick to remove special-case of trailing chars", "for", "c", "in", "(", "s", "+", "\",\"", ")", ":", "if", "c", "==", "\",\"", "and...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
parse_node
Parse a Newick formatted string into a `Node` object. :param s: Newick formatted string to parse. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to `Node.create`. :return: `Node` instance.
src/newick.py
def parse_node(s, strip_comments=False, **kw): """ Parse a Newick formatted string into a `Node` object. :param s: Newick formatted string to parse. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to ...
def parse_node(s, strip_comments=False, **kw): """ Parse a Newick formatted string into a `Node` object. :param s: Newick formatted string to parse. :param strip_comments: Flag signaling whether to strip comments enclosed in square \ brackets. :param kw: Keyword arguments are passed through to ...
[ "Parse", "a", "Newick", "formatted", "string", "into", "a", "Node", "object", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L451-L473
[ "def", "parse_node", "(", "s", ",", "strip_comments", "=", "False", ",", "*", "*", "kw", ")", ":", "if", "strip_comments", ":", "s", "=", "COMMENT", ".", "sub", "(", "''", ",", "s", ")", "s", "=", "s", ".", "strip", "(", ")", "parts", "=", "s",...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.create
Create a new `Node` object. :param name: Node label. :param length: Branch length from the new node to its parent. :param descendants: list of descendants or `None`. :param kw: Additonal keyword arguments are passed through to `Node.__init__`. :return: `Node` instance.
src/newick.py
def create(cls, name=None, length=None, descendants=None, **kw): """ Create a new `Node` object. :param name: Node label. :param length: Branch length from the new node to its parent. :param descendants: list of descendants or `None`. :param kw: Additonal keyword argumen...
def create(cls, name=None, length=None, descendants=None, **kw): """ Create a new `Node` object. :param name: Node label. :param length: Branch length from the new node to its parent. :param descendants: list of descendants or `None`. :param kw: Additonal keyword argumen...
[ "Create", "a", "new", "Node", "object", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L68-L81
[ "def", "create", "(", "cls", ",", "name", "=", "None", ",", "length", "=", "None", ",", "descendants", "=", "None", ",", "*", "*", "kw", ")", ":", "node", "=", "cls", "(", "name", "=", "name", ",", "length", "=", "length", ",", "*", "*", "kw", ...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.newick
The representation of the Node in Newick format.
src/newick.py
def newick(self): """The representation of the Node in Newick format.""" label = self.name or '' if self._length: label += ':' + self._length descendants = ','.join([n.newick for n in self.descendants]) if descendants: descendants = '(' + descendants + ')'...
def newick(self): """The representation of the Node in Newick format.""" label = self.name or '' if self._length: label += ':' + self._length descendants = ','.join([n.newick for n in self.descendants]) if descendants: descendants = '(' + descendants + ')'...
[ "The", "representation", "of", "the", "Node", "in", "Newick", "format", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L88-L96
[ "def", "newick", "(", "self", ")", ":", "label", "=", "self", ".", "name", "or", "''", "if", "self", ".", "_length", ":", "label", "+=", "':'", "+", "self", ".", "_length", "descendants", "=", "','", ".", "join", "(", "[", "n", ".", "newick", "fo...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.ascii_art
Return a unicode string representing a tree in ASCII art fashion. :param strict: Use ASCII characters strictly (for the tree symbols). :param show_internal: Show labels of internal nodes. :return: unicode string >>> node = loads('((A,B)C,((D,E)F,G,H)I)J;')[0] >>> print(node.asc...
src/newick.py
def ascii_art(self, strict=False, show_internal=True): """ Return a unicode string representing a tree in ASCII art fashion. :param strict: Use ASCII characters strictly (for the tree symbols). :param show_internal: Show labels of internal nodes. :return: unicode string ...
def ascii_art(self, strict=False, show_internal=True): """ Return a unicode string representing a tree in ASCII art fashion. :param strict: Use ASCII characters strictly (for the tree symbols). :param show_internal: Show labels of internal nodes. :return: unicode string ...
[ "Return", "a", "unicode", "string", "representing", "a", "tree", "in", "ASCII", "art", "fashion", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L137-L179
[ "def", "ascii_art", "(", "self", ",", "strict", "=", "False", ",", "show_internal", "=", "True", ")", ":", "cmap", "=", "{", "'\\u2500'", ":", "'-'", ",", "'\\u2502'", ":", "'|'", ",", "'\\u250c'", ":", "'/'", ",", "'\\u2514'", ":", "'\\\\'", ",", "'...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.walk
Traverses the (sub)tree rooted at self, yielding each visited Node. .. seealso:: https://en.wikipedia.org/wiki/Tree_traversal :param mode: Specifies the algorithm to use when traversing the subtree rooted \ at self. `None` for breadth-first, `'postorder'` for post-order depth-first \ s...
src/newick.py
def walk(self, mode=None): """ Traverses the (sub)tree rooted at self, yielding each visited Node. .. seealso:: https://en.wikipedia.org/wiki/Tree_traversal :param mode: Specifies the algorithm to use when traversing the subtree rooted \ at self. `None` for breadth-first, `'pos...
def walk(self, mode=None): """ Traverses the (sub)tree rooted at self, yielding each visited Node. .. seealso:: https://en.wikipedia.org/wiki/Tree_traversal :param mode: Specifies the algorithm to use when traversing the subtree rooted \ at self. `None` for breadth-first, `'pos...
[ "Traverses", "the", "(", "sub", ")", "tree", "rooted", "at", "self", "yielding", "each", "visited", "Node", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L189-L207
[ "def", "walk", "(", "self", ",", "mode", "=", "None", ")", ":", "if", "mode", "==", "'postorder'", ":", "for", "n", "in", "self", ".", "_postorder", "(", ")", ":", "yield", "n", "else", ":", "# default to a breadth-first search", "yield", "self", "for", ...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.visit
Apply a function to matching nodes in the (sub)tree rooted at self. :param visitor: A callable accepting a Node object as single argument.. :param predicate: A callable accepting a Node object as single argument and \ returning a boolean signaling whether Node matches; if `None` all nodes match...
src/newick.py
def visit(self, visitor, predicate=None, **kw): """ Apply a function to matching nodes in the (sub)tree rooted at self. :param visitor: A callable accepting a Node object as single argument.. :param predicate: A callable accepting a Node object as single argument and \ returning...
def visit(self, visitor, predicate=None, **kw): """ Apply a function to matching nodes in the (sub)tree rooted at self. :param visitor: A callable accepting a Node object as single argument.. :param predicate: A callable accepting a Node object as single argument and \ returning...
[ "Apply", "a", "function", "to", "matching", "nodes", "in", "the", "(", "sub", ")", "tree", "rooted", "at", "self", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L209-L222
[ "def", "visit", "(", "self", ",", "visitor", ",", "predicate", "=", "None", ",", "*", "*", "kw", ")", ":", "predicate", "=", "predicate", "or", "bool", "for", "n", "in", "self", ".", "walk", "(", "*", "*", "kw", ")", ":", "if", "predicate", "(", ...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.get_node
Gets the specified node by name. :return: Node or None if name does not exist in tree
src/newick.py
def get_node(self, label): """ Gets the specified node by name. :return: Node or None if name does not exist in tree """ for n in self.walk(): if n.name == label: return n
def get_node(self, label): """ Gets the specified node by name. :return: Node or None if name does not exist in tree """ for n in self.walk(): if n.name == label: return n
[ "Gets", "the", "specified", "node", "by", "name", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L249-L257
[ "def", "get_node", "(", "self", ",", "label", ")", ":", "for", "n", "in", "self", ".", "walk", "(", ")", ":", "if", "n", ".", "name", "==", "label", ":", "return", "n" ]
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.prune
Remove all those nodes in the specified list, or if inverse=True, remove all those nodes not in the specified list. The specified nodes must be leaves and distinct from the root node. :param nodes: A list of Node objects :param inverse: Specifies whether to remove nodes in the list or ...
src/newick.py
def prune(self, leaves, inverse=False): """ Remove all those nodes in the specified list, or if inverse=True, remove all those nodes not in the specified list. The specified nodes must be leaves and distinct from the root node. :param nodes: A list of Node objects :para...
def prune(self, leaves, inverse=False): """ Remove all those nodes in the specified list, or if inverse=True, remove all those nodes not in the specified list. The specified nodes must be leaves and distinct from the root node. :param nodes: A list of Node objects :para...
[ "Remove", "all", "those", "nodes", "in", "the", "specified", "list", "or", "if", "inverse", "=", "True", "remove", "all", "those", "nodes", "not", "in", "the", "specified", "list", ".", "The", "specified", "nodes", "must", "be", "leaves", "and", "distinct"...
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L268-L284
[ "def", "prune", "(", "self", ",", "leaves", ",", "inverse", "=", "False", ")", ":", "self", ".", "visit", "(", "lambda", "n", ":", "n", ".", "ancestor", ".", "descendants", ".", "remove", "(", "n", ")", ",", "# We won't prune the root node, even if it is a...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.prune_by_names
Perform an (inverse) prune, with leaves specified by name. :param node_names: A list of leaaf Node names (strings) :param inverse: Specifies whether to remove nodes in the list or not\ in the list.
src/newick.py
def prune_by_names(self, leaf_names, inverse=False): """ Perform an (inverse) prune, with leaves specified by name. :param node_names: A list of leaaf Node names (strings) :param inverse: Specifies whether to remove nodes in the list or not\ in the list. """ ...
def prune_by_names(self, leaf_names, inverse=False): """ Perform an (inverse) prune, with leaves specified by name. :param node_names: A list of leaaf Node names (strings) :param inverse: Specifies whether to remove nodes in the list or not\ in the list. """ ...
[ "Perform", "an", "(", "inverse", ")", "prune", "with", "leaves", "specified", "by", "name", ".", ":", "param", "node_names", ":", "A", "list", "of", "leaaf", "Node", "names", "(", "strings", ")", ":", "param", "inverse", ":", "Specifies", "whether", "to"...
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L286-L293
[ "def", "prune_by_names", "(", "self", ",", "leaf_names", ",", "inverse", "=", "False", ")", ":", "self", ".", "prune", "(", "[", "l", "for", "l", "in", "self", ".", "walk", "(", ")", "if", "l", ".", "name", "in", "leaf_names", "]", ",", "inverse", ...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.remove_redundant_nodes
Remove all nodes which have only a single child, and attach their grandchildren to their parent. The resulting tree has the minimum number of internal nodes required for the number of leaves. :param preserve_lengths: If true, branch lengths of removed nodes are \ added to those of their...
src/newick.py
def remove_redundant_nodes(self, preserve_lengths=True): """ Remove all nodes which have only a single child, and attach their grandchildren to their parent. The resulting tree has the minimum number of internal nodes required for the number of leaves. :param preserve_lengths: I...
def remove_redundant_nodes(self, preserve_lengths=True): """ Remove all nodes which have only a single child, and attach their grandchildren to their parent. The resulting tree has the minimum number of internal nodes required for the number of leaves. :param preserve_lengths: I...
[ "Remove", "all", "nodes", "which", "have", "only", "a", "single", "child", "and", "attach", "their", "grandchildren", "to", "their", "parent", ".", "The", "resulting", "tree", "has", "the", "minimum", "number", "of", "internal", "nodes", "required", "for", "...
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L295-L319
[ "def", "remove_redundant_nodes", "(", "self", ",", "preserve_lengths", "=", "True", ")", ":", "for", "n", "in", "self", ".", "walk", "(", "mode", "=", "'postorder'", ")", ":", "while", "n", ".", "ancestor", "and", "len", "(", "n", ".", "ancestor", ".",...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.resolve_polytomies
Insert additional nodes with length=0 into the subtree in such a way that all non-leaf nodes have only 2 descendants, i.e. the tree becomes a fully resolved binary tree.
src/newick.py
def resolve_polytomies(self): """ Insert additional nodes with length=0 into the subtree in such a way that all non-leaf nodes have only 2 descendants, i.e. the tree becomes a fully resolved binary tree. """ def _resolve_polytomies(n): new = Node(length=self._...
def resolve_polytomies(self): """ Insert additional nodes with length=0 into the subtree in such a way that all non-leaf nodes have only 2 descendants, i.e. the tree becomes a fully resolved binary tree. """ def _resolve_polytomies(n): new = Node(length=self._...
[ "Insert", "additional", "nodes", "with", "length", "=", "0", "into", "the", "subtree", "in", "such", "a", "way", "that", "all", "non", "-", "leaf", "nodes", "have", "only", "2", "descendants", "i", ".", "e", ".", "the", "tree", "becomes", "a", "fully",...
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L321-L333
[ "def", "resolve_polytomies", "(", "self", ")", ":", "def", "_resolve_polytomies", "(", "n", ")", ":", "new", "=", "Node", "(", "length", "=", "self", ".", "_length_formatter", "(", "self", ".", "_length_parser", "(", "'0'", ")", ")", ")", "while", "len",...
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.remove_internal_names
Set the name of all non-leaf nodes in the subtree to None.
src/newick.py
def remove_internal_names(self): """ Set the name of all non-leaf nodes in the subtree to None. """ self.visit(lambda n: setattr(n, 'name', None), lambda n: not n.is_leaf)
def remove_internal_names(self): """ Set the name of all non-leaf nodes in the subtree to None. """ self.visit(lambda n: setattr(n, 'name', None), lambda n: not n.is_leaf)
[ "Set", "the", "name", "of", "all", "non", "-", "leaf", "nodes", "in", "the", "subtree", "to", "None", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L341-L345
[ "def", "remove_internal_names", "(", "self", ")", ":", "self", ".", "visit", "(", "lambda", "n", ":", "setattr", "(", "n", ",", "'name'", ",", "None", ")", ",", "lambda", "n", ":", "not", "n", ".", "is_leaf", ")" ]
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
Node.remove_leaf_names
Set the name of all leaf nodes in the subtree to None.
src/newick.py
def remove_leaf_names(self): """ Set the name of all leaf nodes in the subtree to None. """ self.visit(lambda n: setattr(n, 'name', None), lambda n: n.is_leaf)
def remove_leaf_names(self): """ Set the name of all leaf nodes in the subtree to None. """ self.visit(lambda n: setattr(n, 'name', None), lambda n: n.is_leaf)
[ "Set", "the", "name", "of", "all", "leaf", "nodes", "in", "the", "subtree", "to", "None", "." ]
glottobank/python-newick
python
https://github.com/glottobank/python-newick/blob/e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702/src/newick.py#L347-L351
[ "def", "remove_leaf_names", "(", "self", ")", ":", "self", ".", "visit", "(", "lambda", "n", ":", "setattr", "(", "n", ",", "'name'", ",", "None", ")", ",", "lambda", "n", ":", "n", ".", "is_leaf", ")" ]
e8d4d1e4610f271d0f0e5cb86c0e0360b43bd702
test
auth_required
Decorator that protect methods with HTTP authentication.
tornado_http_auth.py
def auth_required(realm, auth_func): '''Decorator that protect methods with HTTP authentication.''' def auth_decorator(func): def inner(self, *args, **kw): if self.get_authenticated_user(auth_func, realm): return func(self, *args, **kw) return inner return auth_de...
def auth_required(realm, auth_func): '''Decorator that protect methods with HTTP authentication.''' def auth_decorator(func): def inner(self, *args, **kw): if self.get_authenticated_user(auth_func, realm): return func(self, *args, **kw) return inner return auth_de...
[ "Decorator", "that", "protect", "methods", "with", "HTTP", "authentication", "." ]
gvalkov/tornado-http-auth
python
https://github.com/gvalkov/tornado-http-auth/blob/9eb225c1740fad1e53320b55d8d4fc6ab4ba58b6/tornado_http_auth.py#L227-L234
[ "def", "auth_required", "(", "realm", ",", "auth_func", ")", ":", "def", "auth_decorator", "(", "func", ")", ":", "def", "inner", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "self", ".", "get_authenticated_user", "(", "auth_func...
9eb225c1740fad1e53320b55d8d4fc6ab4ba58b6
test
dispose
Clear all comments in json_str. Clear JS-style comments like // and /**/ in json_str. Accept a str or unicode as input. Args: json_str: A json string of str or unicode to clean up comment Returns: str: The str without comments (or unicode if you pass in unicode)
jstyleson.py
def dispose(json_str): """Clear all comments in json_str. Clear JS-style comments like // and /**/ in json_str. Accept a str or unicode as input. Args: json_str: A json string of str or unicode to clean up comment Returns: str: The str without comments (or unicode if you pass in u...
def dispose(json_str): """Clear all comments in json_str. Clear JS-style comments like // and /**/ in json_str. Accept a str or unicode as input. Args: json_str: A json string of str or unicode to clean up comment Returns: str: The str without comments (or unicode if you pass in u...
[ "Clear", "all", "comments", "in", "json_str", "." ]
linjackson78/jstyleson
python
https://github.com/linjackson78/jstyleson/blob/a5aff96642684118a9a5efcb69e366f8b840346b/jstyleson.py#L4-L99
[ "def", "dispose", "(", "json_str", ")", ":", "result_str", "=", "list", "(", "json_str", ")", "escaped", "=", "False", "normal", "=", "True", "sl_comment", "=", "False", "ml_comment", "=", "False", "quoted", "=", "False", "a_step_from_comment", "=", "False",...
a5aff96642684118a9a5efcb69e366f8b840346b
test
GenericAuth.require_setting
Raises an exception if the given app setting is not defined.
bottle_auth/core/auth.py
def require_setting(self, name, feature="this feature"): """Raises an exception if the given app setting is not defined.""" if name not in self.settings: raise Exception("You must define the '%s' setting in your " "application to use %s" % (name, feature))
def require_setting(self, name, feature="this feature"): """Raises an exception if the given app setting is not defined.""" if name not in self.settings: raise Exception("You must define the '%s' setting in your " "application to use %s" % (name, feature))
[ "Raises", "an", "exception", "if", "the", "given", "app", "setting", "is", "not", "defined", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L142-L146
[ "def", "require_setting", "(", "self", ",", "name", ",", "feature", "=", "\"this feature\"", ")", ":", "if", "name", "not", "in", "self", ".", "settings", ":", "raise", "Exception", "(", "\"You must define the '%s' setting in your \"", "\"application to use %s\"", "...
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.get_argument
Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we throw an HTTP 400 exception if it is missing. If the argument appears in the url more than once, we return the last value. The returned value is...
bottle_auth/core/auth.py
def get_argument(self, name, default=_ARG_DEFAULT, strip=True): """Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we throw an HTTP 400 exception if it is missing. If the argument appears in the url more ...
def get_argument(self, name, default=_ARG_DEFAULT, strip=True): """Returns the value of the argument with the given name. If default is not provided, the argument is considered to be required, and we throw an HTTP 400 exception if it is missing. If the argument appears in the url more ...
[ "Returns", "the", "value", "of", "the", "argument", "with", "the", "given", "name", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L150-L166
[ "def", "get_argument", "(", "self", ",", "name", ",", "default", "=", "_ARG_DEFAULT", ",", "strip", "=", "True", ")", ":", "args", "=", "self", ".", "get_arguments", "(", "name", ",", "strip", "=", "strip", ")", "if", "not", "args", ":", "if", "defau...
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.get_arguments
Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode.
bottle_auth/core/auth.py
def get_arguments(self, name, strip=True): """Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. """ values = [] for v in self.request.params.getall(name): v = s...
def get_arguments(self, name, strip=True): """Returns a list of the arguments with the given name. If the argument is not present, returns an empty list. The returned values are always unicode. """ values = [] for v in self.request.params.getall(name): v = s...
[ "Returns", "a", "list", "of", "the", "arguments", "with", "the", "given", "name", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L168-L185
[ "def", "get_arguments", "(", "self", ",", "name", ",", "strip", "=", "True", ")", ":", "values", "=", "[", "]", "for", "v", "in", "self", ".", "request", ".", "params", ".", "getall", "(", "name", ")", ":", "v", "=", "self", ".", "decode_argument",...
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.async_callback
Obsolete - catches exceptions from the wrapped function. This function is unnecessary since Tornado 1.1.
bottle_auth/core/auth.py
def async_callback(self, callback, *args, **kwargs): """Obsolete - catches exceptions from the wrapped function. This function is unnecessary since Tornado 1.1. """ if callback is None: return None if args or kwargs: callback = functools.partial(callback,...
def async_callback(self, callback, *args, **kwargs): """Obsolete - catches exceptions from the wrapped function. This function is unnecessary since Tornado 1.1. """ if callback is None: return None if args or kwargs: callback = functools.partial(callback,...
[ "Obsolete", "-", "catches", "exceptions", "from", "the", "wrapped", "function", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L202-L214
[ "def", "async_callback", "(", "self", ",", "callback", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "callback", "is", "None", ":", "return", "None", "if", "args", "or", "kwargs", ":", "callback", "=", "functools", ".", "partial", "(", "...
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.get_cookie
Gets the value of the cookie with the given name, else default.
bottle_auth/core/auth.py
def get_cookie(self, name, default=None): """Gets the value of the cookie with the given name, else default.""" assert self.cookie_monster, 'Cookie Monster not set' return self.cookie_monster.get_cookie(name, default)
def get_cookie(self, name, default=None): """Gets the value of the cookie with the given name, else default.""" assert self.cookie_monster, 'Cookie Monster not set' return self.cookie_monster.get_cookie(name, default)
[ "Gets", "the", "value", "of", "the", "cookie", "with", "the", "given", "name", "else", "default", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L216-L219
[ "def", "get_cookie", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "assert", "self", ".", "cookie_monster", ",", "'Cookie Monster not set'", "return", "self", ".", "cookie_monster", ".", "get_cookie", "(", "name", ",", "default", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.set_cookie
Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cookie.html#morsel-objects for available attributes.
bottle_auth/core/auth.py
def set_cookie(self, name, value, domain=None, expires=None, path="/", expires_days=None, **kwargs): """Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cook...
def set_cookie(self, name, value, domain=None, expires=None, path="/", expires_days=None, **kwargs): """Sets the given cookie name/value with the given options. Additional keyword arguments are set on the Cookie.Morsel directly. See http://docs.python.org/library/cook...
[ "Sets", "the", "given", "cookie", "name", "/", "value", "with", "the", "given", "options", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L221-L232
[ "def", "set_cookie", "(", "self", ",", "name", ",", "value", ",", "domain", "=", "None", ",", "expires", "=", "None", ",", "path", "=", "\"/\"", ",", "expires_days", "=", "None", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "cookie_monst...
db07e526864aeac05ee68444b47e5db29540ce18
test
GenericAuth.clear_cookie
Deletes the cookie with the given name.
bottle_auth/core/auth.py
def clear_cookie(self, name, path="/", domain=None): """Deletes the cookie with the given name.""" assert self.cookie_monster, 'Cookie Monster not set' #, path=path, domain=domain) self.cookie_monster.delete_cookie(name)
def clear_cookie(self, name, path="/", domain=None): """Deletes the cookie with the given name.""" assert self.cookie_monster, 'Cookie Monster not set' #, path=path, domain=domain) self.cookie_monster.delete_cookie(name)
[ "Deletes", "the", "cookie", "with", "the", "given", "name", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L234-L238
[ "def", "clear_cookie", "(", "self", ",", "name", ",", "path", "=", "\"/\"", ",", "domain", "=", "None", ")", ":", "assert", "self", ".", "cookie_monster", ",", "'Cookie Monster not set'", "#, path=path, domain=domain)", "self", ".", "cookie_monster", ".", "delet...
db07e526864aeac05ee68444b47e5db29540ce18
test
OpenIdMixin.authenticate_redirect
Returns the authentication URL for this service. After authentication, the service will redirect back to the given callback URI. We request the given attributes for the authenticated user by default (name, email, language, and username). If you don't need all those attributes f...
bottle_auth/core/auth.py
def authenticate_redirect( self, callback_uri=None, ax_attrs=["name", "email", "language", "username"]): """Returns the authentication URL for this service. After authentication, the service will redirect back to the given callback URI. ...
def authenticate_redirect( self, callback_uri=None, ax_attrs=["name", "email", "language", "username"]): """Returns the authentication URL for this service. After authentication, the service will redirect back to the given callback URI. ...
[ "Returns", "the", "authentication", "URL", "for", "this", "service", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L246-L262
[ "def", "authenticate_redirect", "(", "self", ",", "callback_uri", "=", "None", ",", "ax_attrs", "=", "[", "\"name\"", ",", "\"email\"", ",", "\"language\"", ",", "\"username\"", "]", ")", ":", "callback_uri", "=", "callback_uri", "or", "self", ".", "request", ...
db07e526864aeac05ee68444b47e5db29540ce18
test
OpenIdMixin.get_authenticated_user
Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the authenticate_redirect() or authorize_redirect() methods.
bottle_auth/core/auth.py
def get_authenticated_user(self, callback): """Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the authenticate_redirect() or authorize_redirect() methods. """ # Verify the OpenID response via...
def get_authenticated_user(self, callback): """Fetches the authenticated user data upon redirect. This method should be called by the handler that receives the redirect from the authenticate_redirect() or authorize_redirect() methods. """ # Verify the OpenID response via...
[ "Fetches", "the", "authenticated", "user", "data", "upon", "redirect", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L264-L280
[ "def", "get_authenticated_user", "(", "self", ",", "callback", ")", ":", "# Verify the OpenID response via direct request to the OP", "# Recommendation @hmarrao, ref #3", "args", "=", "dict", "(", "(", "k", ",", "unicode", "(", "v", "[", "-", "1", "]", ")", ".", "...
db07e526864aeac05ee68444b47e5db29540ce18
test
OAuthMixin.authorize_redirect
Redirects the user to obtain OAuth authorization for this service. Twitter and FriendFeed both require that you register a Callback URL with your application. You should call this method to log the user in, and then call get_authenticated_user() in the handler you registered as your Cal...
bottle_auth/core/auth.py
def authorize_redirect(self, callback_uri=None, extra_params=None): """Redirects the user to obtain OAuth authorization for this service. Twitter and FriendFeed both require that you register a Callback URL with your application. You should call this method to log the user in, and then ...
def authorize_redirect(self, callback_uri=None, extra_params=None): """Redirects the user to obtain OAuth authorization for this service. Twitter and FriendFeed both require that you register a Callback URL with your application. You should call this method to log the user in, and then ...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L398-L423
[ "def", "authorize_redirect", "(", "self", ",", "callback_uri", "=", "None", ",", "extra_params", "=", "None", ")", ":", "if", "callback_uri", "and", "getattr", "(", "self", ",", "\"_OAUTH_NO_CALLBACKS\"", ",", "False", ")", ":", "raise", "Exception", "(", "\...
db07e526864aeac05ee68444b47e5db29540ce18
test
OAuthMixin.get_authenticated_user
Gets the OAuth authorized user and access token on callback. This method should be called from the handler for your registered OAuth Callback URL to complete the registration process. We call callback with the authenticated user, which in addition to standard attributes like 'name' incl...
bottle_auth/core/auth.py
def get_authenticated_user(self, callback): """Gets the OAuth authorized user and access token on callback. This method should be called from the handler for your registered OAuth Callback URL to complete the registration process. We call callback with the authenticated user, which in a...
def get_authenticated_user(self, callback): """Gets the OAuth authorized user and access token on callback. This method should be called from the handler for your registered OAuth Callback URL to complete the registration process. We call callback with the authenticated user, which in a...
[ "Gets", "the", "OAuth", "authorized", "user", "and", "access", "token", "on", "callback", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L426-L455
[ "def", "get_authenticated_user", "(", "self", ",", "callback", ")", ":", "request_key", "=", "self", ".", "get_argument", "(", "\"oauth_token\"", ")", "oauth_verifier", "=", "self", ".", "get_argument", "(", "\"oauth_verifier\"", ",", "None", ")", "request_cookie"...
db07e526864aeac05ee68444b47e5db29540ce18
test
OAuthMixin._oauth_request_parameters
Returns the OAuth parameters as a dict for the given request. parameters should include all POST arguments and query string arguments that will be sent with the request.
bottle_auth/core/auth.py
def _oauth_request_parameters(self, url, access_token, parameters={}, method="GET"): """Returns the OAuth parameters as a dict for the given request. parameters should include all POST arguments and query string arguments that will be sent with the request. ...
def _oauth_request_parameters(self, url, access_token, parameters={}, method="GET"): """Returns the OAuth parameters as a dict for the given request. parameters should include all POST arguments and query string arguments that will be sent with the request. ...
[ "Returns", "the", "OAuth", "parameters", "as", "a", "dict", "for", "the", "given", "request", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L536-L562
[ "def", "_oauth_request_parameters", "(", "self", ",", "url", ",", "access_token", ",", "parameters", "=", "{", "}", ",", "method", "=", "\"GET\"", ")", ":", "consumer_token", "=", "self", ".", "_oauth_consumer_token", "(", ")", "base_args", "=", "dict", "(",...
db07e526864aeac05ee68444b47e5db29540ce18
test
OAuth2Mixin.authorize_redirect
Redirects the user to obtain OAuth authorization for this service. Some providers require that you register a Callback URL with your application. You should call this method to log the user in, and then call get_authenticated_user() in the handler you registered as your Callback URL to ...
bottle_auth/core/auth.py
def authorize_redirect(self, redirect_uri=None, client_id=None, client_secret=None, extra_params=None ): """Redirects the user to obtain OAuth authorization for this service. Some providers require that you register a Callback URL with your application. You should cal...
def authorize_redirect(self, redirect_uri=None, client_id=None, client_secret=None, extra_params=None ): """Redirects the user to obtain OAuth authorization for this service. Some providers require that you register a Callback URL with your application. You should cal...
[ "Redirects", "the", "user", "to", "obtain", "OAuth", "authorization", "for", "this", "service", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L567-L583
[ "def", "authorize_redirect", "(", "self", ",", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "extra_params", "=", "None", ")", ":", "args", "=", "{", "\"redirect_uri\"", ":", "redirect_uri", ",", "\"clien...
db07e526864aeac05ee68444b47e5db29540ce18
test
FriendFeedMixin.friendfeed_request
Fetches the given relative API path, e.g., "/bret/friends" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments. All the FriendFeed methods are documented at http://friendfeed.com/api/documentation. Many methods re...
bottle_auth/core/auth.py
def friendfeed_request(self, path, callback, access_token=None, post_args=None, **args): """Fetches the given relative API path, e.g., "/bret/friends" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments. ...
def friendfeed_request(self, path, callback, access_token=None, post_args=None, **args): """Fetches the given relative API path, e.g., "/bret/friends" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments. ...
[ "Fetches", "the", "given", "relative", "API", "path", "e", ".", "g", ".", "/", "bret", "/", "friends" ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L775-L828
[ "def", "friendfeed_request", "(", "self", ",", "path", ",", "callback", ",", "access_token", "=", "None", ",", "post_args", "=", "None", ",", "*", "*", "args", ")", ":", "# Add the OAuth resource request signature if we have credentials", "url", "=", "\"http://frien...
db07e526864aeac05ee68444b47e5db29540ce18
test
GoogleMixin.authorize_redirect
Authenticates and authorizes for the given Google resource. Some of the available resources are: * Gmail Contacts - http://www.google.com/m8/feeds/ * Calendar - http://www.google.com/calendar/feeds/ * Finance - http://finance.google.com/finance/feeds/ You can authorize multipl...
bottle_auth/core/auth.py
def authorize_redirect(self, oauth_scope, callback_uri=None, ax_attrs=["name","email","language","username"]): """Authenticates and authorizes for the given Google resource. Some of the available resources are: * Gmail Contacts - http://www.google.com/m8/feeds/ ...
def authorize_redirect(self, oauth_scope, callback_uri=None, ax_attrs=["name","email","language","username"]): """Authenticates and authorizes for the given Google resource. Some of the available resources are: * Gmail Contacts - http://www.google.com/m8/feeds/ ...
[ "Authenticates", "and", "authorizes", "for", "the", "given", "Google", "resource", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L885-L901
[ "def", "authorize_redirect", "(", "self", ",", "oauth_scope", ",", "callback_uri", "=", "None", ",", "ax_attrs", "=", "[", "\"name\"", ",", "\"email\"", ",", "\"language\"", ",", "\"username\"", "]", ")", ":", "callback_uri", "=", "callback_uri", "or", "self",...
db07e526864aeac05ee68444b47e5db29540ce18
test
GoogleMixin.get_authenticated_user
Fetches the authenticated user data upon redirect.
bottle_auth/core/auth.py
def get_authenticated_user(self, callback): """Fetches the authenticated user data upon redirect.""" # Look to see if we are doing combined OpenID/OAuth oauth_ns = "" for name, values in self.request.arguments.iteritems(): if name.startswith("openid.ns.") and \ ...
def get_authenticated_user(self, callback): """Fetches the authenticated user data upon redirect.""" # Look to see if we are doing combined OpenID/OAuth oauth_ns = "" for name, values in self.request.arguments.iteritems(): if name.startswith("openid.ns.") and \ ...
[ "Fetches", "the", "authenticated", "user", "data", "upon", "redirect", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L903-L919
[ "def", "get_authenticated_user", "(", "self", ",", "callback", ")", ":", "# Look to see if we are doing combined OpenID/OAuth", "oauth_ns", "=", "\"\"", "for", "name", ",", "values", "in", "self", ".", "request", ".", "arguments", ".", "iteritems", "(", ")", ":", ...
db07e526864aeac05ee68444b47e5db29540ce18
test
FacebookMixin.facebook_request
Makes a Facebook API REST request. We automatically include the Facebook API key and signature, but it is the callers responsibility to include 'session_key' and any other required arguments to the method. The available Facebook methods are documented here: http://wiki.develope...
bottle_auth/core/auth.py
def facebook_request(self, method, callback, **args): """Makes a Facebook API REST request. We automatically include the Facebook API key and signature, but it is the callers responsibility to include 'session_key' and any other required arguments to the method. The available F...
def facebook_request(self, method, callback, **args): """Makes a Facebook API REST request. We automatically include the Facebook API key and signature, but it is the callers responsibility to include 'session_key' and any other required arguments to the method. The available F...
[ "Makes", "a", "Facebook", "API", "REST", "request", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L1027-L1071
[ "def", "facebook_request", "(", "self", ",", "method", ",", "callback", ",", "*", "*", "args", ")", ":", "self", ".", "require_setting", "(", "\"facebook_api_key\"", ",", "\"Facebook Connect\"", ")", "self", ".", "require_setting", "(", "\"facebook_secret\"", ",...
db07e526864aeac05ee68444b47e5db29540ce18
test
FacebookGraphMixin.get_authenticated_user
Handles the login for the Facebook user, returning a user object. Example usage:: class FacebookGraphLoginHandler(LoginHandler, tornado.auth.FacebookGraphMixin): @tornado.web.asynchronous def get(self): if self.get_argument("code", False): se...
bottle_auth/core/auth.py
def get_authenticated_user(self, redirect_uri, client_id, client_secret, code, callback, fields=None): """Handles the login for the Facebook user, returning a user object. Example usage:: class FacebookGraphLoginHandler(LoginHandler, tornado.auth.FacebookGraphMixin)...
def get_authenticated_user(self, redirect_uri, client_id, client_secret, code, callback, fields=None): """Handles the login for the Facebook user, returning a user object. Example usage:: class FacebookGraphLoginHandler(LoginHandler, tornado.auth.FacebookGraphMixin)...
[ "Handles", "the", "login", "for", "the", "Facebook", "user", "returning", "a", "user", "object", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L1120-L1163
[ "def", "get_authenticated_user", "(", "self", ",", "redirect_uri", ",", "client_id", ",", "client_secret", ",", "code", ",", "callback", ",", "fields", "=", "None", ")", ":", "http", "=", "httpclient", ".", "AsyncHTTPClient", "(", ")", "args", "=", "{", "\...
db07e526864aeac05ee68444b47e5db29540ce18
test
FacebookGraphMixin.facebook_request
Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments. An introduction to the Facebook Graph API can be found at http://developers.facebook.com/docs/api ...
bottle_auth/core/auth.py
def facebook_request(self, path, callback, access_token=None, post_args=None, **args): """Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments....
def facebook_request(self, path, callback, access_token=None, post_args=None, **args): """Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, post_args should be provided. Query string arguments should be given as keyword arguments....
[ "Fetches", "the", "given", "relative", "API", "path", "e", ".", "g", ".", "/", "btaylor", "/", "picture" ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L1209-L1257
[ "def", "facebook_request", "(", "self", ",", "path", ",", "callback", ",", "access_token", "=", "None", ",", "post_args", "=", "None", ",", "*", "*", "args", ")", ":", "url", "=", "\"https://graph.facebook.com\"", "+", "path", "all_args", "=", "{", "}", ...
db07e526864aeac05ee68444b47e5db29540ce18
test
url_concat
Concatenate url and argument dictionary regardless of whether url has existing query parameters. >>> url_concat("http://example.com/foo?a=b", dict(c="d")) 'http://example.com/foo?a=b&c=d'
bottle_auth/core/httputil.py
def url_concat(url, args): """Concatenate url and argument dictionary regardless of whether url has existing query parameters. >>> url_concat("http://example.com/foo?a=b", dict(c="d")) 'http://example.com/foo?a=b&c=d' """ if not args: return url if url[-1] not in ('?', '&'): url += ...
def url_concat(url, args): """Concatenate url and argument dictionary regardless of whether url has existing query parameters. >>> url_concat("http://example.com/foo?a=b", dict(c="d")) 'http://example.com/foo?a=b&c=d' """ if not args: return url if url[-1] not in ('?', '&'): url += ...
[ "Concatenate", "url", "and", "argument", "dictionary", "regardless", "of", "whether", "url", "has", "existing", "query", "parameters", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L179-L189
[ "def", "url_concat", "(", "url", ",", "args", ")", ":", "if", "not", "args", ":", "return", "url", "if", "url", "[", "-", "1", "]", "not", "in", "(", "'?'", ",", "'&'", ")", ":", "url", "+=", "'&'", "if", "(", "'?'", "in", "url", ")", "else",...
db07e526864aeac05ee68444b47e5db29540ce18
test
parse_multipart_form_data
Parses a multipart/form-data body. The boundary and data parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body.
bottle_auth/core/httputil.py
def parse_multipart_form_data(boundary, data, arguments, files): """Parses a multipart/form-data body. The boundary and data parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body. """ # The standard allows fo...
def parse_multipart_form_data(boundary, data, arguments, files): """Parses a multipart/form-data body. The boundary and data parameters are both byte strings. The dictionaries given in the arguments and files parameters will be updated with the contents of the body. """ # The standard allows fo...
[ "Parses", "a", "multipart", "/", "form", "-", "data", "body", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L191-L233
[ "def", "parse_multipart_form_data", "(", "boundary", ",", "data", ",", "arguments", ",", "files", ")", ":", "# The standard allows for the boundary to be quoted in the header,", "# although it's rare (it happens at least for google app engine", "# xmpp). I think we're also supposed to h...
db07e526864aeac05ee68444b47e5db29540ce18
test
_parse_header
Parse a Content-type like header. Return the main content-type and a dictionary of options.
bottle_auth/core/httputil.py
def _parse_header(line): """Parse a Content-type like header. Return the main content-type and a dictionary of options. """ parts = _parseparam(';' + line) key = parts.next() pdict = {} for p in parts: i = p.find('=') if i >= 0: name = p[:i].strip().lower() ...
def _parse_header(line): """Parse a Content-type like header. Return the main content-type and a dictionary of options. """ parts = _parseparam(';' + line) key = parts.next() pdict = {} for p in parts: i = p.find('=') if i >= 0: name = p[:i].strip().lower() ...
[ "Parse", "a", "Content", "-", "type", "like", "header", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L251-L269
[ "def", "_parse_header", "(", "line", ")", ":", "parts", "=", "_parseparam", "(", "';'", "+", "line", ")", "key", "=", "parts", ".", "next", "(", ")", "pdict", "=", "{", "}", "for", "p", "in", "parts", ":", "i", "=", "p", ".", "find", "(", "'='"...
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders.add
Adds a new value for the given key.
bottle_auth/core/httputil.py
def add(self, name, value): """Adds a new value for the given key.""" norm_name = HTTPHeaders._normalize_name(name) self._last_key = norm_name if norm_name in self: # bypass our override of __setitem__ since it modifies _as_list dict.__setitem__(self, norm_name, s...
def add(self, name, value): """Adds a new value for the given key.""" norm_name = HTTPHeaders._normalize_name(name) self._last_key = norm_name if norm_name in self: # bypass our override of __setitem__ since it modifies _as_list dict.__setitem__(self, norm_name, s...
[ "Adds", "a", "new", "value", "for", "the", "given", "key", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L77-L86
[ "def", "add", "(", "self", ",", "name", ",", "value", ")", ":", "norm_name", "=", "HTTPHeaders", ".", "_normalize_name", "(", "name", ")", "self", ".", "_last_key", "=", "norm_name", "if", "norm_name", "in", "self", ":", "# bypass our override of __setitem__ s...
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders.get_list
Returns all values for the given header as a list.
bottle_auth/core/httputil.py
def get_list(self, name): """Returns all values for the given header as a list.""" norm_name = HTTPHeaders._normalize_name(name) return self._as_list.get(norm_name, [])
def get_list(self, name): """Returns all values for the given header as a list.""" norm_name = HTTPHeaders._normalize_name(name) return self._as_list.get(norm_name, [])
[ "Returns", "all", "values", "for", "the", "given", "header", "as", "a", "list", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L88-L91
[ "def", "get_list", "(", "self", ",", "name", ")", ":", "norm_name", "=", "HTTPHeaders", ".", "_normalize_name", "(", "name", ")", "return", "self", ".", "_as_list", ".", "get", "(", "norm_name", ",", "[", "]", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders.get_all
Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name.
bottle_auth/core/httputil.py
def get_all(self): """Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name. """ for name, list in self._as_list.iteritems(): for value in list: yield (name, value)
def get_all(self): """Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name. """ for name, list in self._as_list.iteritems(): for value in list: yield (name, value)
[ "Returns", "an", "iterable", "of", "all", "(", "name", "value", ")", "pairs", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L93-L101
[ "def", "get_all", "(", "self", ")", ":", "for", "name", ",", "list", "in", "self", ".", "_as_list", ".", "iteritems", "(", ")", ":", "for", "value", "in", "list", ":", "yield", "(", "name", ",", "value", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders.parse_line
Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html'
bottle_auth/core/httputil.py
def parse_line(self, line): """Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html' """ if line[0].isspace(): # continuation of a multi-line header ...
def parse_line(self, line): """Updates the dictionary with a single header line. >>> h = HTTPHeaders() >>> h.parse_line("Content-Type: text/html") >>> h.get('content-type') 'text/html' """ if line[0].isspace(): # continuation of a multi-line header ...
[ "Updates", "the", "dictionary", "with", "a", "single", "header", "line", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L103-L119
[ "def", "parse_line", "(", "self", ",", "line", ")", ":", "if", "line", "[", "0", "]", ".", "isspace", "(", ")", ":", "# continuation of a multi-line header", "new_part", "=", "' '", "+", "line", ".", "lstrip", "(", ")", "self", ".", "_as_list", "[", "s...
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders.parse
Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.iteritems()) [('Content-Length', '42'), ('Content-Type', 'text/html')]
bottle_auth/core/httputil.py
def parse(cls, headers): """Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.iteritems()) [('Content-Length', '42'), ('Content-Type', 'text/html')] """ h = cls() for line i...
def parse(cls, headers): """Returns a dictionary from HTTP header text. >>> h = HTTPHeaders.parse("Content-Type: text/html\\r\\nContent-Length: 42\\r\\n") >>> sorted(h.iteritems()) [('Content-Length', '42'), ('Content-Type', 'text/html')] """ h = cls() for line i...
[ "Returns", "a", "dictionary", "from", "HTTP", "header", "text", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L122-L133
[ "def", "parse", "(", "cls", ",", "headers", ")", ":", "h", "=", "cls", "(", ")", "for", "line", "in", "headers", ".", "splitlines", "(", ")", ":", "if", "line", ":", "h", ".", "parse_line", "(", "line", ")", "return", "h" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
HTTPHeaders._normalize_name
Converts a name to Http-Header-Case. >>> HTTPHeaders._normalize_name("coNtent-TYPE") 'Content-Type'
bottle_auth/core/httputil.py
def _normalize_name(name): """Converts a name to Http-Header-Case. >>> HTTPHeaders._normalize_name("coNtent-TYPE") 'Content-Type' """ try: return HTTPHeaders._normalized_headers[name] except KeyError: if HTTPHeaders._NORMALIZED_HEADER_RE.match(nam...
def _normalize_name(name): """Converts a name to Http-Header-Case. >>> HTTPHeaders._normalize_name("coNtent-TYPE") 'Content-Type' """ try: return HTTPHeaders._normalized_headers[name] except KeyError: if HTTPHeaders._NORMALIZED_HEADER_RE.match(nam...
[ "Converts", "a", "name", "to", "Http", "-", "Header", "-", "Case", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/httputil.py#L162-L176
[ "def", "_normalize_name", "(", "name", ")", ":", "try", ":", "return", "HTTPHeaders", ".", "_normalized_headers", "[", "name", "]", "except", "KeyError", ":", "if", "HTTPHeaders", ".", "_NORMALIZED_HEADER_RE", ".", "match", "(", "name", ")", ":", "normalized",...
db07e526864aeac05ee68444b47e5db29540ce18
test
utf8
Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8.
bottle_auth/core/escape.py
def utf8(value): """Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8. """ if isinstance(value, _UTF8_TYPES): return value assert isinstance(value, unicode...
def utf8(value): """Converts a string argument to a byte string. If the argument is already a byte string or None, it is returned unchanged. Otherwise it must be a unicode string and is encoded as utf8. """ if isinstance(value, _UTF8_TYPES): return value assert isinstance(value, unicode...
[ "Converts", "a", "string", "argument", "to", "a", "byte", "string", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/escape.py#L153-L162
[ "def", "utf8", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_UTF8_TYPES", ")", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "unicode", ")", "return", "value", ".", "encode", "(", "\"utf-8\"", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
to_unicode
Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8.
bottle_auth/core/escape.py
def to_unicode(value): """Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8. """ if isinstance(value, _TO_UNICODE_TYPES): return value assert isinstanc...
def to_unicode(value): """Converts a string argument to a unicode string. If the argument is already a unicode string or None, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8. """ if isinstance(value, _TO_UNICODE_TYPES): return value assert isinstanc...
[ "Converts", "a", "string", "argument", "to", "a", "unicode", "string", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/escape.py#L165-L174
[ "def", "to_unicode", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_TO_UNICODE_TYPES", ")", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "bytes", ")", "return", "value", ".", "decode", "(", "\"utf-8\"", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
to_basestring
Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two type...
bottle_auth/core/escape.py
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user su...
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user su...
[ "Converts", "a", "string", "argument", "to", "a", "subclass", "of", "basestring", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/escape.py#L188-L200
[ "def", "to_basestring", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_BASESTRING_TYPES", ")", ":", "return", "value", "assert", "isinstance", "(", "value", ",", "bytes", ")", "return", "value", ".", "decode", "(", "\"utf-8\"", ")" ]
db07e526864aeac05ee68444b47e5db29540ce18
test
recursive_unicode
Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries.
bottle_auth/core/escape.py
def recursive_unicode(obj): """Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries. """ if isinstance(obj, dict): return dict((recursive_unicode(k), recursive_unicode(v)) for (k,v) in obj.iteritems()) elif isinstance(obj, list): ...
def recursive_unicode(obj): """Walks a simple data structure, converting byte strings to unicode. Supports lists, tuples, and dictionaries. """ if isinstance(obj, dict): return dict((recursive_unicode(k), recursive_unicode(v)) for (k,v) in obj.iteritems()) elif isinstance(obj, list): ...
[ "Walks", "a", "simple", "data", "structure", "converting", "byte", "strings", "to", "unicode", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/escape.py#L202-L216
[ "def", "recursive_unicode", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "dict", "(", "(", "recursive_unicode", "(", "k", ")", ",", "recursive_unicode", "(", "v", ")", ")", "for", "(", "k", ",", "v", ")", "...
db07e526864aeac05ee68444b47e5db29540ce18
test
AuthPlugin.setup
Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.
bottle_auth/__init__.py
def setup(self, app): """ Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.""" for other in app.plugins: if not isinstance(other, AuthPlugin): continue if other.keyword == self.keyword: ...
def setup(self, app): """ Make sure that other installed plugins don't affect the same keyword argument and check if metadata is available.""" for other in app.plugins: if not isinstance(other, AuthPlugin): continue if other.keyword == self.keyword: ...
[ "Make", "sure", "that", "other", "installed", "plugins", "don", "t", "affect", "the", "same", "keyword", "argument", "and", "check", "if", "metadata", "is", "available", "." ]
avelino/bottle-auth
python
https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/__init__.py#L18-L27
[ "def", "setup", "(", "self", ",", "app", ")", ":", "for", "other", "in", "app", ".", "plugins", ":", "if", "not", "isinstance", "(", "other", ",", "AuthPlugin", ")", ":", "continue", "if", "other", ".", "keyword", "==", "self", ".", "keyword", ":", ...
db07e526864aeac05ee68444b47e5db29540ce18
test
iter_subclasses
Generator over all subclasses of a given class, in depth-first order. >>> bool in list(iter_subclasses(int)) True >>> class A(object): pass >>> class B(A): pass >>> class C(A): pass >>> class D(B,C): pass >>> class E(D): pass >>> >>> for cls in iter_subclasses(A): ... print(cls.__name__) B D E C >>> # ...
jaraco/classes/ancestry.py
def iter_subclasses(cls, _seen=None): """ Generator over all subclasses of a given class, in depth-first order. >>> bool in list(iter_subclasses(int)) True >>> class A(object): pass >>> class B(A): pass >>> class C(A): pass >>> class D(B,C): pass >>> class E(D): pass >>> >>> for cls in iter_subclasses(A): ...
def iter_subclasses(cls, _seen=None): """ Generator over all subclasses of a given class, in depth-first order. >>> bool in list(iter_subclasses(int)) True >>> class A(object): pass >>> class B(A): pass >>> class C(A): pass >>> class D(B,C): pass >>> class E(D): pass >>> >>> for cls in iter_subclasses(A): ...
[ "Generator", "over", "all", "subclasses", "of", "a", "given", "class", "in", "depth", "-", "first", "order", "." ]
jaraco/jaraco.classes
python
https://github.com/jaraco/jaraco.classes/blob/6347957478d589101a0774464d8d282520c2c990/jaraco/classes/ancestry.py#L30-L75
[ "def", "iter_subclasses", "(", "cls", ",", "_seen", "=", "None", ")", ":", "if", "not", "isinstance", "(", "cls", ",", "type", ")", ":", "raise", "TypeError", "(", "'iter_subclasses must be called with '", "'new-style classes, not %.100r'", "%", "cls", ")", "if"...
6347957478d589101a0774464d8d282520c2c990
test
CORS.selectPolicy
Based on the matching strategy and the origin and optionally the requested method a tuple of policyname and origin to pass back is returned.
wsgicors.py
def selectPolicy(self, origin, request_method=None): "Based on the matching strategy and the origin and optionally the requested method a tuple of policyname and origin to pass back is returned." ret_origin = None policyname = None if self.matchstrategy in ("firstmatch", "verbmatch"): ...
def selectPolicy(self, origin, request_method=None): "Based on the matching strategy and the origin and optionally the requested method a tuple of policyname and origin to pass back is returned." ret_origin = None policyname = None if self.matchstrategy in ("firstmatch", "verbmatch"): ...
[ "Based", "on", "the", "matching", "strategy", "and", "the", "origin", "and", "optionally", "the", "requested", "method", "a", "tuple", "of", "policyname", "and", "origin", "to", "pass", "back", "is", "returned", "." ]
may-day/wsgicors
python
https://github.com/may-day/wsgicors/blob/619867a811b10c788c40c4af5204142ffabe0f1f/wsgicors.py#L104-L127
[ "def", "selectPolicy", "(", "self", ",", "origin", ",", "request_method", "=", "None", ")", ":", "ret_origin", "=", "None", "policyname", "=", "None", "if", "self", ".", "matchstrategy", "in", "(", "\"firstmatch\"", ",", "\"verbmatch\"", ")", ":", "for", "...
619867a811b10c788c40c4af5204142ffabe0f1f
test
loads
Loads Appinfo content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with Appinfo data.
steamfiles/appinfo.py
def loads(data, wrapper=dict): """ Loads Appinfo content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with Appinfo data. """ if not isinstance(data, (bytes, by...
def loads(data, wrapper=dict): """ Loads Appinfo content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with Appinfo data. """ if not isinstance(data, (bytes, by...
[ "Loads", "Appinfo", "content", "into", "a", "Python", "object", ".", ":", "param", "data", ":", "A", "byte", "-", "like", "object", "with", "the", "contents", "of", "an", "Appinfo", "file", ".", ":", "param", "wrapper", ":", "A", "wrapping", "object", ...
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/appinfo.py#L32-L42
[ "def", "loads", "(", "data", ",", "wrapper", "=", "dict", ")", ":", "if", "not", "isinstance", "(", "data", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "raise", "TypeError", "(", "'can only load a bytes-like object as an Appinfo but got '", "+", "type"...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
dumps
Serializes a dictionary into Appinfo data. :param obj: A dictionary to serialize. :return:
steamfiles/appinfo.py
def dumps(obj): """ Serializes a dictionary into Appinfo data. :param obj: A dictionary to serialize. :return: """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as an Appinfo but got ' + type(obj).__name__) return b''.join(AppinfoEncoder(obj).iter_encode(...
def dumps(obj): """ Serializes a dictionary into Appinfo data. :param obj: A dictionary to serialize. :return: """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as an Appinfo but got ' + type(obj).__name__) return b''.join(AppinfoEncoder(obj).iter_encode(...
[ "Serializes", "a", "dictionary", "into", "Appinfo", "data", ".", ":", "param", "obj", ":", "A", "dictionary", "to", "serialize", ".", ":", "return", ":" ]
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/appinfo.py#L54-L63
[ "def", "dumps", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "raise", "TypeError", "(", "'can only dump a dictionary as an Appinfo but got '", "+", "type", "(", "obj", ")", ".", "__name__", ")", "return", "b''", ".", ...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
loads
Loads Manifest content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: A dictionary with Manifest data.
steamfiles/manifest.py
def loads(data, wrapper=dict): """ Loads Manifest content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: A dictionary with Manifest data. """ if not isinstance(data, (bytes, bytearray...
def loads(data, wrapper=dict): """ Loads Manifest content into a Python object. :param data: A byte-like object with the contents of an Appinfo file. :param wrapper: A wrapping object for key-value pairs. :return: A dictionary with Manifest data. """ if not isinstance(data, (bytes, bytearray...
[ "Loads", "Manifest", "content", "into", "a", "Python", "object", ".", ":", "param", "data", ":", "A", "byte", "-", "like", "object", "with", "the", "contents", "of", "an", "Appinfo", "file", ".", ":", "param", "wrapper", ":", "A", "wrapping", "object", ...
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/manifest.py#L46-L78
[ "def", "loads", "(", "data", ",", "wrapper", "=", "dict", ")", ":", "if", "not", "isinstance", "(", "data", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "raise", "TypeError", "(", "'can only load a bytes-like object as a Manifest but got '", "+", "type"...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
dumps
Serializes a dictionary into Manifest data. :param obj: A dictionary to serialize. :return: A file object.
steamfiles/manifest.py
def dumps(obj): """ Serializes a dictionary into Manifest data. :param obj: A dictionary to serialize. :return: A file object. """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as a Manifest but got ' + type(obj).__name__) data = [] int32 = struct.Str...
def dumps(obj): """ Serializes a dictionary into Manifest data. :param obj: A dictionary to serialize. :return: A file object. """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as a Manifest but got ' + type(obj).__name__) data = [] int32 = struct.Str...
[ "Serializes", "a", "dictionary", "into", "Manifest", "data", ".", ":", "param", "obj", ":", "A", "dictionary", "to", "serialize", ".", ":", "return", ":", "A", "file", "object", "." ]
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/manifest.py#L90-L116
[ "def", "dumps", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "raise", "TypeError", "(", "'can only dump a dictionary as a Manifest but got '", "+", "type", "(", "obj", ")", ".", "__name__", ")", "data", "=", "[", "]",...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
loads
Loads ACF content into a Python object. :param data: An UTF-8 encoded content of an ACF file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with ACF data.
steamfiles/acf.py
def loads(data, wrapper=dict): """ Loads ACF content into a Python object. :param data: An UTF-8 encoded content of an ACF file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with ACF data. """ if not isinstance(data, str): raise TypeError('can...
def loads(data, wrapper=dict): """ Loads ACF content into a Python object. :param data: An UTF-8 encoded content of an ACF file. :param wrapper: A wrapping object for key-value pairs. :return: An Ordered Dictionary with ACF data. """ if not isinstance(data, str): raise TypeError('can...
[ "Loads", "ACF", "content", "into", "a", "Python", "object", ".", ":", "param", "data", ":", "An", "UTF", "-", "8", "encoded", "content", "of", "an", "ACF", "file", ".", ":", "param", "wrapper", ":", "A", "wrapping", "object", "for", "key", "-", "valu...
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/acf.py#L7-L42
[ "def", "loads", "(", "data", ",", "wrapper", "=", "dict", ")", ":", "if", "not", "isinstance", "(", "data", ",", "str", ")", ":", "raise", "TypeError", "(", "'can only load a str as an ACF but got '", "+", "type", "(", "data", ")", ".", "__name__", ")", ...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
dumps
Serializes a dictionary into ACF data. :param obj: A dictionary to serialize. :return: ACF data.
steamfiles/acf.py
def dumps(obj): """ Serializes a dictionary into ACF data. :param obj: A dictionary to serialize. :return: ACF data. """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as an ACF but got ' + type(obj).__name__) return '\n'.join(_dumps(obj, level=0)) + '\n'
def dumps(obj): """ Serializes a dictionary into ACF data. :param obj: A dictionary to serialize. :return: ACF data. """ if not isinstance(obj, dict): raise TypeError('can only dump a dictionary as an ACF but got ' + type(obj).__name__) return '\n'.join(_dumps(obj, level=0)) + '\n'
[ "Serializes", "a", "dictionary", "into", "ACF", "data", ".", ":", "param", "obj", ":", "A", "dictionary", "to", "serialize", ".", ":", "return", ":", "ACF", "data", "." ]
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/acf.py#L55-L64
[ "def", "dumps", "(", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "raise", "TypeError", "(", "'can only dump a dictionary as an ACF but got '", "+", "type", "(", "obj", ")", ".", "__name__", ")", "return", "'\\n'", ".", "j...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
_dumps
Does the actual serializing of data into an ACF format. :param obj: A dictionary to serialize. :param level: Nesting level. :return: A List of strings.
steamfiles/acf.py
def _dumps(obj, level): """ Does the actual serializing of data into an ACF format. :param obj: A dictionary to serialize. :param level: Nesting level. :return: A List of strings. """ lines = [] indent = '\t' * level for key, value in obj.items(): if isinstance(value, dict):...
def _dumps(obj, level): """ Does the actual serializing of data into an ACF format. :param obj: A dictionary to serialize. :param level: Nesting level. :return: A List of strings. """ lines = [] indent = '\t' * level for key, value in obj.items(): if isinstance(value, dict):...
[ "Does", "the", "actual", "serializing", "of", "data", "into", "an", "ACF", "format", ".", ":", "param", "obj", ":", "A", "dictionary", "to", "serialize", ".", ":", "param", "level", ":", "Nesting", "level", ".", ":", "return", ":", "A", "List", "of", ...
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/acf.py#L76-L100
[ "def", "_dumps", "(", "obj", ",", "level", ")", ":", "lines", "=", "[", "]", "indent", "=", "'\\t'", "*", "level", "for", "key", ",", "value", "in", "obj", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "#...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
_prepare_subsection
Creates a subsection ready to be filled. :param data: Semi-parsed dictionary. :param sections: A list of sections. :param wrapper: A wrapping object for key-value pairs. :return: A newly created subsection.
steamfiles/acf.py
def _prepare_subsection(data, sections, wrapper): """ Creates a subsection ready to be filled. :param data: Semi-parsed dictionary. :param sections: A list of sections. :param wrapper: A wrapping object for key-value pairs. :return: A newly created subsection. """ current = data for ...
def _prepare_subsection(data, sections, wrapper): """ Creates a subsection ready to be filled. :param data: Semi-parsed dictionary. :param sections: A list of sections. :param wrapper: A wrapping object for key-value pairs. :return: A newly created subsection. """ current = data for ...
[ "Creates", "a", "subsection", "ready", "to", "be", "filled", ".", ":", "param", "data", ":", "Semi", "-", "parsed", "dictionary", ".", ":", "param", "sections", ":", "A", "list", "of", "sections", ".", ":", "param", "wrapper", ":", "A", "wrapping", "ob...
leovp/steamfiles
python
https://github.com/leovp/steamfiles/blob/e2264d09d128aecb838c4d310d7ea11e28c6597e/steamfiles/acf.py#L103-L116
[ "def", "_prepare_subsection", "(", "data", ",", "sections", ",", "wrapper", ")", ":", "current", "=", "data", "for", "i", "in", "sections", "[", ":", "-", "1", "]", ":", "current", "=", "current", "[", "i", "]", "current", "[", "sections", "[", "-", ...
e2264d09d128aecb838c4d310d7ea11e28c6597e
test
occupancy
Return a vector with the occupancy of each grid point for given array of points
insane/structure.py
def occupancy(grid, points, spacing=0.01): """Return a vector with the occupancy of each grid point for given array of points""" distances = ((grid[:,None,:] - points[None,:,:])**2).sum(axis=2) occupied = (distances < spacing).sum(axis=1) return occupied
def occupancy(grid, points, spacing=0.01): """Return a vector with the occupancy of each grid point for given array of points""" distances = ((grid[:,None,:] - points[None,:,:])**2).sum(axis=2) occupied = (distances < spacing).sum(axis=1) return occupied
[ "Return", "a", "vector", "with", "the", "occupancy", "of", "each", "grid", "point", "for", "given", "array", "of", "points" ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/structure.py#L10-L15
[ "def", "occupancy", "(", "grid", ",", "points", ",", "spacing", "=", "0.01", ")", ":", "distances", "=", "(", "(", "grid", "[", ":", ",", "None", ",", ":", "]", "-", "points", "[", "None", ",", ":", ",", ":", "]", ")", "**", "2", ")", ".", ...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
write_gro
Write a GRO file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic box as a 3x3 matrix.
insane/structure.py
def write_gro(outfile, title, atoms, box): """ Write a GRO file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic b...
def write_gro(outfile, title, atoms, box): """ Write a GRO file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic b...
[ "Write", "a", "GRO", "file", "." ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/structure.py#L332-L366
[ "def", "write_gro", "(", "outfile", ",", "title", ",", "atoms", ",", "box", ")", ":", "# Print the title", "print", "(", "title", ",", "file", "=", "outfile", ")", "# Print the number of atoms", "print", "(", "\"{:5d}\"", ".", "format", "(", "len", "(", "a...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
write_pdb
Write a PDB file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic box as a 3x3 matrix.
insane/structure.py
def write_pdb(outfile, title, atoms, box): """ Write a PDB file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic b...
def write_pdb(outfile, title, atoms, box): """ Write a PDB file. Parameters ---------- outfile The stream to write in. title The title of the GRO file. Must be a single line. atoms An instance of Structure containing the atoms to write. box The periodic b...
[ "Write", "a", "PDB", "file", "." ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/structure.py#L369-L394
[ "def", "write_pdb", "(", "outfile", ",", "title", ",", "atoms", ",", "box", ")", ":", "# Print the title", "print", "(", "'TITLE '", "+", "title", ",", "file", "=", "outfile", ")", "# Print the box", "print", "(", "pdbBoxString", "(", "box", ")", ",", "f...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
determine_molecule_numbers
Determine molecule numbers for given total, absolute and relative numbers
insane/core.py
def determine_molecule_numbers(total, molecules, absolute, relative): """Determine molecule numbers for given total, absolute and relative numbers""" weight = sum(relative) if not any(absolute): # Only relative numbers numbers = [int(total*i/weight) for i in relative] elif any(rela...
def determine_molecule_numbers(total, molecules, absolute, relative): """Determine molecule numbers for given total, absolute and relative numbers""" weight = sum(relative) if not any(absolute): # Only relative numbers numbers = [int(total*i/weight) for i in relative] elif any(rela...
[ "Determine", "molecule", "numbers", "for", "given", "total", "absolute", "and", "relative", "numbers" ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/core.py#L69-L84
[ "def", "determine_molecule_numbers", "(", "total", ",", "molecules", ",", "absolute", ",", "relative", ")", ":", "weight", "=", "sum", "(", "relative", ")", "if", "not", "any", "(", "absolute", ")", ":", "# Only relative numbers", "numbers", "=", "[", "int",...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
resize_pbc_for_lipids
Adapt the size of the box to accomodate the lipids. The PBC is changed **in place**.
insane/core.py
def resize_pbc_for_lipids(pbc, relL, relU, absL, absU, uparea, area, hole, proteins): """ Adapt the size of the box to accomodate the lipids. The PBC is changed **in place**. """ if any(relL) and any(relU): # Determine box from size # If one leaflet is defi...
def resize_pbc_for_lipids(pbc, relL, relU, absL, absU, uparea, area, hole, proteins): """ Adapt the size of the box to accomodate the lipids. The PBC is changed **in place**. """ if any(relL) and any(relU): # Determine box from size # If one leaflet is defi...
[ "Adapt", "the", "size", "of", "the", "box", "to", "accomodate", "the", "lipids", "." ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/core.py#L87-L144
[ "def", "resize_pbc_for_lipids", "(", "pbc", ",", "relL", ",", "relU", ",", "absL", ",", "absU", ",", "uparea", ",", "area", ",", "hole", ",", "proteins", ")", ":", "if", "any", "(", "relL", ")", "and", "any", "(", "relU", ")", ":", "# Determine box f...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
write_top
Write a basic TOP file. The topology is written in *outpath*. If *outpath* is en empty string, or anything for which ``bool(outpath) == False``, the topology is written on the standard error, and the header is omitted, and only what has been buit by Insane id displayed (e.g. Proteins are excluded). ...
insane/core.py
def write_top(outpath, molecules, title): """ Write a basic TOP file. The topology is written in *outpath*. If *outpath* is en empty string, or anything for which ``bool(outpath) == False``, the topology is written on the standard error, and the header is omitted, and only what has been buit by...
def write_top(outpath, molecules, title): """ Write a basic TOP file. The topology is written in *outpath*. If *outpath* is en empty string, or anything for which ``bool(outpath) == False``, the topology is written on the standard error, and the header is omitted, and only what has been buit by...
[ "Write", "a", "basic", "TOP", "file", "." ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/core.py#L773-L817
[ "def", "write_top", "(", "outpath", ",", "molecules", ",", "title", ")", ":", "topmolecules", "=", "[", "]", "for", "i", "in", "molecules", ":", "if", "i", "[", "0", "]", ".", "endswith", "(", "'.o'", ")", ":", "topmolecules", ".", "append", "(", "...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
iter_resource
Return a stream for a given resource file in the module. The resource file has to be part of the module and its filenane given relative to the module.
insane/utils.py
def iter_resource(filename): """ Return a stream for a given resource file in the module. The resource file has to be part of the module and its filenane given relative to the module. """ with pkg_resources.resource_stream(__name__, filename) as resource: for line in resource: ...
def iter_resource(filename): """ Return a stream for a given resource file in the module. The resource file has to be part of the module and its filenane given relative to the module. """ with pkg_resources.resource_stream(__name__, filename) as resource: for line in resource: ...
[ "Return", "a", "stream", "for", "a", "given", "resource", "file", "in", "the", "module", "." ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/utils.py#L25-L34
[ "def", "iter_resource", "(", "filename", ")", ":", "with", "pkg_resources", ".", "resource_stream", "(", "__name__", ",", "filename", ")", "as", "resource", ":", "for", "line", "in", "resource", ":", "yield", "line", ".", "decode", "(", "'utf-8'", ")" ]
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
Lipid.parse
Parse lipid definition from string: alhead=C P, allink=A A, altail=TCC CCCC, alname=DPSM, charge=0.0
insane/lipids.py
def parse(self, string): """ Parse lipid definition from string: alhead=C P, allink=A A, altail=TCC CCCC, alname=DPSM, charge=0.0 """ fields = [i.split("=") for i in string.split(', ')] for what, val in fields: what = what.strip() val = val.s...
def parse(self, string): """ Parse lipid definition from string: alhead=C P, allink=A A, altail=TCC CCCC, alname=DPSM, charge=0.0 """ fields = [i.split("=") for i in string.split(', ')] for what, val in fields: what = what.strip() val = val.s...
[ "Parse", "lipid", "definition", "from", "string", ":" ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/lipids.py#L66-L88
[ "def", "parse", "(", "self", ",", "string", ")", ":", "fields", "=", "[", "i", ".", "split", "(", "\"=\"", ")", "for", "i", "in", "string", ".", "split", "(", "', '", ")", "]", "for", "what", ",", "val", "in", "fields", ":", "what", "=", "what"...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
Lipid.build
Build/return a list of [(bead, x, y, z), ...]
insane/lipids.py
def build(self, **kwargs): """Build/return a list of [(bead, x, y, z), ...]""" if not self.coords: if self.beads and self.template: stuff = zip(self.beads, self.template) self.coords = [[i, x, y, z] for i, (x, y, z) in stuff if i != "-"] else: ...
def build(self, **kwargs): """Build/return a list of [(bead, x, y, z), ...]""" if not self.coords: if self.beads and self.template: stuff = zip(self.beads, self.template) self.coords = [[i, x, y, z] for i, (x, y, z) in stuff if i != "-"] else: ...
[ "Build", "/", "return", "a", "list", "of", "[", "(", "bead", "x", "y", "z", ")", "...", "]" ]
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/lipids.py#L90-L144
[ "def", "build", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "coords", ":", "if", "self", ".", "beads", "and", "self", ".", "template", ":", "stuff", "=", "zip", "(", "self", ".", "beads", ",", "self", ".", "template"...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
molspec
Parse a string for a lipid or a solvent as given on the command line (MOLECULE[=NUMBER|:NUMBER]); where `=NUMBER` sets an absolute number of the molecule, and `:NUMBER` sets a relative number of it. If both absolute and relative number are set False, then relative count is 1.
insane/converters.py
def molspec(x): """ Parse a string for a lipid or a solvent as given on the command line (MOLECULE[=NUMBER|:NUMBER]); where `=NUMBER` sets an absolute number of the molecule, and `:NUMBER` sets a relative number of it. If both absolute and relative number are set False, then relative count is 1. ...
def molspec(x): """ Parse a string for a lipid or a solvent as given on the command line (MOLECULE[=NUMBER|:NUMBER]); where `=NUMBER` sets an absolute number of the molecule, and `:NUMBER` sets a relative number of it. If both absolute and relative number are set False, then relative count is 1. ...
[ "Parse", "a", "string", "for", "a", "lipid", "or", "a", "solvent", "as", "given", "on", "the", "command", "line", "(", "MOLECULE", "[", "=", "NUMBER|", ":", "NUMBER", "]", ")", ";", "where", "=", "NUMBER", "sets", "an", "absolute", "number", "of", "t...
Tsjerk/Insane
python
https://github.com/Tsjerk/Insane/blob/b73f08910ddb0b66597b20ff75ecee7f65f4ecf6/insane/converters.py#L51-L70
[ "def", "molspec", "(", "x", ")", ":", "lip", "=", "x", ".", "split", "(", "\":\"", ")", "abn", "=", "lip", "[", "0", "]", ".", "split", "(", "\"=\"", ")", "names", "=", "abn", "[", "0", "]", "if", "len", "(", "abn", ")", ">", "1", ":", "n...
b73f08910ddb0b66597b20ff75ecee7f65f4ecf6
test
message_user
Send a message to a particular user. :param user: User instance :param message: Message to show :param level: Message level
async_messages/__init__.py
def message_user(user, message, level=constants.INFO): """ Send a message to a particular user. :param user: User instance :param message: Message to show :param level: Message level """ # We store a list of messages in the cache so we can have multiple messages # queued up for a user. ...
def message_user(user, message, level=constants.INFO): """ Send a message to a particular user. :param user: User instance :param message: Message to show :param level: Message level """ # We store a list of messages in the cache so we can have multiple messages # queued up for a user. ...
[ "Send", "a", "message", "to", "a", "particular", "user", "." ]
codeinthehole/django-async-messages
python
https://github.com/codeinthehole/django-async-messages/blob/292cb2fc517521dabc67b90e7ca5b1617f59e214/async_messages/__init__.py#L5-L18
[ "def", "message_user", "(", "user", ",", "message", ",", "level", "=", "constants", ".", "INFO", ")", ":", "# We store a list of messages in the cache so we can have multiple messages", "# queued up for a user.", "user_key", "=", "_user_key", "(", "user", ")", "messages",...
292cb2fc517521dabc67b90e7ca5b1617f59e214
test
message_users
Send a message to a group of users. :param users: Users queryset :param message: Message to show :param level: Message level
async_messages/__init__.py
def message_users(users, message, level=constants.INFO): """ Send a message to a group of users. :param users: Users queryset :param message: Message to show :param level: Message level """ for user in users: message_user(user, message, level)
def message_users(users, message, level=constants.INFO): """ Send a message to a group of users. :param users: Users queryset :param message: Message to show :param level: Message level """ for user in users: message_user(user, message, level)
[ "Send", "a", "message", "to", "a", "group", "of", "users", "." ]
codeinthehole/django-async-messages
python
https://github.com/codeinthehole/django-async-messages/blob/292cb2fc517521dabc67b90e7ca5b1617f59e214/async_messages/__init__.py#L21-L30
[ "def", "message_users", "(", "users", ",", "message", ",", "level", "=", "constants", ".", "INFO", ")", ":", "for", "user", "in", "users", ":", "message_user", "(", "user", ",", "message", ",", "level", ")" ]
292cb2fc517521dabc67b90e7ca5b1617f59e214