Search is not available for this dataset
text stringlengths 75 104k |
|---|
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 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 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 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 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 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 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 _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_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 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 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 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 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 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 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 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_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 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 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 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_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 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 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 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 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_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 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 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 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 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 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 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 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 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 _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 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 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 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 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 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 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 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 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 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_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 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 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_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 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(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 _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 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 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_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 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 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 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 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 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 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 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 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 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 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, 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 _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 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 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_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 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 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 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 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 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 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 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 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_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 get_messages(user):
"""
Fetch messages for given user. Returns None if no such message exists.
:param user: User instance
"""
key = _user_key(user)
result = cache.get(key)
if result:
cache.delete(key)
return result
return None |
def process_response(self, request, response):
"""
Check for messages for this user and, if it exists,
call the messages API with it
"""
if hasattr(request, "session") and hasattr(request, "user") and request.user.is_authenticated():
msgs = get_messages(request.user)
... |
def check_config_file(msg):
"""
Checks the config.json file for default settings and auth values.
Args:
:msg: (Message class) an instance of a message class.
"""
with jsonconfig.Config("messages", indent=4) as cfg:
verify_profile_name(msg, cfg)
retrieve_data_from_config(msg... |
def verify_profile_name(msg, cfg):
"""
Verifies the profile name exists in the config.json file.
Args:
:msg: (Message class) an instance of a message class.
:cfg: (jsonconfig.Config) config instance.
"""
if msg.profile not in cfg.data:
raise UnknownProfileError(msg.profile) |
def retrieve_data_from_config(msg, cfg):
"""
Update msg attrs with values from the profile configuration if the
msg.attr=None, else leave it alone.
Args:
:msg: (Message class) an instance of a message class.
:cfg: (jsonconfig.Config) config instance.
"""
msg_type = msg.__class__... |
def retrieve_pwd_from_config(msg, cfg):
"""
Retrieve auth from profile configuration and set in msg.auth attr.
Args:
:msg: (Message class) an instance of a message class.
:cfg: (jsonconfig.Config) config instance.
"""
msg_type = msg.__class__.__name__.lower()
key_fmt = msg.profi... |
def update_config_data(msg, cfg):
"""
Updates the profile's config entry with values set in each attr by the
user. This will overwrite existing values.
Args:
:msg: (Message class) an instance of a message class.
:cfg: (jsonconfig.Config) config instance.
"""
for attr in msg:
... |
def update_config_pwd(msg, cfg):
"""
Updates the profile's auth entry with values set by the user.
This will overwrite existing values.
Args:
:msg: (Message class) an instance of a message class.
:cfg: (jsonconfig.Config) config instance.
"""
msg_type = msg.__class__.__name__.lo... |
def create_config_profile(msg_type):
"""
Create a profile for the given message type.
Args:
:msg_type: (str) message type to create config entry.
"""
msg_type = msg_type.lower()
if msg_type not in CONFIG.keys():
raise UnsupportedMessageTypeError(msg_type)
display_required_... |
def display_required_items(msg_type):
"""
Display the required items needed to configure a profile for the given
message type.
Args:
:msg_type: (str) message type to create config entry.
"""
print("Configure a profile for: " + msg_type)
print("You will need the following information... |
def get_data_from_user(msg_type):
"""Get the required 'settings' from the user and return as a dict."""
data = {}
for k, v in CONFIG[msg_type]["settings"].items():
data[k] = input(v + ": ")
return data |
def get_auth_from_user(msg_type):
"""Get the required 'auth' from the user and return as a dict."""
auth = []
for k, v in CONFIG[msg_type]["auth"].items():
auth.append((k, getpass(v + ": ")))
return OrderedDict(auth) |
def configure_profile(msg_type, profile_name, data, auth):
"""
Create the profile entry.
Args:
:msg_type: (str) message type to create config entry.
:profile_name: (str) name of the profile entry
:data: (dict) dict values for the 'settings'
:auth: (dict) auth parameters
... |
def write_data(msg_type, profile_name, data, cfg):
"""
Write the settings into the data portion of the cfg.
Args:
:msg_type: (str) message type to create config entry.
:profile_name: (str) name of the profile entry
:data: (dict) dict values for the 'settings'
:cfg: (jsonconf... |
def write_auth(msg_type, profile_name, auth, cfg):
"""
Write the settings into the auth portion of the cfg.
Args:
:msg_type: (str) message type to create config entry.
:profile_name: (str) name of the profile entry
:auth: (dict) auth parameters
:cfg: (jsonconfig.Config) conf... |
def _construct_message(self):
"""Build the message params."""
self.message["text"] = ""
if self.from_:
self.message["text"] += "From: " + self.from_ + "\n"
if self.subject:
self.message["text"] += "Subject: " + self.subject + "\n"
self.message["text"] += ... |
def _add_attachments(self):
"""Add attachments."""
if self.attachments:
if not isinstance(self.attachments, list):
self.attachments = [self.attachments]
self.message["attachments"] = [
{"image_url": url, "author_name": ""} for url in self.attachme... |
def send(self, encoding="json"):
"""Send the message via HTTP POST, default is json-encoded."""
self._construct_message()
if self.verbose:
print(
"Debugging info"
"\n--------------"
"\n{} Message created.".format(timestamp())
... |
def _construct_message(self):
"""Set the message token/channel, then call the bas class constructor."""
self.message = {"token": self._auth, "channel": self.channel}
super()._construct_message() |
def send(msg_type, send_async=False, *args, **kwargs):
"""
Constructs a message class and sends the message.
Defaults to sending synchronously. Set send_async=True to send
asynchronously.
Args:
:msg_type: (str) the type of message to send, i.e. 'Email'
:send_async: (bool) default i... |
def message_factory(msg_type, msg_types=MESSAGE_TYPES, *args, **kwargs):
"""
Factory function to return the specified message instance.
Args:
:msg_type: (str) the type of message to send, i.e. 'Email'
:msg_types: (str, list, or set) the supported message types
:kwargs: (dict) keywor... |
def credential_property(cred):
"""
A credential property factory for each message class that will set
private attributes and return obfuscated credentials when requested.
"""
def getter(instance):
return "***obfuscated***"
def setter(instance, value):
private = "_" + cred
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.