repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
necaris/python3-openid | openid/extensions/ax.py | FetchRequest.parseExtensionArgs | def parseExtensionArgs(self, ax_args):
"""Given attribute exchange arguments, populate this FetchRequest.
@param ax_args: Attribute Exchange arguments from the request.
As returned from L{Message.getArgs<openid.message.Message.getArgs>}.
@type ax_args: dict
@raises KeyError... | python | def parseExtensionArgs(self, ax_args):
"""Given attribute exchange arguments, populate this FetchRequest.
@param ax_args: Attribute Exchange arguments from the request.
As returned from L{Message.getArgs<openid.message.Message.getArgs>}.
@type ax_args: dict
@raises KeyError... | [
"def",
"parseExtensionArgs",
"(",
"self",
",",
"ax_args",
")",
":",
"# Raises an exception if the mode is not the expected value",
"self",
".",
"_checkMode",
"(",
"ax_args",
")",
"aliases",
"=",
"NamespaceMap",
"(",
")",
"for",
"key",
",",
"value",
"in",
"ax_args",
... | Given attribute exchange arguments, populate this FetchRequest.
@param ax_args: Attribute Exchange arguments from the request.
As returned from L{Message.getArgs<openid.message.Message.getArgs>}.
@type ax_args: dict
@raises KeyError: if the message is not consistent in its use
... | [
"Given",
"attribute",
"exchange",
"arguments",
"populate",
"this",
"FetchRequest",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L334-L397 |
necaris/python3-openid | openid/consumer/html_parse.py | findLinksRel | def findLinksRel(link_attrs_list, target_rel):
"""Filter the list of link attributes on whether it has target_rel
as a relationship."""
# XXX: TESTME
matchesTarget = lambda attrs: linkHasRel(attrs, target_rel)
return list(filter(matchesTarget, link_attrs_list)) | python | def findLinksRel(link_attrs_list, target_rel):
"""Filter the list of link attributes on whether it has target_rel
as a relationship."""
# XXX: TESTME
matchesTarget = lambda attrs: linkHasRel(attrs, target_rel)
return list(filter(matchesTarget, link_attrs_list)) | [
"def",
"findLinksRel",
"(",
"link_attrs_list",
",",
"target_rel",
")",
":",
"# XXX: TESTME",
"matchesTarget",
"=",
"lambda",
"attrs",
":",
"linkHasRel",
"(",
"attrs",
",",
"target_rel",
")",
"return",
"list",
"(",
"filter",
"(",
"matchesTarget",
",",
"link_attrs... | Filter the list of link attributes on whether it has target_rel
as a relationship. | [
"Filter",
"the",
"list",
"of",
"link",
"attributes",
"on",
"whether",
"it",
"has",
"target_rel",
"as",
"a",
"relationship",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/html_parse.py#L262-L267 |
necaris/python3-openid | openid/store/sqlstore.py | SQLStore.txn_getAssociation | def txn_getAssociation(self, server_url, handle=None):
"""Get the most recent association that has been set for this
server URL and handle.
str -> NoneType or Association
"""
if handle is not None:
self.db_get_assoc(server_url, handle)
else:
self.... | python | def txn_getAssociation(self, server_url, handle=None):
"""Get the most recent association that has been set for this
server URL and handle.
str -> NoneType or Association
"""
if handle is not None:
self.db_get_assoc(server_url, handle)
else:
self.... | [
"def",
"txn_getAssociation",
"(",
"self",
",",
"server_url",
",",
"handle",
"=",
"None",
")",
":",
"if",
"handle",
"is",
"not",
"None",
":",
"self",
".",
"db_get_assoc",
"(",
"server_url",
",",
"handle",
")",
"else",
":",
"self",
".",
"db_get_assocs",
"(... | Get the most recent association that has been set for this
server URL and handle.
str -> NoneType or Association | [
"Get",
"the",
"most",
"recent",
"association",
"that",
"has",
"been",
"set",
"for",
"this",
"server",
"URL",
"and",
"handle",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/store/sqlstore.py#L220-L249 |
necaris/python3-openid | openid/fetchers.py | Urllib2Fetcher._makeResponse | def _makeResponse(self, urllib2_response):
'''
Construct an HTTPResponse from the the urllib response. Attempt to
decode the response body from bytes to str if the necessary information
is available.
'''
resp = HTTPResponse()
resp.body = urllib2_response.read(MAX_... | python | def _makeResponse(self, urllib2_response):
'''
Construct an HTTPResponse from the the urllib response. Attempt to
decode the response body from bytes to str if the necessary information
is available.
'''
resp = HTTPResponse()
resp.body = urllib2_response.read(MAX_... | [
"def",
"_makeResponse",
"(",
"self",
",",
"urllib2_response",
")",
":",
"resp",
"=",
"HTTPResponse",
"(",
")",
"resp",
".",
"body",
"=",
"urllib2_response",
".",
"read",
"(",
"MAX_RESPONSE_KB",
"*",
"1024",
")",
"resp",
".",
"final_url",
"=",
"urllib2_respon... | Construct an HTTPResponse from the the urllib response. Attempt to
decode the response body from bytes to str if the necessary information
is available. | [
"Construct",
"an",
"HTTPResponse",
"from",
"the",
"the",
"urllib",
"response",
".",
"Attempt",
"to",
"decode",
"the",
"response",
"body",
"from",
"bytes",
"to",
"str",
"if",
"the",
"necessary",
"information",
"is",
"available",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/fetchers.py#L243-L271 |
necaris/python3-openid | openid/fetchers.py | Urllib2Fetcher._parseHeaderValue | def _parseHeaderValue(self, header_value):
"""
Parse out a complex header value (such as Content-Type, with a value
like "text/html; charset=utf-8") into a main value and a dictionary of
extra information (in this case, 'text/html' and {'charset': 'utf8'}).
"""
values = h... | python | def _parseHeaderValue(self, header_value):
"""
Parse out a complex header value (such as Content-Type, with a value
like "text/html; charset=utf-8") into a main value and a dictionary of
extra information (in this case, 'text/html' and {'charset': 'utf8'}).
"""
values = h... | [
"def",
"_parseHeaderValue",
"(",
"self",
",",
"header_value",
")",
":",
"values",
"=",
"header_value",
".",
"split",
"(",
"';'",
",",
"1",
")",
"if",
"len",
"(",
"values",
")",
"==",
"1",
":",
"# There's no extra info -- return the main value and an empty dict",
... | Parse out a complex header value (such as Content-Type, with a value
like "text/html; charset=utf-8") into a main value and a dictionary of
extra information (in this case, 'text/html' and {'charset': 'utf8'}). | [
"Parse",
"out",
"a",
"complex",
"header",
"value",
"(",
"such",
"as",
"Content",
"-",
"Type",
"with",
"a",
"value",
"like",
"text",
"/",
"html",
";",
"charset",
"=",
"utf",
"-",
"8",
")",
"into",
"a",
"main",
"value",
"and",
"a",
"dictionary",
"of",
... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/fetchers.py#L279-L298 |
necaris/python3-openid | openid/message.py | registerNamespaceAlias | def registerNamespaceAlias(namespace_uri, alias):
"""
Registers a (namespace URI, alias) mapping in a global namespace
alias map. Raises NamespaceAliasRegistrationError if either the
namespace URI or alias has already been registered with a
different value. This function is required if you want to... | python | def registerNamespaceAlias(namespace_uri, alias):
"""
Registers a (namespace URI, alias) mapping in a global namespace
alias map. Raises NamespaceAliasRegistrationError if either the
namespace URI or alias has already been registered with a
different value. This function is required if you want to... | [
"def",
"registerNamespaceAlias",
"(",
"namespace_uri",
",",
"alias",
")",
":",
"global",
"registered_aliases",
"if",
"registered_aliases",
".",
"get",
"(",
"alias",
")",
"==",
"namespace_uri",
":",
"return",
"if",
"namespace_uri",
"in",
"list",
"(",
"registered_al... | Registers a (namespace URI, alias) mapping in a global namespace
alias map. Raises NamespaceAliasRegistrationError if either the
namespace URI or alias has already been registered with a
different value. This function is required if you want to use a
namespace with an OpenID 1 message. | [
"Registers",
"a",
"(",
"namespace",
"URI",
"alias",
")",
"mapping",
"in",
"a",
"global",
"namespace",
"alias",
"map",
".",
"Raises",
"NamespaceAliasRegistrationError",
"if",
"either",
"the",
"namespace",
"URI",
"or",
"alias",
"has",
"already",
"been",
"registere... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L115-L136 |
necaris/python3-openid | openid/message.py | Message.setOpenIDNamespace | def setOpenIDNamespace(self, openid_ns_uri, implicit):
"""Set the OpenID namespace URI used in this message.
@raises InvalidOpenIDNamespace: if the namespace is not in
L{Message.allowed_openid_namespaces}
"""
if isinstance(openid_ns_uri, bytes):
openid_ns_uri = s... | python | def setOpenIDNamespace(self, openid_ns_uri, implicit):
"""Set the OpenID namespace URI used in this message.
@raises InvalidOpenIDNamespace: if the namespace is not in
L{Message.allowed_openid_namespaces}
"""
if isinstance(openid_ns_uri, bytes):
openid_ns_uri = s... | [
"def",
"setOpenIDNamespace",
"(",
"self",
",",
"openid_ns_uri",
",",
"implicit",
")",
":",
"if",
"isinstance",
"(",
"openid_ns_uri",
",",
"bytes",
")",
":",
"openid_ns_uri",
"=",
"str",
"(",
"openid_ns_uri",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"if",
"ope... | Set the OpenID namespace URI used in this message.
@raises InvalidOpenIDNamespace: if the namespace is not in
L{Message.allowed_openid_namespaces} | [
"Set",
"the",
"OpenID",
"namespace",
"URI",
"used",
"in",
"this",
"message",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L256-L268 |
necaris/python3-openid | openid/message.py | Message.toPostArgs | def toPostArgs(self):
"""
Return all arguments with openid. in front of namespaced arguments.
@return bytes
"""
args = {}
# Add namespace definitions to the output
for ns_uri, alias in self.namespaces.items():
if self.namespaces.isImplicit(ns_uri):
... | python | def toPostArgs(self):
"""
Return all arguments with openid. in front of namespaced arguments.
@return bytes
"""
args = {}
# Add namespace definitions to the output
for ns_uri, alias in self.namespaces.items():
if self.namespaces.isImplicit(ns_uri):
... | [
"def",
"toPostArgs",
"(",
"self",
")",
":",
"args",
"=",
"{",
"}",
"# Add namespace definitions to the output",
"for",
"ns_uri",
",",
"alias",
"in",
"self",
".",
"namespaces",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"namespaces",
".",
"isImplicit",
... | Return all arguments with openid. in front of namespaced arguments.
@return bytes | [
"Return",
"all",
"arguments",
"with",
"openid",
".",
"in",
"front",
"of",
"namespaced",
"arguments",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L288-L310 |
necaris/python3-openid | openid/message.py | Message.toArgs | def toArgs(self):
"""Return all namespaced arguments, failing if any
non-namespaced arguments exist."""
# FIXME - undocumented exception
post_args = self.toPostArgs()
kvargs = {}
for k, v in post_args.items():
if not k.startswith('openid.'):
ra... | python | def toArgs(self):
"""Return all namespaced arguments, failing if any
non-namespaced arguments exist."""
# FIXME - undocumented exception
post_args = self.toPostArgs()
kvargs = {}
for k, v in post_args.items():
if not k.startswith('openid.'):
ra... | [
"def",
"toArgs",
"(",
"self",
")",
":",
"# FIXME - undocumented exception",
"post_args",
"=",
"self",
".",
"toPostArgs",
"(",
")",
"kvargs",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"post_args",
".",
"items",
"(",
")",
":",
"if",
"not",
"k",
".",
"... | Return all namespaced arguments, failing if any
non-namespaced arguments exist. | [
"Return",
"all",
"namespaced",
"arguments",
"failing",
"if",
"any",
"non",
"-",
"namespaced",
"arguments",
"exist",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L312-L326 |
necaris/python3-openid | openid/message.py | Message.toFormMarkup | def toFormMarkup(self,
action_url,
form_tag_attrs=None,
submit_text="Continue"):
"""Generate HTML form markup that contains the values in this
message, to be HTTP POSTed as x-www-form-urlencoded UTF-8.
@param action_url: The URL to ... | python | def toFormMarkup(self,
action_url,
form_tag_attrs=None,
submit_text="Continue"):
"""Generate HTML form markup that contains the values in this
message, to be HTTP POSTed as x-www-form-urlencoded UTF-8.
@param action_url: The URL to ... | [
"def",
"toFormMarkup",
"(",
"self",
",",
"action_url",
",",
"form_tag_attrs",
"=",
"None",
",",
"submit_text",
"=",
"\"Continue\"",
")",
":",
"if",
"ElementTree",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'This function requires ElementTree.'",
")",
"asser... | Generate HTML form markup that contains the values in this
message, to be HTTP POSTed as x-www-form-urlencoded UTF-8.
@param action_url: The URL to which the form will be POSTed
@type action_url: str
@param form_tag_attrs: Dictionary of attributes to be added to
the form ta... | [
"Generate",
"HTML",
"form",
"markup",
"that",
"contains",
"the",
"values",
"in",
"this",
"message",
"to",
"be",
"HTTP",
"POSTed",
"as",
"x",
"-",
"www",
"-",
"form",
"-",
"urlencoded",
"UTF",
"-",
"8",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L328-L383 |
necaris/python3-openid | openid/message.py | Message.toURLEncoded | def toURLEncoded(self):
"""Generate an x-www-urlencoded string"""
args = sorted(self.toPostArgs().items())
return urllib.parse.urlencode(args) | python | def toURLEncoded(self):
"""Generate an x-www-urlencoded string"""
args = sorted(self.toPostArgs().items())
return urllib.parse.urlencode(args) | [
"def",
"toURLEncoded",
"(",
"self",
")",
":",
"args",
"=",
"sorted",
"(",
"self",
".",
"toPostArgs",
"(",
")",
".",
"items",
"(",
")",
")",
"return",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"args",
")"
] | Generate an x-www-urlencoded string | [
"Generate",
"an",
"x",
"-",
"www",
"-",
"urlencoded",
"string"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L397-L400 |
necaris/python3-openid | openid/message.py | Message._fixNS | def _fixNS(self, namespace):
"""Convert an input value into the internally used values of
this object
@param namespace: The string or constant to convert
@type namespace: str or unicode or BARE_NS or OPENID_NS
"""
if isinstance(namespace, bytes):
namespace = ... | python | def _fixNS(self, namespace):
"""Convert an input value into the internally used values of
this object
@param namespace: The string or constant to convert
@type namespace: str or unicode or BARE_NS or OPENID_NS
"""
if isinstance(namespace, bytes):
namespace = ... | [
"def",
"_fixNS",
"(",
"self",
",",
"namespace",
")",
":",
"if",
"isinstance",
"(",
"namespace",
",",
"bytes",
")",
":",
"namespace",
"=",
"str",
"(",
"namespace",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"if",
"namespace",
"==",
"OPENID_NS",
":",
"if",
... | Convert an input value into the internally used values of
this object
@param namespace: The string or constant to convert
@type namespace: str or unicode or BARE_NS or OPENID_NS | [
"Convert",
"an",
"input",
"value",
"into",
"the",
"internally",
"used",
"values",
"of",
"this",
"object"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L402-L434 |
necaris/python3-openid | openid/message.py | Message.getArgs | def getArgs(self, namespace):
"""Get the arguments that are defined for this namespace URI
@returns: mapping from namespaced keys to values
@returntype: dict of {str:bytes}
"""
namespace = self._fixNS(namespace)
args = []
for ((pair_ns, ns_key), value) in self.ar... | python | def getArgs(self, namespace):
"""Get the arguments that are defined for this namespace URI
@returns: mapping from namespaced keys to values
@returntype: dict of {str:bytes}
"""
namespace = self._fixNS(namespace)
args = []
for ((pair_ns, ns_key), value) in self.ar... | [
"def",
"getArgs",
"(",
"self",
",",
"namespace",
")",
":",
"namespace",
"=",
"self",
".",
"_fixNS",
"(",
"namespace",
")",
"args",
"=",
"[",
"]",
"for",
"(",
"(",
"pair_ns",
",",
"ns_key",
")",
",",
"value",
")",
"in",
"self",
".",
"args",
".",
"... | Get the arguments that are defined for this namespace URI
@returns: mapping from namespaced keys to values
@returntype: dict of {str:bytes} | [
"Get",
"the",
"arguments",
"that",
"are",
"defined",
"for",
"this",
"namespace",
"URI"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L488-L507 |
necaris/python3-openid | openid/message.py | Message.setArg | def setArg(self, namespace, key, value):
"""Set a single argument in this namespace"""
assert key is not None
assert value is not None
namespace = self._fixNS(namespace)
# try to ensure that internally it's consistent, at least: str -> str
if isinstance(value, bytes):
... | python | def setArg(self, namespace, key, value):
"""Set a single argument in this namespace"""
assert key is not None
assert value is not None
namespace = self._fixNS(namespace)
# try to ensure that internally it's consistent, at least: str -> str
if isinstance(value, bytes):
... | [
"def",
"setArg",
"(",
"self",
",",
"namespace",
",",
"key",
",",
"value",
")",
":",
"assert",
"key",
"is",
"not",
"None",
"assert",
"value",
"is",
"not",
"None",
"namespace",
"=",
"self",
".",
"_fixNS",
"(",
"namespace",
")",
"# try to ensure that internal... | Set a single argument in this namespace | [
"Set",
"a",
"single",
"argument",
"in",
"this",
"namespace"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L519-L529 |
necaris/python3-openid | openid/message.py | NamespaceMap.addAlias | def addAlias(self, namespace_uri, desired_alias, implicit=False):
"""Add an alias from this namespace URI to the desired alias
"""
if isinstance(namespace_uri, bytes):
namespace_uri = str(namespace_uri, encoding="utf-8")
# Check that desired_alias is not an openid protocol fi... | python | def addAlias(self, namespace_uri, desired_alias, implicit=False):
"""Add an alias from this namespace URI to the desired alias
"""
if isinstance(namespace_uri, bytes):
namespace_uri = str(namespace_uri, encoding="utf-8")
# Check that desired_alias is not an openid protocol fi... | [
"def",
"addAlias",
"(",
"self",
",",
"namespace_uri",
",",
"desired_alias",
",",
"implicit",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"namespace_uri",
",",
"bytes",
")",
":",
"namespace_uri",
"=",
"str",
"(",
"namespace_uri",
",",
"encoding",
"=",
... | Add an alias from this namespace URI to the desired alias | [
"Add",
"an",
"alias",
"from",
"this",
"namespace",
"URI",
"to",
"the",
"desired",
"alias"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/message.py#L604-L648 |
necaris/python3-openid | openid/yadis/xrires.py | _appendArgs | def _appendArgs(url, args):
"""Append some arguments to an HTTP query.
"""
# to be merged with oidutil.appendArgs when we combine the projects.
if hasattr(args, 'items'):
args = list(args.items())
args.sort()
if len(args) == 0:
return url
# According to XRI Resolution s... | python | def _appendArgs(url, args):
"""Append some arguments to an HTTP query.
"""
# to be merged with oidutil.appendArgs when we combine the projects.
if hasattr(args, 'items'):
args = list(args.items())
args.sort()
if len(args) == 0:
return url
# According to XRI Resolution s... | [
"def",
"_appendArgs",
"(",
"url",
",",
"args",
")",
":",
"# to be merged with oidutil.appendArgs when we combine the projects.",
"if",
"hasattr",
"(",
"args",
",",
"'items'",
")",
":",
"args",
"=",
"list",
"(",
"args",
".",
"items",
"(",
")",
")",
"args",
".",... | Append some arguments to an HTTP query. | [
"Append",
"some",
"arguments",
"to",
"an",
"HTTP",
"query",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/yadis/xrires.py#L100-L123 |
necaris/python3-openid | examples/djopenid/util.py | getOpenIDStore | def getOpenIDStore(filestore_path, table_prefix):
"""
Returns an OpenID association store object based on the database
engine chosen for this Django application.
* If no database engine is chosen, a filesystem-based store will
be used whose path is filestore_path.
* If a database engine is c... | python | def getOpenIDStore(filestore_path, table_prefix):
"""
Returns an OpenID association store object based on the database
engine chosen for this Django application.
* If no database engine is chosen, a filesystem-based store will
be used whose path is filestore_path.
* If a database engine is c... | [
"def",
"getOpenIDStore",
"(",
"filestore_path",
",",
"table_prefix",
")",
":",
"db_engine",
"=",
"settings",
".",
"DATABASES",
"[",
"'default'",
"]",
"[",
"'ENGINE'",
"]",
"if",
"not",
"db_engine",
":",
"return",
"FileOpenIDStore",
"(",
"filestore_path",
")",
... | Returns an OpenID association store object based on the database
engine chosen for this Django application.
* If no database engine is chosen, a filesystem-based store will
be used whose path is filestore_path.
* If a database engine is chosen, a store object for that database
type will be ret... | [
"Returns",
"an",
"OpenID",
"association",
"store",
"object",
"based",
"on",
"the",
"database",
"engine",
"chosen",
"for",
"this",
"Django",
"application",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/djopenid/util.py#L27-L91 |
necaris/python3-openid | examples/djopenid/util.py | renderXRDS | def renderXRDS(request, type_uris, endpoint_urls):
"""Render an XRDS page with the specified type URIs and endpoint
URLs in one service block, and return a response with the
appropriate content-type.
"""
response = render_to_response(
'xrds.xml', {'type_uris': type_uris,
... | python | def renderXRDS(request, type_uris, endpoint_urls):
"""Render an XRDS page with the specified type URIs and endpoint
URLs in one service block, and return a response with the
appropriate content-type.
"""
response = render_to_response(
'xrds.xml', {'type_uris': type_uris,
... | [
"def",
"renderXRDS",
"(",
"request",
",",
"type_uris",
",",
"endpoint_urls",
")",
":",
"response",
"=",
"render_to_response",
"(",
"'xrds.xml'",
",",
"{",
"'type_uris'",
":",
"type_uris",
",",
"'endpoint_urls'",
":",
"endpoint_urls",
"}",
",",
"context_instance",
... | Render an XRDS page with the specified type URIs and endpoint
URLs in one service block, and return a response with the
appropriate content-type. | [
"Render",
"an",
"XRDS",
"page",
"with",
"the",
"specified",
"type",
"URIs",
"and",
"endpoint",
"URLs",
"in",
"one",
"service",
"block",
"and",
"return",
"a",
"response",
"with",
"the",
"appropriate",
"content",
"-",
"type",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/djopenid/util.py#L147-L157 |
necaris/python3-openid | openid/codecutil.py | _pct_escape_handler | def _pct_escape_handler(err):
'''
Encoding error handler that does percent-escaping of Unicode, to be used
with codecs.register_error
TODO: replace use of this with urllib.parse.quote as appropriate
'''
chunk = err.object[err.start:err.end]
replacements = _pct_encoded_replacements(chunk)
... | python | def _pct_escape_handler(err):
'''
Encoding error handler that does percent-escaping of Unicode, to be used
with codecs.register_error
TODO: replace use of this with urllib.parse.quote as appropriate
'''
chunk = err.object[err.start:err.end]
replacements = _pct_encoded_replacements(chunk)
... | [
"def",
"_pct_escape_handler",
"(",
"err",
")",
":",
"chunk",
"=",
"err",
".",
"object",
"[",
"err",
".",
"start",
":",
"err",
".",
"end",
"]",
"replacements",
"=",
"_pct_encoded_replacements",
"(",
"chunk",
")",
"return",
"(",
"\"\"",
".",
"join",
"(",
... | Encoding error handler that does percent-escaping of Unicode, to be used
with codecs.register_error
TODO: replace use of this with urllib.parse.quote as appropriate | [
"Encoding",
"error",
"handler",
"that",
"does",
"percent",
"-",
"escaping",
"of",
"Unicode",
"to",
"be",
"used",
"with",
"codecs",
".",
"register_error",
"TODO",
":",
"replace",
"use",
"of",
"this",
"with",
"urllib",
".",
"parse",
".",
"quote",
"as",
"appr... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/codecutil.py#L80-L88 |
necaris/python3-openid | openid/kvform.py | seqToKV | def seqToKV(seq, strict=False):
"""Represent a sequence of pairs of strings as newline-terminated
key:value pairs. The pairs are generated in the order given.
@param seq: The pairs
@type seq: [(str, (unicode|str))]
@return: A string representation of the sequence
@rtype: bytes
"""
def... | python | def seqToKV(seq, strict=False):
"""Represent a sequence of pairs of strings as newline-terminated
key:value pairs. The pairs are generated in the order given.
@param seq: The pairs
@type seq: [(str, (unicode|str))]
@return: A string representation of the sequence
@rtype: bytes
"""
def... | [
"def",
"seqToKV",
"(",
"seq",
",",
"strict",
"=",
"False",
")",
":",
"def",
"err",
"(",
"msg",
")",
":",
"formatted",
"=",
"'seqToKV warning: %s: %r'",
"%",
"(",
"msg",
",",
"seq",
")",
"if",
"strict",
":",
"raise",
"KVFormError",
"(",
"formatted",
")"... | Represent a sequence of pairs of strings as newline-terminated
key:value pairs. The pairs are generated in the order given.
@param seq: The pairs
@type seq: [(str, (unicode|str))]
@return: A string representation of the sequence
@rtype: bytes | [
"Represent",
"a",
"sequence",
"of",
"pairs",
"of",
"strings",
"as",
"newline",
"-",
"terminated",
"key",
":",
"value",
"pairs",
".",
"The",
"pairs",
"are",
"generated",
"in",
"the",
"order",
"given",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/kvform.py#L10-L63 |
necaris/python3-openid | openid/yadis/xri.py | iriToURI | def iriToURI(iri):
"""Transform an IRI to a URI by escaping unicode."""
# According to RFC 3987, section 3.1, "Mapping of IRIs to URIs"
if isinstance(iri, bytes):
iri = str(iri, encoding="utf-8")
return iri.encode('ascii', errors='oid_percent_escape').decode() | python | def iriToURI(iri):
"""Transform an IRI to a URI by escaping unicode."""
# According to RFC 3987, section 3.1, "Mapping of IRIs to URIs"
if isinstance(iri, bytes):
iri = str(iri, encoding="utf-8")
return iri.encode('ascii', errors='oid_percent_escape').decode() | [
"def",
"iriToURI",
"(",
"iri",
")",
":",
"# According to RFC 3987, section 3.1, \"Mapping of IRIs to URIs\"",
"if",
"isinstance",
"(",
"iri",
",",
"bytes",
")",
":",
"iri",
"=",
"str",
"(",
"iri",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"return",
"iri",
".",
"... | Transform an IRI to a URI by escaping unicode. | [
"Transform",
"an",
"IRI",
"to",
"a",
"URI",
"by",
"escaping",
"unicode",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/yadis/xri.py#L59-L64 |
necaris/python3-openid | openid/urinorm.py | urinorm | def urinorm(uri):
'''
Normalize a URI
'''
# TODO: use urllib.parse instead of these complex regular expressions
if isinstance(uri, bytes):
uri = str(uri, encoding='utf-8')
uri = uri.encode('ascii', errors='oid_percent_escape').decode('utf-8')
# _escapeme_re.sub(_pct_escape_unicode, ... | python | def urinorm(uri):
'''
Normalize a URI
'''
# TODO: use urllib.parse instead of these complex regular expressions
if isinstance(uri, bytes):
uri = str(uri, encoding='utf-8')
uri = uri.encode('ascii', errors='oid_percent_escape').decode('utf-8')
# _escapeme_re.sub(_pct_escape_unicode, ... | [
"def",
"urinorm",
"(",
"uri",
")",
":",
"# TODO: use urllib.parse instead of these complex regular expressions",
"if",
"isinstance",
"(",
"uri",
",",
"bytes",
")",
":",
"uri",
"=",
"str",
"(",
"uri",
",",
"encoding",
"=",
"'utf-8'",
")",
"uri",
"=",
"uri",
"."... | Normalize a URI | [
"Normalize",
"a",
"URI"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/urinorm.py#L92-L161 |
necaris/python3-openid | examples/djopenid/server/views.py | server | def server(request):
"""
Respond to requests for the server's primary web page.
"""
return render_to_response(
'server/index.html', {
'user_url': getViewURL(request, idPage),
'server_xrds_url': getViewURL(request, idpXrds),
},
context_instance=RequestConte... | python | def server(request):
"""
Respond to requests for the server's primary web page.
"""
return render_to_response(
'server/index.html', {
'user_url': getViewURL(request, idPage),
'server_xrds_url': getViewURL(request, idpXrds),
},
context_instance=RequestConte... | [
"def",
"server",
"(",
"request",
")",
":",
"return",
"render_to_response",
"(",
"'server/index.html'",
",",
"{",
"'user_url'",
":",
"getViewURL",
"(",
"request",
",",
"idPage",
")",
",",
"'server_xrds_url'",
":",
"getViewURL",
"(",
"request",
",",
"idpXrds",
"... | Respond to requests for the server's primary web page. | [
"Respond",
"to",
"requests",
"for",
"the",
"server",
"s",
"primary",
"web",
"page",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/djopenid/server/views.py#L68-L77 |
necaris/python3-openid | examples/djopenid/server/views.py | displayResponse | def displayResponse(request, openid_response):
"""
Display an OpenID response. Errors will be displayed directly to
the user; successful responses and other protocol-level messages
will be sent using the proper mechanism (i.e., direct response,
redirection, etc.).
"""
s = getServer(request)... | python | def displayResponse(request, openid_response):
"""
Display an OpenID response. Errors will be displayed directly to
the user; successful responses and other protocol-level messages
will be sent using the proper mechanism (i.e., direct response,
redirection, etc.).
"""
s = getServer(request)... | [
"def",
"displayResponse",
"(",
"request",
",",
"openid_response",
")",
":",
"s",
"=",
"getServer",
"(",
"request",
")",
"# Encode the response into something that is renderable.",
"try",
":",
"webresponse",
"=",
"s",
".",
"encodeResponse",
"(",
"openid_response",
")",... | Display an OpenID response. Errors will be displayed directly to
the user; successful responses and other protocol-level messages
will be sent using the proper mechanism (i.e., direct response,
redirection, etc.). | [
"Display",
"an",
"OpenID",
"response",
".",
"Errors",
"will",
"be",
"displayed",
"directly",
"to",
"the",
"user",
";",
"successful",
"responses",
"and",
"other",
"protocol",
"-",
"level",
"messages",
"will",
"be",
"sent",
"using",
"the",
"proper",
"mechanism",... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/djopenid/server/views.py#L261-L287 |
necaris/python3-openid | openid/store/filestore.py | _removeIfPresent | def _removeIfPresent(filename):
"""Attempt to remove a file, returning whether the file existed at
the time of the call.
str -> bool
"""
try:
os.unlink(filename)
except OSError as why:
if why.errno == ENOENT:
# Someone beat us to it, but it's gone, so that's OK
... | python | def _removeIfPresent(filename):
"""Attempt to remove a file, returning whether the file existed at
the time of the call.
str -> bool
"""
try:
os.unlink(filename)
except OSError as why:
if why.errno == ENOENT:
# Someone beat us to it, but it's gone, so that's OK
... | [
"def",
"_removeIfPresent",
"(",
"filename",
")",
":",
"try",
":",
"os",
".",
"unlink",
"(",
"filename",
")",
"except",
"OSError",
"as",
"why",
":",
"if",
"why",
".",
"errno",
"==",
"ENOENT",
":",
"# Someone beat us to it, but it's gone, so that's OK",
"return",
... | Attempt to remove a file, returning whether the file existed at
the time of the call.
str -> bool | [
"Attempt",
"to",
"remove",
"a",
"file",
"returning",
"whether",
"the",
"file",
"existed",
"at",
"the",
"time",
"of",
"the",
"call",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/store/filestore.py#L45-L61 |
necaris/python3-openid | openid/store/filestore.py | FileOpenIDStore.storeAssociation | def storeAssociation(self, server_url, association):
"""Store an association in the association directory.
(str, Association) -> NoneType
"""
association_s = association.serialize() # NOTE: UTF-8 encoded bytes
filename = self.getAssociationFilename(server_url, association.handl... | python | def storeAssociation(self, server_url, association):
"""Store an association in the association directory.
(str, Association) -> NoneType
"""
association_s = association.serialize() # NOTE: UTF-8 encoded bytes
filename = self.getAssociationFilename(server_url, association.handl... | [
"def",
"storeAssociation",
"(",
"self",
",",
"server_url",
",",
"association",
")",
":",
"association_s",
"=",
"association",
".",
"serialize",
"(",
")",
"# NOTE: UTF-8 encoded bytes",
"filename",
"=",
"self",
".",
"getAssociationFilename",
"(",
"server_url",
",",
... | Store an association in the association directory.
(str, Association) -> NoneType | [
"Store",
"an",
"association",
"in",
"the",
"association",
"directory",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/store/filestore.py#L175-L215 |
necaris/python3-openid | examples/consumer.py | OpenIDRequestHandler.doVerify | def doVerify(self):
"""Process the form submission, initating OpenID verification.
"""
# First, make sure that the user entered something
openid_url = self.query.get('openid_identifier')
if not openid_url:
self.render(
'Enter an OpenID Identifier to v... | python | def doVerify(self):
"""Process the form submission, initating OpenID verification.
"""
# First, make sure that the user entered something
openid_url = self.query.get('openid_identifier')
if not openid_url:
self.render(
'Enter an OpenID Identifier to v... | [
"def",
"doVerify",
"(",
"self",
")",
":",
"# First, make sure that the user entered something",
"openid_url",
"=",
"self",
".",
"query",
".",
"get",
"(",
"'openid_identifier'",
")",
"if",
"not",
"openid_url",
":",
"self",
".",
"render",
"(",
"'Enter an OpenID Identi... | Process the form submission, initating OpenID verification. | [
"Process",
"the",
"form",
"submission",
"initating",
"OpenID",
"verification",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/consumer.py#L160-L219 |
necaris/python3-openid | examples/consumer.py | OpenIDRequestHandler.buildURL | def buildURL(self, action, **query):
"""Build a URL relative to the server base_url, with the given
query parameters added."""
base = urllib.parse.urljoin(self.server.base_url, action)
return appendArgs(base, query) | python | def buildURL(self, action, **query):
"""Build a URL relative to the server base_url, with the given
query parameters added."""
base = urllib.parse.urljoin(self.server.base_url, action)
return appendArgs(base, query) | [
"def",
"buildURL",
"(",
"self",
",",
"action",
",",
"*",
"*",
"query",
")",
":",
"base",
"=",
"urllib",
".",
"parse",
".",
"urljoin",
"(",
"self",
".",
"server",
".",
"base_url",
",",
"action",
")",
"return",
"appendArgs",
"(",
"base",
",",
"query",
... | Build a URL relative to the server base_url, with the given
query parameters added. | [
"Build",
"a",
"URL",
"relative",
"to",
"the",
"server",
"base_url",
"with",
"the",
"given",
"query",
"parameters",
"added",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/examples/consumer.py#L357-L361 |
necaris/python3-openid | openid/server/server.py | AssociateRequest.answer | def answer(self, assoc):
"""Respond to this request with an X{association}.
@param assoc: The association to send back.
@type assoc: L{openid.association.Association}
@returns: A response with the association information, encrypted
to the consumer's X{public key} if appropr... | python | def answer(self, assoc):
"""Respond to this request with an X{association}.
@param assoc: The association to send back.
@type assoc: L{openid.association.Association}
@returns: A response with the association information, encrypted
to the consumer's X{public key} if appropr... | [
"def",
"answer",
"(",
"self",
",",
"assoc",
")",
":",
"response",
"=",
"OpenIDResponse",
"(",
"self",
")",
"response",
".",
"fields",
".",
"updateArgs",
"(",
"OPENID_NS",
",",
"{",
"'expires_in'",
":",
"str",
"(",
"assoc",
".",
"expiresIn",
")",
",",
"... | Respond to this request with an X{association}.
@param assoc: The association to send back.
@type assoc: L{openid.association.Association}
@returns: A response with the association information, encrypted
to the consumer's X{public key} if appropriate.
@returntype: L{OpenIDR... | [
"Respond",
"to",
"this",
"request",
"with",
"an",
"X",
"{",
"association",
"}",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/server/server.py#L456-L482 |
necaris/python3-openid | openid/server/server.py | OpenIDResponse.whichEncoding | def whichEncoding(self):
"""How should I be encoded?
@returns: one of ENCODE_URL, ENCODE_HTML_FORM, or ENCODE_KVFORM.
@change: 2.1.0 added the ENCODE_HTML_FORM response.
"""
if self.request.mode in BROWSER_REQUEST_MODES:
if self.fields.getOpenIDNamespace() == OPENID... | python | def whichEncoding(self):
"""How should I be encoded?
@returns: one of ENCODE_URL, ENCODE_HTML_FORM, or ENCODE_KVFORM.
@change: 2.1.0 added the ENCODE_HTML_FORM response.
"""
if self.request.mode in BROWSER_REQUEST_MODES:
if self.fields.getOpenIDNamespace() == OPENID... | [
"def",
"whichEncoding",
"(",
"self",
")",
":",
"if",
"self",
".",
"request",
".",
"mode",
"in",
"BROWSER_REQUEST_MODES",
":",
"if",
"self",
".",
"fields",
".",
"getOpenIDNamespace",
"(",
")",
"==",
"OPENID2_NS",
"and",
"len",
"(",
"self",
".",
"encodeToURL... | How should I be encoded?
@returns: one of ENCODE_URL, ENCODE_HTML_FORM, or ENCODE_KVFORM.
@change: 2.1.0 added the ENCODE_HTML_FORM response. | [
"How",
"should",
"I",
"be",
"encoded?"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/server/server.py#L1042-L1056 |
necaris/python3-openid | openid/extensions/draft/pape5.py | PAPEExtension._generateAlias | def _generateAlias(self):
"""Return an unused auth level alias"""
for i in range(1000):
alias = 'cust%d' % (i, )
if alias not in self.auth_level_aliases:
return alias
raise RuntimeError('Could not find an unused alias (tried 1000!)') | python | def _generateAlias(self):
"""Return an unused auth level alias"""
for i in range(1000):
alias = 'cust%d' % (i, )
if alias not in self.auth_level_aliases:
return alias
raise RuntimeError('Could not find an unused alias (tried 1000!)') | [
"def",
"_generateAlias",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1000",
")",
":",
"alias",
"=",
"'cust%d'",
"%",
"(",
"i",
",",
")",
"if",
"alias",
"not",
"in",
"self",
".",
"auth_level_aliases",
":",
"return",
"alias",
"raise",
"Runt... | Return an unused auth level alias | [
"Return",
"an",
"unused",
"auth",
"level",
"alias"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/draft/pape5.py#L73-L80 |
necaris/python3-openid | openid/extensions/draft/pape5.py | PAPEExtension._getAlias | def _getAlias(self, auth_level_uri):
"""Return the alias for the specified auth level URI.
@raises KeyError: if no alias is defined
"""
for (alias, existing_uri) in self.auth_level_aliases.items():
if auth_level_uri == existing_uri:
return alias
rais... | python | def _getAlias(self, auth_level_uri):
"""Return the alias for the specified auth level URI.
@raises KeyError: if no alias is defined
"""
for (alias, existing_uri) in self.auth_level_aliases.items():
if auth_level_uri == existing_uri:
return alias
rais... | [
"def",
"_getAlias",
"(",
"self",
",",
"auth_level_uri",
")",
":",
"for",
"(",
"alias",
",",
"existing_uri",
")",
"in",
"self",
".",
"auth_level_aliases",
".",
"items",
"(",
")",
":",
"if",
"auth_level_uri",
"==",
"existing_uri",
":",
"return",
"alias",
"ra... | Return the alias for the specified auth level URI.
@raises KeyError: if no alias is defined | [
"Return",
"the",
"alias",
"for",
"the",
"specified",
"auth",
"level",
"URI",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/draft/pape5.py#L82-L91 |
necaris/python3-openid | openid/yadis/filters.py | mkCompoundFilter | def mkCompoundFilter(parts):
"""Create a filter out of a list of filter-like things
Used by mkFilter
@param parts: list of filter, endpoint, callable or list of any of these
"""
# Separate into a list of callables and a list of filter objects
transformers = []
filters = []
for subfilte... | python | def mkCompoundFilter(parts):
"""Create a filter out of a list of filter-like things
Used by mkFilter
@param parts: list of filter, endpoint, callable or list of any of these
"""
# Separate into a list of callables and a list of filter objects
transformers = []
filters = []
for subfilte... | [
"def",
"mkCompoundFilter",
"(",
"parts",
")",
":",
"# Separate into a list of callables and a list of filter objects",
"transformers",
"=",
"[",
"]",
"filters",
"=",
"[",
"]",
"for",
"subfilter",
"in",
"parts",
":",
"try",
":",
"subfilter",
"=",
"list",
"(",
"subf... | Create a filter out of a list of filter-like things
Used by mkFilter
@param parts: list of filter, endpoint, callable or list of any of these | [
"Create",
"a",
"filter",
"out",
"of",
"a",
"list",
"of",
"filter",
"-",
"like",
"things"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/yadis/filters.py#L172-L210 |
gawel/irc3 | irc3/plugins/cron.py | cron | def cron(cronline, venusian_category='irc3.plugins.cron'):
"""main decorator"""
def wrapper(func):
def callback(context, name, ob):
obj = context.context
crons = obj.get_plugin(Crons)
if info.scope == 'class':
callback = getattr(
ob... | python | def cron(cronline, venusian_category='irc3.plugins.cron'):
"""main decorator"""
def wrapper(func):
def callback(context, name, ob):
obj = context.context
crons = obj.get_plugin(Crons)
if info.scope == 'class':
callback = getattr(
ob... | [
"def",
"cron",
"(",
"cronline",
",",
"venusian_category",
"=",
"'irc3.plugins.cron'",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"def",
"callback",
"(",
"context",
",",
"name",
",",
"ob",
")",
":",
"obj",
"=",
"context",
".",
"context",
"crons",
... | main decorator | [
"main",
"decorator"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/cron.py#L83-L98 |
marselester/flask-api-utils | api_utils/app.py | ResponsiveFlask.default_errorhandler | def default_errorhandler(self, f):
"""Decorator that registers handler of default (Werkzeug) HTTP errors.
Note that it might override already defined error handlers.
"""
for http_code in default_exceptions:
self.error_handler_spec[None][http_code] = f
return f | python | def default_errorhandler(self, f):
"""Decorator that registers handler of default (Werkzeug) HTTP errors.
Note that it might override already defined error handlers.
"""
for http_code in default_exceptions:
self.error_handler_spec[None][http_code] = f
return f | [
"def",
"default_errorhandler",
"(",
"self",
",",
"f",
")",
":",
"for",
"http_code",
"in",
"default_exceptions",
":",
"self",
".",
"error_handler_spec",
"[",
"None",
"]",
"[",
"http_code",
"]",
"=",
"f",
"return",
"f"
] | Decorator that registers handler of default (Werkzeug) HTTP errors.
Note that it might override already defined error handlers. | [
"Decorator",
"that",
"registers",
"handler",
"of",
"default",
"(",
"Werkzeug",
")",
"HTTP",
"errors",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/app.py#L46-L54 |
marselester/flask-api-utils | api_utils/app.py | ResponsiveFlask._response_mimetype_based_on_accept_header | def _response_mimetype_based_on_accept_header(self):
"""Determines mimetype to response based on Accept header.
If mimetype is not found, it returns ``None``.
"""
response_mimetype = None
if not request.accept_mimetypes:
response_mimetype = self.default_mimetype
... | python | def _response_mimetype_based_on_accept_header(self):
"""Determines mimetype to response based on Accept header.
If mimetype is not found, it returns ``None``.
"""
response_mimetype = None
if not request.accept_mimetypes:
response_mimetype = self.default_mimetype
... | [
"def",
"_response_mimetype_based_on_accept_header",
"(",
"self",
")",
":",
"response_mimetype",
"=",
"None",
"if",
"not",
"request",
".",
"accept_mimetypes",
":",
"response_mimetype",
"=",
"self",
".",
"default_mimetype",
"else",
":",
"all_media_types_wildcard",
"=",
... | Determines mimetype to response based on Accept header.
If mimetype is not found, it returns ``None``. | [
"Determines",
"mimetype",
"to",
"response",
"based",
"on",
"Accept",
"header",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/app.py#L56-L77 |
marselester/flask-api-utils | api_utils/app.py | ResponsiveFlask.make_response | def make_response(self, rv):
"""Returns response based on Accept header.
If no Accept header field is present, then it is assumed that
the client accepts all media types. This way JSON format will
be used.
If an Accept header field is present, and if the server cannot
s... | python | def make_response(self, rv):
"""Returns response based on Accept header.
If no Accept header field is present, then it is assumed that
the client accepts all media types. This way JSON format will
be used.
If an Accept header field is present, and if the server cannot
s... | [
"def",
"make_response",
"(",
"self",
",",
"rv",
")",
":",
"status",
"=",
"headers",
"=",
"None",
"if",
"isinstance",
"(",
"rv",
",",
"tuple",
")",
":",
"rv",
",",
"status",
",",
"headers",
"=",
"rv",
"+",
"(",
"None",
",",
")",
"*",
"(",
"3",
"... | Returns response based on Accept header.
If no Accept header field is present, then it is assumed that
the client accepts all media types. This way JSON format will
be used.
If an Accept header field is present, and if the server cannot
send a response which is acceptable accor... | [
"Returns",
"response",
"based",
"on",
"Accept",
"header",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/app.py#L79-L120 |
gawel/irc3 | irc3/dec.py | dcc_event | def dcc_event(regexp, callback=None, iotype='in',
venusian_category='irc3.dcc'):
"""Work like :class:`~irc3.dec.event` but occurs during DCC CHATs"""
return event(regexp, callback=callback, iotype='dcc_' + iotype,
venusian_category=venusian_category) | python | def dcc_event(regexp, callback=None, iotype='in',
venusian_category='irc3.dcc'):
"""Work like :class:`~irc3.dec.event` but occurs during DCC CHATs"""
return event(regexp, callback=callback, iotype='dcc_' + iotype,
venusian_category=venusian_category) | [
"def",
"dcc_event",
"(",
"regexp",
",",
"callback",
"=",
"None",
",",
"iotype",
"=",
"'in'",
",",
"venusian_category",
"=",
"'irc3.dcc'",
")",
":",
"return",
"event",
"(",
"regexp",
",",
"callback",
"=",
"callback",
",",
"iotype",
"=",
"'dcc_'",
"+",
"io... | Work like :class:`~irc3.dec.event` but occurs during DCC CHATs | [
"Work",
"like",
":",
"class",
":",
"~irc3",
".",
"dec",
".",
"event",
"but",
"occurs",
"during",
"DCC",
"CHATs"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dec.py#L85-L89 |
gawel/irc3 | irc3/dec.py | extend | def extend(func):
"""Allow to extend a bot:
Create a module with some useful routine:
.. literalinclude:: ../examples/myextends.py
..
>>> import sys
>>> sys.path.append('examples')
>>> from irc3 import IrcBot
>>> IrcBot.defaults.update(asynchronous=False, testing=True)
... | python | def extend(func):
"""Allow to extend a bot:
Create a module with some useful routine:
.. literalinclude:: ../examples/myextends.py
..
>>> import sys
>>> sys.path.append('examples')
>>> from irc3 import IrcBot
>>> IrcBot.defaults.update(asynchronous=False, testing=True)
... | [
"def",
"extend",
"(",
"func",
")",
":",
"def",
"callback",
"(",
"context",
",",
"name",
",",
"ob",
")",
":",
"obj",
"=",
"context",
".",
"context",
"if",
"info",
".",
"scope",
"==",
"'class'",
":",
"f",
"=",
"getattr",
"(",
"obj",
".",
"get_plugin"... | Allow to extend a bot:
Create a module with some useful routine:
.. literalinclude:: ../examples/myextends.py
..
>>> import sys
>>> sys.path.append('examples')
>>> from irc3 import IrcBot
>>> IrcBot.defaults.update(asynchronous=False, testing=True)
Now you can use thos... | [
"Allow",
"to",
"extend",
"a",
"bot",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dec.py#L92-L122 |
gawel/irc3 | irc3d/__init__.py | IrcServer.notice | def notice(self, client, message):
"""send a notice to client"""
if client and message:
messages = utils.split_message(message, self.config.max_length)
for msg in messages:
client.fwrite(':{c.srv} NOTICE {c.nick} :{msg}', msg=msg) | python | def notice(self, client, message):
"""send a notice to client"""
if client and message:
messages = utils.split_message(message, self.config.max_length)
for msg in messages:
client.fwrite(':{c.srv} NOTICE {c.nick} :{msg}', msg=msg) | [
"def",
"notice",
"(",
"self",
",",
"client",
",",
"message",
")",
":",
"if",
"client",
"and",
"message",
":",
"messages",
"=",
"utils",
".",
"split_message",
"(",
"message",
",",
"self",
".",
"config",
".",
"max_length",
")",
"for",
"msg",
"in",
"messa... | send a notice to client | [
"send",
"a",
"notice",
"to",
"client"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3d/__init__.py#L168-L173 |
marselester/flask-api-utils | api_utils/auth.py | Hawk.client_key_loader | def client_key_loader(self, f):
"""Registers a function to be called to find a client key.
Function you set has to take a client id and return a client key::
@hawk.client_key_loader
def get_client_key(client_id):
if client_id == 'Alice':
retu... | python | def client_key_loader(self, f):
"""Registers a function to be called to find a client key.
Function you set has to take a client id and return a client key::
@hawk.client_key_loader
def get_client_key(client_id):
if client_id == 'Alice':
retu... | [
"def",
"client_key_loader",
"(",
"self",
",",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapped_f",
"(",
"client_id",
")",
":",
"client_key",
"=",
"f",
"(",
"client_id",
")",
"return",
"{",
"'id'",
":",
"client_id",
",",
"'key'",
":",
"clie... | Registers a function to be called to find a client key.
Function you set has to take a client id and return a client key::
@hawk.client_key_loader
def get_client_key(client_id):
if client_id == 'Alice':
return 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w... | [
"Registers",
"a",
"function",
"to",
"be",
"called",
"to",
"find",
"a",
"client",
"key",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/auth.py#L50-L75 |
marselester/flask-api-utils | api_utils/auth.py | Hawk.auth_required | def auth_required(self, view_func):
"""Decorator that provides an access to view function for
authenticated users only.
Note that we don't run authentication when `HAWK_ENABLED` is `False`.
"""
@wraps(view_func)
def wrapped_view_func(*args, **kwargs):
if cur... | python | def auth_required(self, view_func):
"""Decorator that provides an access to view function for
authenticated users only.
Note that we don't run authentication when `HAWK_ENABLED` is `False`.
"""
@wraps(view_func)
def wrapped_view_func(*args, **kwargs):
if cur... | [
"def",
"auth_required",
"(",
"self",
",",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
")",
"def",
"wrapped_view_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"current_app",
".",
"config",
"[",
"'HAWK_ENABLED'",
"]",
":",
... | Decorator that provides an access to view function for
authenticated users only.
Note that we don't run authentication when `HAWK_ENABLED` is `False`. | [
"Decorator",
"that",
"provides",
"an",
"access",
"to",
"view",
"function",
"for",
"authenticated",
"users",
"only",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/auth.py#L77-L93 |
marselester/flask-api-utils | api_utils/auth.py | Hawk._sign_response | def _sign_response(self, response):
"""Signs a response if it's possible."""
if 'Authorization' not in request.headers:
return response
try:
mohawk_receiver = mohawk.Receiver(
credentials_map=self._client_key_loader_func,
request_header=re... | python | def _sign_response(self, response):
"""Signs a response if it's possible."""
if 'Authorization' not in request.headers:
return response
try:
mohawk_receiver = mohawk.Receiver(
credentials_map=self._client_key_loader_func,
request_header=re... | [
"def",
"_sign_response",
"(",
"self",
",",
"response",
")",
":",
"if",
"'Authorization'",
"not",
"in",
"request",
".",
"headers",
":",
"return",
"response",
"try",
":",
"mohawk_receiver",
"=",
"mohawk",
".",
"Receiver",
"(",
"credentials_map",
"=",
"self",
"... | Signs a response if it's possible. | [
"Signs",
"a",
"response",
"if",
"it",
"s",
"possible",
"."
] | train | https://github.com/marselester/flask-api-utils/blob/f633e49e883c2f4e2523941e70b2d79ff4e138dc/api_utils/auth.py#L133-L157 |
gawel/irc3 | irc3/dcc/manager.py | DCCManager.create | def create(self, name_or_class, mask, filepath=None, **kwargs):
"""Create a new DCC connection. Return an ``asyncio.Protocol``"""
if isinstance(name_or_class, type):
name = name_or_class.type
protocol = name_or_class
else:
name = name_or_class
prot... | python | def create(self, name_or_class, mask, filepath=None, **kwargs):
"""Create a new DCC connection. Return an ``asyncio.Protocol``"""
if isinstance(name_or_class, type):
name = name_or_class.type
protocol = name_or_class
else:
name = name_or_class
prot... | [
"def",
"create",
"(",
"self",
",",
"name_or_class",
",",
"mask",
",",
"filepath",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name_or_class",
",",
"type",
")",
":",
"name",
"=",
"name_or_class",
".",
"type",
"protocol",
"=... | Create a new DCC connection. Return an ``asyncio.Protocol`` | [
"Create",
"a",
"new",
"DCC",
"connection",
".",
"Return",
"an",
"asyncio",
".",
"Protocol"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dcc/manager.py#L67-L112 |
gawel/irc3 | irc3/dcc/manager.py | DCCManager.resume | def resume(self, mask, filename, port, pos):
"""Resume a DCC send"""
self.connections['send']['masks'][mask][port].offset = pos
message = 'DCC ACCEPT %s %d %d' % (filename, port, pos)
self.bot.ctcp(mask, message) | python | def resume(self, mask, filename, port, pos):
"""Resume a DCC send"""
self.connections['send']['masks'][mask][port].offset = pos
message = 'DCC ACCEPT %s %d %d' % (filename, port, pos)
self.bot.ctcp(mask, message) | [
"def",
"resume",
"(",
"self",
",",
"mask",
",",
"filename",
",",
"port",
",",
"pos",
")",
":",
"self",
".",
"connections",
"[",
"'send'",
"]",
"[",
"'masks'",
"]",
"[",
"mask",
"]",
"[",
"port",
"]",
".",
"offset",
"=",
"pos",
"message",
"=",
"'D... | Resume a DCC send | [
"Resume",
"a",
"DCC",
"send"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dcc/manager.py#L114-L118 |
gawel/irc3 | irc3/dcc/manager.py | DCCManager.is_allowed | def is_allowed(self, name_or_class, mask): # pragma: no cover
"""Return True is a new connection is allowed"""
if isinstance(name_or_class, type):
name = name_or_class.type
else:
name = name_or_class
info = self.connections[name]
limit = self.config[name ... | python | def is_allowed(self, name_or_class, mask): # pragma: no cover
"""Return True is a new connection is allowed"""
if isinstance(name_or_class, type):
name = name_or_class.type
else:
name = name_or_class
info = self.connections[name]
limit = self.config[name ... | [
"def",
"is_allowed",
"(",
"self",
",",
"name_or_class",
",",
"mask",
")",
":",
"# pragma: no cover",
"if",
"isinstance",
"(",
"name_or_class",
",",
"type",
")",
":",
"name",
"=",
"name_or_class",
".",
"type",
"else",
":",
"name",
"=",
"name_or_class",
"info"... | Return True is a new connection is allowed | [
"Return",
"True",
"is",
"a",
"new",
"connection",
"is",
"allowed"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dcc/manager.py#L120-L144 |
gawel/irc3 | irc3/utils.py | split_message | def split_message(message, max_length):
"""Split long messages"""
if len(message) > max_length:
for message in textwrap.wrap(message, max_length):
yield message
else:
yield message.rstrip(STRIPPED_CHARS) | python | def split_message(message, max_length):
"""Split long messages"""
if len(message) > max_length:
for message in textwrap.wrap(message, max_length):
yield message
else:
yield message.rstrip(STRIPPED_CHARS) | [
"def",
"split_message",
"(",
"message",
",",
"max_length",
")",
":",
"if",
"len",
"(",
"message",
")",
">",
"max_length",
":",
"for",
"message",
"in",
"textwrap",
".",
"wrap",
"(",
"message",
",",
"max_length",
")",
":",
"yield",
"message",
"else",
":",
... | Split long messages | [
"Split",
"long",
"messages"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L167-L173 |
gawel/irc3 | irc3/utils.py | parse_config | def parse_config(main_section, *filenames):
"""parse config files"""
filename = filenames[-1]
filename = os.path.abspath(filename)
here = os.path.dirname(filename)
defaults = dict(here=here, hash='#')
defaults['#'] = '#'
config = configparser.ConfigParser(
defaults, allow_no_value=F... | python | def parse_config(main_section, *filenames):
"""parse config files"""
filename = filenames[-1]
filename = os.path.abspath(filename)
here = os.path.dirname(filename)
defaults = dict(here=here, hash='#')
defaults['#'] = '#'
config = configparser.ConfigParser(
defaults, allow_no_value=F... | [
"def",
"parse_config",
"(",
"main_section",
",",
"*",
"filenames",
")",
":",
"filename",
"=",
"filenames",
"[",
"-",
"1",
"]",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"here",
"=",
"os",
".",
"path",
".",
"dirname",
"... | parse config files | [
"parse",
"config",
"files"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L190-L226 |
gawel/irc3 | irc3/utils.py | extract_config | def extract_config(config, prefix):
"""return all keys with the same prefix without the prefix"""
prefix = prefix.strip('.') + '.'
plen = len(prefix)
value = {}
for k, v in config.items():
if k.startswith(prefix):
value[k[plen:]] = v
return value | python | def extract_config(config, prefix):
"""return all keys with the same prefix without the prefix"""
prefix = prefix.strip('.') + '.'
plen = len(prefix)
value = {}
for k, v in config.items():
if k.startswith(prefix):
value[k[plen:]] = v
return value | [
"def",
"extract_config",
"(",
"config",
",",
"prefix",
")",
":",
"prefix",
"=",
"prefix",
".",
"strip",
"(",
"'.'",
")",
"+",
"'.'",
"plen",
"=",
"len",
"(",
"prefix",
")",
"value",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"config",
".",
"items... | return all keys with the same prefix without the prefix | [
"return",
"all",
"keys",
"with",
"the",
"same",
"prefix",
"without",
"the",
"prefix"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L229-L237 |
gawel/irc3 | irc3/utils.py | as_list | def as_list(value):
"""clever string spliting:
.. code-block:: python
>>> print(as_list('value'))
['value']
>>> print(as_list('v1 v2'))
['v1', 'v2']
>>> print(as_list(None))
[]
>>> print(as_list(['v1']))
['v1']
"""
if isinstance(value, (l... | python | def as_list(value):
"""clever string spliting:
.. code-block:: python
>>> print(as_list('value'))
['value']
>>> print(as_list('v1 v2'))
['v1', 'v2']
>>> print(as_list(None))
[]
>>> print(as_list(['v1']))
['v1']
"""
if isinstance(value, (l... | [
"def",
"as_list",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"value",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"for",
"c",
"in",
"'\\n '",
":",
"if",
"c",
"in",
"value"... | clever string spliting:
.. code-block:: python
>>> print(as_list('value'))
['value']
>>> print(as_list('v1 v2'))
['v1', 'v2']
>>> print(as_list(None))
[]
>>> print(as_list(['v1']))
['v1'] | [
"clever",
"string",
"spliting",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L240-L262 |
gawel/irc3 | irc3/utils.py | parse_modes | def parse_modes(modes, targets=None, noargs=''):
"""Parse channel modes:
.. code-block:: python
>>> parse_modes('+c-n', noargs='cn')
[('+', 'c', None), ('-', 'n', None)]
>>> parse_modes('+c-v', ['gawel'], noargs='c')
[('+', 'c', None), ('-', 'v', 'gawel')]
"""
if not ta... | python | def parse_modes(modes, targets=None, noargs=''):
"""Parse channel modes:
.. code-block:: python
>>> parse_modes('+c-n', noargs='cn')
[('+', 'c', None), ('-', 'n', None)]
>>> parse_modes('+c-v', ['gawel'], noargs='c')
[('+', 'c', None), ('-', 'v', 'gawel')]
"""
if not ta... | [
"def",
"parse_modes",
"(",
"modes",
",",
"targets",
"=",
"None",
",",
"noargs",
"=",
"''",
")",
":",
"if",
"not",
"targets",
":",
"targets",
"=",
"[",
"]",
"cleaned",
"=",
"[",
"]",
"for",
"mode",
"in",
"modes",
":",
"if",
"mode",
"in",
"'-+'",
"... | Parse channel modes:
.. code-block:: python
>>> parse_modes('+c-n', noargs='cn')
[('+', 'c', None), ('-', 'n', None)]
>>> parse_modes('+c-v', ['gawel'], noargs='c')
[('+', 'c', None), ('-', 'v', 'gawel')] | [
"Parse",
"channel",
"modes",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L282-L301 |
gawel/irc3 | irc3/utils.py | wraps_with_context | def wraps_with_context(func, context):
"""Return a wrapped partial(func, context)"""
wrapped = functools.partial(func, context)
wrapped = functools.wraps(func)(wrapped)
if asyncio.iscoroutinefunction(func):
wrapped = asyncio.coroutine(wrapped)
return wrapped | python | def wraps_with_context(func, context):
"""Return a wrapped partial(func, context)"""
wrapped = functools.partial(func, context)
wrapped = functools.wraps(func)(wrapped)
if asyncio.iscoroutinefunction(func):
wrapped = asyncio.coroutine(wrapped)
return wrapped | [
"def",
"wraps_with_context",
"(",
"func",
",",
"context",
")",
":",
"wrapped",
"=",
"functools",
".",
"partial",
"(",
"func",
",",
"context",
")",
"wrapped",
"=",
"functools",
".",
"wraps",
"(",
"func",
")",
"(",
"wrapped",
")",
"if",
"asyncio",
".",
"... | Return a wrapped partial(func, context) | [
"Return",
"a",
"wrapped",
"partial",
"(",
"func",
"context",
")"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L304-L310 |
gawel/irc3 | irc3/utils.py | maybedotted | def maybedotted(name):
"""Resolve dotted names:
.. code-block:: python
>>> maybedotted('irc3.config')
<module 'irc3.config' from '...'>
>>> maybedotted('irc3.utils.IrcString')
<class 'irc3.utils.IrcString'>
..
"""
if not name:
raise LookupError(
... | python | def maybedotted(name):
"""Resolve dotted names:
.. code-block:: python
>>> maybedotted('irc3.config')
<module 'irc3.config' from '...'>
>>> maybedotted('irc3.utils.IrcString')
<class 'irc3.utils.IrcString'>
..
"""
if not name:
raise LookupError(
... | [
"def",
"maybedotted",
"(",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"LookupError",
"(",
"'Not able to resolve %s'",
"%",
"name",
")",
"if",
"not",
"hasattr",
"(",
"name",
",",
"'__name__'",
")",
":",
"try",
":",
"mod",
"=",
"importlib",
".",
... | Resolve dotted names:
.. code-block:: python
>>> maybedotted('irc3.config')
<module 'irc3.config' from '...'>
>>> maybedotted('irc3.utils.IrcString')
<class 'irc3.utils.IrcString'>
.. | [
"Resolve",
"dotted",
"names",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L313-L348 |
gawel/irc3 | irc3/utils.py | IrcString.nick | def nick(self):
"""return nick name:
.. code-block:: py
>>> print(IrcString('foo').nick)
foo
>>> print(IrcString('foo!user@host').nick)
foo
>>> IrcString('#foo').nick is None
True
>>> IrcString('irc.freenode.net').nick... | python | def nick(self):
"""return nick name:
.. code-block:: py
>>> print(IrcString('foo').nick)
foo
>>> print(IrcString('foo!user@host').nick)
foo
>>> IrcString('#foo').nick is None
True
>>> IrcString('irc.freenode.net').nick... | [
"def",
"nick",
"(",
"self",
")",
":",
"if",
"'!'",
"in",
"self",
":",
"return",
"self",
".",
"split",
"(",
"'!'",
",",
"1",
")",
"[",
"0",
"]",
"if",
"not",
"self",
".",
"is_channel",
"and",
"not",
"self",
".",
"is_server",
":",
"return",
"self"
... | return nick name:
.. code-block:: py
>>> print(IrcString('foo').nick)
foo
>>> print(IrcString('foo!user@host').nick)
foo
>>> IrcString('#foo').nick is None
True
>>> IrcString('irc.freenode.net').nick is None
True | [
"return",
"nick",
"name",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L34-L51 |
gawel/irc3 | irc3/utils.py | IrcString.tagdict | def tagdict(self):
"""return a dict converted from this string interpreted as a tag-string
.. code-block:: py
>>> from pprint import pprint
>>> dict_ = IrcString('aaa=bbb;ccc;example.com/ddd=eee').tagdict
>>> pprint({str(k): str(v) for k, v in dict_.items()})
... | python | def tagdict(self):
"""return a dict converted from this string interpreted as a tag-string
.. code-block:: py
>>> from pprint import pprint
>>> dict_ = IrcString('aaa=bbb;ccc;example.com/ddd=eee').tagdict
>>> pprint({str(k): str(v) for k, v in dict_.items()})
... | [
"def",
"tagdict",
"(",
"self",
")",
":",
"tagdict",
"=",
"getattr",
"(",
"self",
",",
"'_tagdict'",
",",
"None",
")",
"if",
"tagdict",
"is",
"None",
":",
"try",
":",
"self",
".",
"_tagdict",
"=",
"tags",
".",
"decode",
"(",
"self",
")",
"except",
"... | return a dict converted from this string interpreted as a tag-string
.. code-block:: py
>>> from pprint import pprint
>>> dict_ = IrcString('aaa=bbb;ccc;example.com/ddd=eee').tagdict
>>> pprint({str(k): str(v) for k, v in dict_.items()})
{'aaa': 'bbb', 'ccc': 'N... | [
"return",
"a",
"dict",
"converted",
"from",
"this",
"string",
"interpreted",
"as",
"a",
"tag",
"-",
"string"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L145-L161 |
gawel/irc3 | irc3/utils.py | Logger.set_irc_targets | def set_irc_targets(self, bot, *targets):
"""Add a irc Handler using bot and log to targets (can be nicks or
channels:
..
>>> bot = None
.. code-block:: python
>>> log = logging.getLogger('irc.mymodule')
>>> log.set_irc_targets(bot, '#chan', 'admin'... | python | def set_irc_targets(self, bot, *targets):
"""Add a irc Handler using bot and log to targets (can be nicks or
channels:
..
>>> bot = None
.. code-block:: python
>>> log = logging.getLogger('irc.mymodule')
>>> log.set_irc_targets(bot, '#chan', 'admin'... | [
"def",
"set_irc_targets",
"(",
"self",
",",
"bot",
",",
"*",
"targets",
")",
":",
"# get formatter initialized by config (usualy on a NullHandler)",
"ll",
"=",
"logging",
".",
"getLogger",
"(",
"'irc'",
")",
"formatter",
"=",
"ll",
".",
"handlers",
"[",
"0",
"]"... | Add a irc Handler using bot and log to targets (can be nicks or
channels:
..
>>> bot = None
.. code-block:: python
>>> log = logging.getLogger('irc.mymodule')
>>> log.set_irc_targets(bot, '#chan', 'admin') | [
"Add",
"a",
"irc",
"Handler",
"using",
"bot",
"and",
"log",
"to",
"targets",
"(",
"can",
"be",
"nicks",
"or",
"channels",
":"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/utils.py#L370-L388 |
gawel/irc3 | irc3/__init__.py | IrcBot.send_line | def send_line(self, data, nowait=False):
"""send a line to the server. replace CR by spaces"""
data = data.replace('\n', ' ').replace('\r', ' ')
f = asyncio.Future(loop=self.loop)
if self.queue is not None and nowait is False:
self.queue.put_nowait((f, data))
else:
... | python | def send_line(self, data, nowait=False):
"""send a line to the server. replace CR by spaces"""
data = data.replace('\n', ' ').replace('\r', ' ')
f = asyncio.Future(loop=self.loop)
if self.queue is not None and nowait is False:
self.queue.put_nowait((f, data))
else:
... | [
"def",
"send_line",
"(",
"self",
",",
"data",
",",
"nowait",
"=",
"False",
")",
":",
"data",
"=",
"data",
".",
"replace",
"(",
"'\\n'",
",",
"' '",
")",
".",
"replace",
"(",
"'\\r'",
",",
"' '",
")",
"f",
"=",
"asyncio",
".",
"Future",
"(",
"loop... | send a line to the server. replace CR by spaces | [
"send",
"a",
"line",
"to",
"the",
"server",
".",
"replace",
"CR",
"by",
"spaces"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L180-L189 |
gawel/irc3 | irc3/__init__.py | IrcBot.privmsg | def privmsg(self, target, message, nowait=False):
"""send a privmsg to target"""
if message:
messages = utils.split_message(message, self.config.max_length)
if isinstance(target, DCCChat):
for message in messages:
target.send_line(message)
... | python | def privmsg(self, target, message, nowait=False):
"""send a privmsg to target"""
if message:
messages = utils.split_message(message, self.config.max_length)
if isinstance(target, DCCChat):
for message in messages:
target.send_line(message)
... | [
"def",
"privmsg",
"(",
"self",
",",
"target",
",",
"message",
",",
"nowait",
"=",
"False",
")",
":",
"if",
"message",
":",
"messages",
"=",
"utils",
".",
"split_message",
"(",
"message",
",",
"self",
".",
"config",
".",
"max_length",
")",
"if",
"isinst... | send a privmsg to target | [
"send",
"a",
"privmsg",
"to",
"target"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L226-L238 |
gawel/irc3 | irc3/__init__.py | IrcBot.ctcp | def ctcp(self, target, message, nowait=False):
"""send a ctcp to target"""
if target and message:
messages = utils.split_message(message, self.config.max_length)
f = None
for message in messages:
f = self.send_line('PRIVMSG %s :\x01%s\x01' % (target,
... | python | def ctcp(self, target, message, nowait=False):
"""send a ctcp to target"""
if target and message:
messages = utils.split_message(message, self.config.max_length)
f = None
for message in messages:
f = self.send_line('PRIVMSG %s :\x01%s\x01' % (target,
... | [
"def",
"ctcp",
"(",
"self",
",",
"target",
",",
"message",
",",
"nowait",
"=",
"False",
")",
":",
"if",
"target",
"and",
"message",
":",
"messages",
"=",
"utils",
".",
"split_message",
"(",
"message",
",",
"self",
".",
"config",
".",
"max_length",
")",... | send a ctcp to target | [
"send",
"a",
"ctcp",
"to",
"target"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L258-L267 |
gawel/irc3 | irc3/__init__.py | IrcBot.mode | def mode(self, target, *data):
"""set user or channel mode"""
self.send_line('MODE %s %s' % (target, ' '.join(data)), nowait=True) | python | def mode(self, target, *data):
"""set user or channel mode"""
self.send_line('MODE %s %s' % (target, ' '.join(data)), nowait=True) | [
"def",
"mode",
"(",
"self",
",",
"target",
",",
"*",
"data",
")",
":",
"self",
".",
"send_line",
"(",
"'MODE %s %s'",
"%",
"(",
"target",
",",
"' '",
".",
"join",
"(",
"data",
")",
")",
",",
"nowait",
"=",
"True",
")"
] | set user or channel mode | [
"set",
"user",
"or",
"channel",
"mode"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L279-L281 |
gawel/irc3 | irc3/__init__.py | IrcBot.join | def join(self, target):
"""join a channel"""
password = self.config.passwords.get(
target.strip(self.server_config['CHANTYPES']))
if password:
target += ' ' + password
self.send_line('JOIN %s' % target) | python | def join(self, target):
"""join a channel"""
password = self.config.passwords.get(
target.strip(self.server_config['CHANTYPES']))
if password:
target += ' ' + password
self.send_line('JOIN %s' % target) | [
"def",
"join",
"(",
"self",
",",
"target",
")",
":",
"password",
"=",
"self",
".",
"config",
".",
"passwords",
".",
"get",
"(",
"target",
".",
"strip",
"(",
"self",
".",
"server_config",
"[",
"'CHANTYPES'",
"]",
")",
")",
"if",
"password",
":",
"targ... | join a channel | [
"join",
"a",
"channel"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L283-L289 |
gawel/irc3 | irc3/__init__.py | IrcBot.part | def part(self, target, reason=None):
"""quit a channel"""
if reason:
target += ' :' + reason
self.send_line('PART %s' % target) | python | def part(self, target, reason=None):
"""quit a channel"""
if reason:
target += ' :' + reason
self.send_line('PART %s' % target) | [
"def",
"part",
"(",
"self",
",",
"target",
",",
"reason",
"=",
"None",
")",
":",
"if",
"reason",
":",
"target",
"+=",
"' :'",
"+",
"reason",
"self",
".",
"send_line",
"(",
"'PART %s'",
"%",
"target",
")"
] | quit a channel | [
"quit",
"a",
"channel"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L291-L295 |
gawel/irc3 | irc3/__init__.py | IrcBot.kick | def kick(self, channel, target, reason=None):
"""kick target from channel"""
if reason:
target += ' :' + reason
self.send_line('KICK %s %s' % (channel, target), nowait=True) | python | def kick(self, channel, target, reason=None):
"""kick target from channel"""
if reason:
target += ' :' + reason
self.send_line('KICK %s %s' % (channel, target), nowait=True) | [
"def",
"kick",
"(",
"self",
",",
"channel",
",",
"target",
",",
"reason",
"=",
"None",
")",
":",
"if",
"reason",
":",
"target",
"+=",
"' :'",
"+",
"reason",
"self",
".",
"send_line",
"(",
"'KICK %s %s'",
"%",
"(",
"channel",
",",
"target",
")",
",",
... | kick target from channel | [
"kick",
"target",
"from",
"channel"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L297-L301 |
gawel/irc3 | irc3/__init__.py | IrcBot.topic | def topic(self, channel, topic=None):
"""change or request the topic of a channel"""
if topic:
channel += ' :' + topic
self.send_line('TOPIC %s' % channel) | python | def topic(self, channel, topic=None):
"""change or request the topic of a channel"""
if topic:
channel += ' :' + topic
self.send_line('TOPIC %s' % channel) | [
"def",
"topic",
"(",
"self",
",",
"channel",
",",
"topic",
"=",
"None",
")",
":",
"if",
"topic",
":",
"channel",
"+=",
"' :'",
"+",
"topic",
"self",
".",
"send_line",
"(",
"'TOPIC %s'",
"%",
"channel",
")"
] | change or request the topic of a channel | [
"change",
"or",
"request",
"the",
"topic",
"of",
"a",
"channel"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L307-L311 |
gawel/irc3 | irc3/__init__.py | IrcBot.away | def away(self, message=None):
"""mark ourself as away"""
cmd = 'AWAY'
if message:
cmd += ' :' + message
self.send_line(cmd) | python | def away(self, message=None):
"""mark ourself as away"""
cmd = 'AWAY'
if message:
cmd += ' :' + message
self.send_line(cmd) | [
"def",
"away",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"cmd",
"=",
"'AWAY'",
"if",
"message",
":",
"cmd",
"+=",
"' :'",
"+",
"message",
"self",
".",
"send_line",
"(",
"cmd",
")"
] | mark ourself as away | [
"mark",
"ourself",
"as",
"away"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L313-L318 |
gawel/irc3 | irc3/__init__.py | IrcBot.quit | def quit(self, reason=None):
"""disconnect"""
if not reason:
reason = 'bye'
else:
reason = reason
self.send_line('QUIT :%s' % reason) | python | def quit(self, reason=None):
"""disconnect"""
if not reason:
reason = 'bye'
else:
reason = reason
self.send_line('QUIT :%s' % reason) | [
"def",
"quit",
"(",
"self",
",",
"reason",
"=",
"None",
")",
":",
"if",
"not",
"reason",
":",
"reason",
"=",
"'bye'",
"else",
":",
"reason",
"=",
"reason",
"self",
".",
"send_line",
"(",
"'QUIT :%s'",
"%",
"reason",
")"
] | disconnect | [
"disconnect"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L324-L330 |
gawel/irc3 | irc3/__init__.py | IrcBot.ip | def ip(self):
"""return bot's ip as an ``ip_address`` object"""
if not self._ip:
if 'ip' in self.config:
ip = self.config['ip']
else:
ip = self.protocol.transport.get_extra_info('sockname')[0]
ip = ip_address(ip)
if ip.versi... | python | def ip(self):
"""return bot's ip as an ``ip_address`` object"""
if not self._ip:
if 'ip' in self.config:
ip = self.config['ip']
else:
ip = self.protocol.transport.get_extra_info('sockname')[0]
ip = ip_address(ip)
if ip.versi... | [
"def",
"ip",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_ip",
":",
"if",
"'ip'",
"in",
"self",
".",
"config",
":",
"ip",
"=",
"self",
".",
"config",
"[",
"'ip'",
"]",
"else",
":",
"ip",
"=",
"self",
".",
"protocol",
".",
"transport",
"."... | return bot's ip as an ``ip_address`` object | [
"return",
"bot",
"s",
"ip",
"as",
"an",
"ip_address",
"object"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L341-L356 |
gawel/irc3 | irc3/__init__.py | IrcBot.dcc | def dcc(self):
"""return the :class:`~irc3.dcc.DCCManager`"""
if self._dcc is None:
self._dcc = DCCManager(self)
return self._dcc | python | def dcc(self):
"""return the :class:`~irc3.dcc.DCCManager`"""
if self._dcc is None:
self._dcc = DCCManager(self)
return self._dcc | [
"def",
"dcc",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dcc",
"is",
"None",
":",
"self",
".",
"_dcc",
"=",
"DCCManager",
"(",
"self",
")",
"return",
"self",
".",
"_dcc"
] | return the :class:`~irc3.dcc.DCCManager` | [
"return",
"the",
":",
"class",
":",
"~irc3",
".",
"dcc",
".",
"DCCManager"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L359-L363 |
gawel/irc3 | irc3/__init__.py | IrcBot.dcc_chat | def dcc_chat(self, mask, host=None, port=None):
"""Open a DCC CHAT whith mask. If host/port are specified then connect
to a server. Else create a server"""
return self.dcc.create(
'chat', mask, host=host, port=port).ready | python | def dcc_chat(self, mask, host=None, port=None):
"""Open a DCC CHAT whith mask. If host/port are specified then connect
to a server. Else create a server"""
return self.dcc.create(
'chat', mask, host=host, port=port).ready | [
"def",
"dcc_chat",
"(",
"self",
",",
"mask",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
")",
":",
"return",
"self",
".",
"dcc",
".",
"create",
"(",
"'chat'",
",",
"mask",
",",
"host",
"=",
"host",
",",
"port",
"=",
"port",
")",
".",
"r... | Open a DCC CHAT whith mask. If host/port are specified then connect
to a server. Else create a server | [
"Open",
"a",
"DCC",
"CHAT",
"whith",
"mask",
".",
"If",
"host",
"/",
"port",
"are",
"specified",
"then",
"connect",
"to",
"a",
"server",
".",
"Else",
"create",
"a",
"server"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L366-L370 |
gawel/irc3 | irc3/__init__.py | IrcBot.dcc_get | def dcc_get(self, mask, host, port, filepath, filesize=None):
"""DCC GET a file from mask. filepath must be an absolute path with an
existing directory. filesize is the expected file size."""
return self.dcc.create(
'get', mask, filepath=filepath, filesize=filesize,
host=... | python | def dcc_get(self, mask, host, port, filepath, filesize=None):
"""DCC GET a file from mask. filepath must be an absolute path with an
existing directory. filesize is the expected file size."""
return self.dcc.create(
'get', mask, filepath=filepath, filesize=filesize,
host=... | [
"def",
"dcc_get",
"(",
"self",
",",
"mask",
",",
"host",
",",
"port",
",",
"filepath",
",",
"filesize",
"=",
"None",
")",
":",
"return",
"self",
".",
"dcc",
".",
"create",
"(",
"'get'",
",",
"mask",
",",
"filepath",
"=",
"filepath",
",",
"filesize",
... | DCC GET a file from mask. filepath must be an absolute path with an
existing directory. filesize is the expected file size. | [
"DCC",
"GET",
"a",
"file",
"from",
"mask",
".",
"filepath",
"must",
"be",
"an",
"absolute",
"path",
"with",
"an",
"existing",
"directory",
".",
"filesize",
"is",
"the",
"expected",
"file",
"size",
"."
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L373-L378 |
gawel/irc3 | irc3/__init__.py | IrcBot.dcc_send | def dcc_send(self, mask, filepath):
"""DCC SEND a file to mask. filepath must be an absolute path to
existing file"""
return self.dcc.create('send', mask, filepath=filepath).ready | python | def dcc_send(self, mask, filepath):
"""DCC SEND a file to mask. filepath must be an absolute path to
existing file"""
return self.dcc.create('send', mask, filepath=filepath).ready | [
"def",
"dcc_send",
"(",
"self",
",",
"mask",
",",
"filepath",
")",
":",
"return",
"self",
".",
"dcc",
".",
"create",
"(",
"'send'",
",",
"mask",
",",
"filepath",
"=",
"filepath",
")",
".",
"ready"
] | DCC SEND a file to mask. filepath must be an absolute path to
existing file | [
"DCC",
"SEND",
"a",
"file",
"to",
"mask",
".",
"filepath",
"must",
"be",
"an",
"absolute",
"path",
"to",
"existing",
"file"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L381-L384 |
gawel/irc3 | irc3/__init__.py | IrcBot.dcc_accept | def dcc_accept(self, mask, filepath, port, pos):
"""accept a DCC RESUME for an axisting DCC SEND. filepath is the
filename to sent. port is the port opened on the server.
pos is the expected offset"""
return self.dcc.resume(mask, filepath, port, pos) | python | def dcc_accept(self, mask, filepath, port, pos):
"""accept a DCC RESUME for an axisting DCC SEND. filepath is the
filename to sent. port is the port opened on the server.
pos is the expected offset"""
return self.dcc.resume(mask, filepath, port, pos) | [
"def",
"dcc_accept",
"(",
"self",
",",
"mask",
",",
"filepath",
",",
"port",
",",
"pos",
")",
":",
"return",
"self",
".",
"dcc",
".",
"resume",
"(",
"mask",
",",
"filepath",
",",
"port",
",",
"pos",
")"
] | accept a DCC RESUME for an axisting DCC SEND. filepath is the
filename to sent. port is the port opened on the server.
pos is the expected offset | [
"accept",
"a",
"DCC",
"RESUME",
"for",
"an",
"axisting",
"DCC",
"SEND",
".",
"filepath",
"is",
"the",
"filename",
"to",
"sent",
".",
"port",
"is",
"the",
"port",
"opened",
"on",
"the",
"server",
".",
"pos",
"is",
"the",
"expected",
"offset"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/__init__.py#L387-L391 |
gawel/irc3 | irc3/tags.py | encode | def encode(tags):
'''Encodes a dictionary of tags to fit into an IRC-message.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from collections import OrderedDict
>>> encode({'key': 'value'})
'key=value'
>>> d = {'aaa': 'bbb', 'ccc': None, 'example.com/ddd': 'eee'}
... | python | def encode(tags):
'''Encodes a dictionary of tags to fit into an IRC-message.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from collections import OrderedDict
>>> encode({'key': 'value'})
'key=value'
>>> d = {'aaa': 'bbb', 'ccc': None, 'example.com/ddd': 'eee'}
... | [
"def",
"encode",
"(",
"tags",
")",
":",
"tagstrings",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"tags",
".",
"items",
"(",
")",
":",
"if",
"not",
"_valid_key",
".",
"match",
"(",
"key",
")",
":",
"raise",
"ValueError",
"(",
"\"dictionary key i... | Encodes a dictionary of tags to fit into an IRC-message.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from collections import OrderedDict
>>> encode({'key': 'value'})
'key=value'
>>> d = {'aaa': 'bbb', 'ccc': None, 'example.com/ddd': 'eee'}
>>> d_ordered = Ordere... | [
"Encodes",
"a",
"dictionary",
"of",
"tags",
"to",
"fit",
"into",
"an",
"IRC",
"-",
"message",
".",
"See",
"IRC",
"Message",
"Tags",
":",
"http",
":",
"//",
"ircv3",
".",
"net",
"/",
"specs",
"/",
"core",
"/",
"message",
"-",
"tags",
"-",
"3",
".",
... | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/tags.py#L53-L84 |
gawel/irc3 | irc3/tags.py | decode | def decode(tagstring):
'''Decodes a tag-string from an IRC-message into a python dictionary.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from pprint import pprint
>>> pprint(decode('key=value'))
{'key': 'value'}
>>> pprint(decode('aaa=bbb;ccc;example.com/ddd=eee... | python | def decode(tagstring):
'''Decodes a tag-string from an IRC-message into a python dictionary.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from pprint import pprint
>>> pprint(decode('key=value'))
{'key': 'value'}
>>> pprint(decode('aaa=bbb;ccc;example.com/ddd=eee... | [
"def",
"decode",
"(",
"tagstring",
")",
":",
"if",
"not",
"tagstring",
":",
"# None/empty = no tags",
"return",
"{",
"}",
"tags",
"=",
"{",
"}",
"for",
"tag",
"in",
"tagstring",
".",
"split",
"(",
"\";\"",
")",
":",
"# value is either everything after \"=\", o... | Decodes a tag-string from an IRC-message into a python dictionary.
See IRC Message Tags: http://ircv3.net/specs/core/message-tags-3.2.html
>>> from pprint import pprint
>>> pprint(decode('key=value'))
{'key': 'value'}
>>> pprint(decode('aaa=bbb;ccc;example.com/ddd=eee'))
{'aaa': 'bbb', 'ccc': ... | [
"Decodes",
"a",
"tag",
"-",
"string",
"from",
"an",
"IRC",
"-",
"message",
"into",
"a",
"python",
"dictionary",
".",
"See",
"IRC",
"Message",
"Tags",
":",
"http",
":",
"//",
"ircv3",
".",
"net",
"/",
"specs",
"/",
"core",
"/",
"message",
"-",
"tags",... | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/tags.py#L87-L125 |
gawel/irc3 | irc3/plugins/quakenet.py | challenge_auth | def challenge_auth(username, password, challenge, lower, digest='sha256'):
"""Calculates quakenet's challenge auth hash
.. code-block:: python
>>> challenge_auth("mooking", "0000000000",
... "12345678901234567890123456789012", str.lower, "md5")
'2ed1a1f1d2cd5487d2e18f27213286b9'
... | python | def challenge_auth(username, password, challenge, lower, digest='sha256'):
"""Calculates quakenet's challenge auth hash
.. code-block:: python
>>> challenge_auth("mooking", "0000000000",
... "12345678901234567890123456789012", str.lower, "md5")
'2ed1a1f1d2cd5487d2e18f27213286b9'
... | [
"def",
"challenge_auth",
"(",
"username",
",",
"password",
",",
"challenge",
",",
"lower",
",",
"digest",
"=",
"'sha256'",
")",
":",
"def",
"hdig",
"(",
"x",
")",
":",
"return",
"fdigest",
"(",
"x",
")",
".",
"hexdigest",
"(",
")",
"fdigest",
"=",
"g... | Calculates quakenet's challenge auth hash
.. code-block:: python
>>> challenge_auth("mooking", "0000000000",
... "12345678901234567890123456789012", str.lower, "md5")
'2ed1a1f1d2cd5487d2e18f27213286b9' | [
"Calculates",
"quakenet",
"s",
"challenge",
"auth",
"hash"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/quakenet.py#L54-L72 |
gawel/irc3 | examples/freenode_irc3.py | auto_retweet | def auto_retweet(bot):
"""retweet author tweets about irc3 and pypi releases"""
conn = bot.get_social_connection(id='twitter')
dirname = os.path.expanduser('~/.irc3/twitter/{nick}'.format(**bot.config))
if not os.path.isdir(dirname):
os.makedirs(dirname)
filename = os.path.join(dirname, 'r... | python | def auto_retweet(bot):
"""retweet author tweets about irc3 and pypi releases"""
conn = bot.get_social_connection(id='twitter')
dirname = os.path.expanduser('~/.irc3/twitter/{nick}'.format(**bot.config))
if not os.path.isdir(dirname):
os.makedirs(dirname)
filename = os.path.join(dirname, 'r... | [
"def",
"auto_retweet",
"(",
"bot",
")",
":",
"conn",
"=",
"bot",
".",
"get_social_connection",
"(",
"id",
"=",
"'twitter'",
")",
"dirname",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.irc3/twitter/{nick}'",
".",
"format",
"(",
"*",
"*",
"bot",
"... | retweet author tweets about irc3 and pypi releases | [
"retweet",
"author",
"tweets",
"about",
"irc3",
"and",
"pypi",
"releases"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/examples/freenode_irc3.py#L57-L82 |
gawel/irc3 | examples/freenode_irc3.py | FeedsHook.filter_travis | def filter_travis(self, entry):
"""Only show the latest entry iif this entry is in a new state"""
fstate = entry.filename + '.state'
if os.path.isfile(fstate):
with open(fstate) as fd:
state = fd.read().strip()
else:
state = None
if 'failed... | python | def filter_travis(self, entry):
"""Only show the latest entry iif this entry is in a new state"""
fstate = entry.filename + '.state'
if os.path.isfile(fstate):
with open(fstate) as fd:
state = fd.read().strip()
else:
state = None
if 'failed... | [
"def",
"filter_travis",
"(",
"self",
",",
"entry",
")",
":",
"fstate",
"=",
"entry",
".",
"filename",
"+",
"'.state'",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"fstate",
")",
":",
"with",
"open",
"(",
"fstate",
")",
"as",
"fd",
":",
"state",
"=... | Only show the latest entry iif this entry is in a new state | [
"Only",
"show",
"the",
"latest",
"entry",
"iif",
"this",
"entry",
"is",
"in",
"a",
"new",
"state"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/examples/freenode_irc3.py#L17-L34 |
gawel/irc3 | examples/freenode_irc3.py | FeedsHook.filter_pypi | def filter_pypi(self, entry):
"""Show only usefull packages"""
for package in self.packages:
if entry.title.lower().startswith(package):
return entry | python | def filter_pypi(self, entry):
"""Show only usefull packages"""
for package in self.packages:
if entry.title.lower().startswith(package):
return entry | [
"def",
"filter_pypi",
"(",
"self",
",",
"entry",
")",
":",
"for",
"package",
"in",
"self",
".",
"packages",
":",
"if",
"entry",
".",
"title",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"package",
")",
":",
"return",
"entry"
] | Show only usefull packages | [
"Show",
"only",
"usefull",
"packages"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/examples/freenode_irc3.py#L36-L40 |
gawel/irc3 | irc3/plugins/async.py | Whois.process_results | def process_results(self, results=None, **value):
"""take results list of all events and put them in a dict"""
channels = []
for res in results:
channels.extend(res.pop('channels', '').split())
value.update(res)
value['channels'] = channels
value['success'... | python | def process_results(self, results=None, **value):
"""take results list of all events and put them in a dict"""
channels = []
for res in results:
channels.extend(res.pop('channels', '').split())
value.update(res)
value['channels'] = channels
value['success'... | [
"def",
"process_results",
"(",
"self",
",",
"results",
"=",
"None",
",",
"*",
"*",
"value",
")",
":",
"channels",
"=",
"[",
"]",
"for",
"res",
"in",
"results",
":",
"channels",
".",
"extend",
"(",
"res",
".",
"pop",
"(",
"'channels'",
",",
"''",
")... | take results list of all events and put them in a dict | [
"take",
"results",
"list",
"of",
"all",
"events",
"and",
"put",
"them",
"in",
"a",
"dict"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/async.py#L92-L100 |
gawel/irc3 | irc3/plugins/async.py | CTCP.process_results | def process_results(self, results=None, **value):
"""take results list of all events and return first dict"""
for res in results:
if 'mask' in res:
res['mask'] = utils.IrcString(res['mask'])
value['success'] = res.pop('retcode', None) != '486'
value.up... | python | def process_results(self, results=None, **value):
"""take results list of all events and return first dict"""
for res in results:
if 'mask' in res:
res['mask'] = utils.IrcString(res['mask'])
value['success'] = res.pop('retcode', None) != '486'
value.up... | [
"def",
"process_results",
"(",
"self",
",",
"results",
"=",
"None",
",",
"*",
"*",
"value",
")",
":",
"for",
"res",
"in",
"results",
":",
"if",
"'mask'",
"in",
"res",
":",
"res",
"[",
"'mask'",
"]",
"=",
"utils",
".",
"IrcString",
"(",
"res",
"[",
... | take results list of all events and return first dict | [
"take",
"results",
"list",
"of",
"all",
"events",
"and",
"return",
"first",
"dict"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/async.py#L277-L284 |
gawel/irc3 | irc3/plugins/command.py | ping | def ping(bot, mask, target, args):
"""ping/pong
%%ping
"""
bot.send('NOTICE %(nick)s :PONG %(nick)s!' % dict(nick=mask.nick)) | python | def ping(bot, mask, target, args):
"""ping/pong
%%ping
"""
bot.send('NOTICE %(nick)s :PONG %(nick)s!' % dict(nick=mask.nick)) | [
"def",
"ping",
"(",
"bot",
",",
"mask",
",",
"target",
",",
"args",
")",
":",
"bot",
".",
"send",
"(",
"'NOTICE %(nick)s :PONG %(nick)s!'",
"%",
"dict",
"(",
"nick",
"=",
"mask",
".",
"nick",
")",
")"
] | ping/pong
%%ping | [
"ping",
"/",
"pong"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/command.py#L453-L458 |
gawel/irc3 | irc3/plugins/command.py | quote | def quote(bot, mask, target, args):
"""send quote to the server
%%quote <args>...
"""
msg = ' '.join(args['<args>'])
bot.log.info('quote> %r', msg)
bot.send(msg) | python | def quote(bot, mask, target, args):
"""send quote to the server
%%quote <args>...
"""
msg = ' '.join(args['<args>'])
bot.log.info('quote> %r', msg)
bot.send(msg) | [
"def",
"quote",
"(",
"bot",
",",
"mask",
",",
"target",
",",
"args",
")",
":",
"msg",
"=",
"' '",
".",
"join",
"(",
"args",
"[",
"'<args>'",
"]",
")",
"bot",
".",
"log",
".",
"info",
"(",
"'quote> %r'",
",",
"msg",
")",
"bot",
".",
"send",
"(",... | send quote to the server
%%quote <args>... | [
"send",
"quote",
"to",
"the",
"server"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/command.py#L462-L469 |
gawel/irc3 | irc3/plugins/command.py | reconnect | def reconnect(bot, mask, target, args):
"""force reconnect
%%reconnect
"""
plugin = bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
bot.loop.call_soon(plugin.reconnect) | python | def reconnect(bot, mask, target, args):
"""force reconnect
%%reconnect
"""
plugin = bot.get_plugin(utils.maybedotted('irc3.plugins.core.Core'))
bot.loop.call_soon(plugin.reconnect) | [
"def",
"reconnect",
"(",
"bot",
",",
"mask",
",",
"target",
",",
"args",
")",
":",
"plugin",
"=",
"bot",
".",
"get_plugin",
"(",
"utils",
".",
"maybedotted",
"(",
"'irc3.plugins.core.Core'",
")",
")",
"bot",
".",
"loop",
".",
"call_soon",
"(",
"plugin",
... | force reconnect
%%reconnect | [
"force",
"reconnect"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/command.py#L473-L479 |
gawel/irc3 | irc3/plugins/command.py | print_help_page | def print_help_page(bot, file=sys.stdout):
"""print help page"""
def p(text):
print(text, file=file)
plugin = bot.get_plugin(Commands)
title = "Available Commands for {nick} at {host}".format(**bot.config)
p("=" * len(title))
p(title)
p("=" * len(title))
p('')
p('.. contents:... | python | def print_help_page(bot, file=sys.stdout):
"""print help page"""
def p(text):
print(text, file=file)
plugin = bot.get_plugin(Commands)
title = "Available Commands for {nick} at {host}".format(**bot.config)
p("=" * len(title))
p(title)
p("=" * len(title))
p('')
p('.. contents:... | [
"def",
"print_help_page",
"(",
"bot",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"def",
"p",
"(",
"text",
")",
":",
"print",
"(",
"text",
",",
"file",
"=",
"file",
")",
"plugin",
"=",
"bot",
".",
"get_plugin",
"(",
"Commands",
")",
"title",
... | print help page | [
"print",
"help",
"page"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/command.py#L483-L519 |
gawel/irc3 | irc3/plugins/core.py | Core.connected | def connected(self, **kwargs):
"""triger the server_ready event"""
self.bot.log.info('Server config: %r', self.bot.server_config)
# recompile when I'm sure of my nickname
self.bot.config['nick'] = kwargs['me']
self.bot.recompile()
# Let all plugins know that server can ... | python | def connected(self, **kwargs):
"""triger the server_ready event"""
self.bot.log.info('Server config: %r', self.bot.server_config)
# recompile when I'm sure of my nickname
self.bot.config['nick'] = kwargs['me']
self.bot.recompile()
# Let all plugins know that server can ... | [
"def",
"connected",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"bot",
".",
"log",
".",
"info",
"(",
"'Server config: %r'",
",",
"self",
".",
"bot",
".",
"server_config",
")",
"# recompile when I'm sure of my nickname",
"self",
".",
"bot",
... | triger the server_ready event | [
"triger",
"the",
"server_ready",
"event"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L50-L62 |
gawel/irc3 | irc3/plugins/core.py | Core.pong | def pong(self, event='PONG', data='', **kw): # pragma: no cover
"""P0NG/PING"""
self.bot.log.debug('%s ping-pong (%s)', event, data)
if self.reconn_handle is not None:
self.reconn_handle.cancel()
self.reconn_handle = self.bot.loop.call_later(self.timeout,
... | python | def pong(self, event='PONG', data='', **kw): # pragma: no cover
"""P0NG/PING"""
self.bot.log.debug('%s ping-pong (%s)', event, data)
if self.reconn_handle is not None:
self.reconn_handle.cancel()
self.reconn_handle = self.bot.loop.call_later(self.timeout,
... | [
"def",
"pong",
"(",
"self",
",",
"event",
"=",
"'PONG'",
",",
"data",
"=",
"''",
",",
"*",
"*",
"kw",
")",
":",
"# pragma: no cover",
"self",
".",
"bot",
".",
"log",
".",
"debug",
"(",
"'%s ping-pong (%s)'",
",",
"event",
",",
"data",
")",
"if",
"s... | P0NG/PING | [
"P0NG",
"/",
"PING"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L74-L85 |
gawel/irc3 | irc3/plugins/core.py | Core.ping | def ping(self, data):
"""PING reply"""
self.bot.send('PONG :' + data)
self.pong(event='PING', data=data) | python | def ping(self, data):
"""PING reply"""
self.bot.send('PONG :' + data)
self.pong(event='PING', data=data) | [
"def",
"ping",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"bot",
".",
"send",
"(",
"'PONG :'",
"+",
"data",
")",
"self",
".",
"pong",
"(",
"event",
"=",
"'PING'",
",",
"data",
"=",
"data",
")"
] | PING reply | [
"PING",
"reply"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L88-L91 |
gawel/irc3 | irc3/plugins/core.py | Core.recompile | def recompile(self, nick=None, new_nick=None, **kw):
"""recompile regexp on new nick"""
if self.bot.nick == nick.nick:
self.bot.config['nick'] = new_nick
self.bot.recompile() | python | def recompile(self, nick=None, new_nick=None, **kw):
"""recompile regexp on new nick"""
if self.bot.nick == nick.nick:
self.bot.config['nick'] = new_nick
self.bot.recompile() | [
"def",
"recompile",
"(",
"self",
",",
"nick",
"=",
"None",
",",
"new_nick",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"bot",
".",
"nick",
"==",
"nick",
".",
"nick",
":",
"self",
".",
"bot",
".",
"config",
"[",
"'nick'",
"]"... | recompile regexp on new nick | [
"recompile",
"regexp",
"on",
"new",
"nick"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L94-L98 |
gawel/irc3 | irc3/plugins/core.py | Core.badnick | def badnick(self, me=None, nick=None, **kw):
"""Use alt nick on nick error"""
if me == '*':
self.bot.set_nick(self.bot.nick + '_')
self.bot.log.debug('Trying to regain nickname in 30s...')
self.nick_handle = self.bot.loop.call_later(
30, self.bot.set_nick, self.bo... | python | def badnick(self, me=None, nick=None, **kw):
"""Use alt nick on nick error"""
if me == '*':
self.bot.set_nick(self.bot.nick + '_')
self.bot.log.debug('Trying to regain nickname in 30s...')
self.nick_handle = self.bot.loop.call_later(
30, self.bot.set_nick, self.bo... | [
"def",
"badnick",
"(",
"self",
",",
"me",
"=",
"None",
",",
"nick",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"me",
"==",
"'*'",
":",
"self",
".",
"bot",
".",
"set_nick",
"(",
"self",
".",
"bot",
".",
"nick",
"+",
"'_'",
")",
"self",
... | Use alt nick on nick error | [
"Use",
"alt",
"nick",
"on",
"nick",
"error"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L101-L107 |
gawel/irc3 | irc3/plugins/core.py | Core.set_config | def set_config(self, data=None, **kwargs):
"""Store server config"""
config = self.bot.config['server_config']
for opt in data.split(' '):
if '=' in opt:
opt, value = opt.split('=', 1)
else:
value = True
if opt.isupper():
... | python | def set_config(self, data=None, **kwargs):
"""Store server config"""
config = self.bot.config['server_config']
for opt in data.split(' '):
if '=' in opt:
opt, value = opt.split('=', 1)
else:
value = True
if opt.isupper():
... | [
"def",
"set_config",
"(",
"self",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"self",
".",
"bot",
".",
"config",
"[",
"'server_config'",
"]",
"for",
"opt",
"in",
"data",
".",
"split",
"(",
"' '",
")",
":",
"if",
"'... | Store server config | [
"Store",
"server",
"config"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/core.py#L109-L118 |
gawel/irc3 | irc3/plugins/feeds.py | fetch | def fetch(args):
"""fetch a feed"""
session = args['session']
for feed, filename in zip(args['feeds'], args['filenames']):
try:
resp = session.get(feed, timeout=5)
content = resp.content
except Exception: # pragma: no cover
pass
else:
... | python | def fetch(args):
"""fetch a feed"""
session = args['session']
for feed, filename in zip(args['feeds'], args['filenames']):
try:
resp = session.get(feed, timeout=5)
content = resp.content
except Exception: # pragma: no cover
pass
else:
... | [
"def",
"fetch",
"(",
"args",
")",
":",
"session",
"=",
"args",
"[",
"'session'",
"]",
"for",
"feed",
",",
"filename",
"in",
"zip",
"(",
"args",
"[",
"'feeds'",
"]",
",",
"args",
"[",
"'filenames'",
"]",
")",
":",
"try",
":",
"resp",
"=",
"session",... | fetch a feed | [
"fetch",
"a",
"feed"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/feeds.py#L79-L91 |
gawel/irc3 | irc3/plugins/feeds.py | parse | def parse(feedparser, args):
"""parse a feed using feedparser"""
entries = []
args = irc3.utils.Config(args)
max_date = datetime.datetime.now() - datetime.timedelta(days=2)
for filename in args['filenames']:
try:
with open(filename + '.updated') as fd:
updated = ... | python | def parse(feedparser, args):
"""parse a feed using feedparser"""
entries = []
args = irc3.utils.Config(args)
max_date = datetime.datetime.now() - datetime.timedelta(days=2)
for filename in args['filenames']:
try:
with open(filename + '.updated') as fd:
updated = ... | [
"def",
"parse",
"(",
"feedparser",
",",
"args",
")",
":",
"entries",
"=",
"[",
"]",
"args",
"=",
"irc3",
".",
"utils",
".",
"Config",
"(",
"args",
")",
"max_date",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"datetime",
".",
"timed... | parse a feed using feedparser | [
"parse",
"a",
"feed",
"using",
"feedparser"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/plugins/feeds.py#L94-L126 |
gawel/irc3 | irc3/dcc/client.py | DCCChat.data_received | def data_received(self, data):
"""data received"""
self.set_timeout()
data = self.decode(data)
if self.queue:
data = self.queue.popleft() + data
lines = data.replace('\r', '').split('\n')
self.queue.append(lines.pop(-1))
for line in lines:
... | python | def data_received(self, data):
"""data received"""
self.set_timeout()
data = self.decode(data)
if self.queue:
data = self.queue.popleft() + data
lines = data.replace('\r', '').split('\n')
self.queue.append(lines.pop(-1))
for line in lines:
... | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"set_timeout",
"(",
")",
"data",
"=",
"self",
".",
"decode",
"(",
"data",
")",
"if",
"self",
".",
"queue",
":",
"data",
"=",
"self",
".",
"queue",
".",
"popleft",
"(",
")",
... | data received | [
"data",
"received"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/dcc/client.py#L81-L90 |
gawel/irc3 | irc3d/dec.py | extend | def extend(func):
"""same as :func:`~irc3.dec.extend` but for servers"""
def callback(context, name, ob):
obj = context.context
if info.scope == 'class':
@functools.wraps(func)
def f(self, *args, **kwargs):
plugin = obj.get_plugin(ob)
retur... | python | def extend(func):
"""same as :func:`~irc3.dec.extend` but for servers"""
def callback(context, name, ob):
obj = context.context
if info.scope == 'class':
@functools.wraps(func)
def f(self, *args, **kwargs):
plugin = obj.get_plugin(ob)
retur... | [
"def",
"extend",
"(",
"func",
")",
":",
"def",
"callback",
"(",
"context",
",",
"name",
",",
"ob",
")",
":",
"obj",
"=",
"context",
".",
"context",
"if",
"info",
".",
"scope",
"==",
"'class'",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
... | same as :func:`~irc3.dec.extend` but for servers | [
"same",
"as",
":",
"func",
":",
"~irc3",
".",
"dec",
".",
"extend",
"but",
"for",
"servers"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3d/dec.py#L23-L36 |
gawel/irc3 | irc3/base.py | IrcObject.attach_events | def attach_events(self, *events, **kwargs):
"""Attach one or more events to the bot instance"""
reg = self.registry
insert = 'insert' in kwargs
for e in events:
cregexp = e.compile(self.config)
regexp = getattr(e.regexp, 're', e.regexp)
if regexp not i... | python | def attach_events(self, *events, **kwargs):
"""Attach one or more events to the bot instance"""
reg = self.registry
insert = 'insert' in kwargs
for e in events:
cregexp = e.compile(self.config)
regexp = getattr(e.regexp, 're', e.regexp)
if regexp not i... | [
"def",
"attach_events",
"(",
"self",
",",
"*",
"events",
",",
"*",
"*",
"kwargs",
")",
":",
"reg",
"=",
"self",
".",
"registry",
"insert",
"=",
"'insert'",
"in",
"kwargs",
"for",
"e",
"in",
"events",
":",
"cregexp",
"=",
"e",
".",
"compile",
"(",
"... | Attach one or more events to the bot instance | [
"Attach",
"one",
"or",
"more",
"events",
"to",
"the",
"bot",
"instance"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L156-L171 |
gawel/irc3 | irc3/base.py | IrcObject.detach_events | def detach_events(self, *events):
"""Detach one or more events from the bot instance"""
reg = self.registry
delete = defaultdict(list)
# remove from self.events
all_events = reg.events
for e in events:
regexp = getattr(e.regexp, 're', e.regexp)
io... | python | def detach_events(self, *events):
"""Detach one or more events from the bot instance"""
reg = self.registry
delete = defaultdict(list)
# remove from self.events
all_events = reg.events
for e in events:
regexp = getattr(e.regexp, 're', e.regexp)
io... | [
"def",
"detach_events",
"(",
"self",
",",
"*",
"events",
")",
":",
"reg",
"=",
"self",
".",
"registry",
"delete",
"=",
"defaultdict",
"(",
"list",
")",
"# remove from self.events",
"all_events",
"=",
"reg",
".",
"events",
"for",
"e",
"in",
"events",
":",
... | Detach one or more events from the bot instance | [
"Detach",
"one",
"or",
"more",
"events",
"from",
"the",
"bot",
"instance"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L173-L193 |
gawel/irc3 | irc3/base.py | IrcObject.reload | def reload(self, *modules):
"""Reload one or more plugins"""
self.notify('before_reload')
if 'configfiles' in self.config:
# reload configfiles
self.log.info('Reloading configuration...')
cfg = utils.parse_config(
self.server and 'server' or '... | python | def reload(self, *modules):
"""Reload one or more plugins"""
self.notify('before_reload')
if 'configfiles' in self.config:
# reload configfiles
self.log.info('Reloading configuration...')
cfg = utils.parse_config(
self.server and 'server' or '... | [
"def",
"reload",
"(",
"self",
",",
"*",
"modules",
")",
":",
"self",
".",
"notify",
"(",
"'before_reload'",
")",
"if",
"'configfiles'",
"in",
"self",
".",
"config",
":",
"# reload configfiles",
"self",
".",
"log",
".",
"info",
"(",
"'Reloading configuration.... | Reload one or more plugins | [
"Reload",
"one",
"or",
"more",
"plugins"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L230-L262 |
gawel/irc3 | irc3/base.py | IrcObject.call_many | def call_many(self, callback, args):
"""callback is run with each arg but run a call per second"""
if isinstance(callback, str):
callback = getattr(self, callback)
f = None
for arg in args:
f = callback(*arg)
return f | python | def call_many(self, callback, args):
"""callback is run with each arg but run a call per second"""
if isinstance(callback, str):
callback = getattr(self, callback)
f = None
for arg in args:
f = callback(*arg)
return f | [
"def",
"call_many",
"(",
"self",
",",
"callback",
",",
"args",
")",
":",
"if",
"isinstance",
"(",
"callback",
",",
"str",
")",
":",
"callback",
"=",
"getattr",
"(",
"self",
",",
"callback",
")",
"f",
"=",
"None",
"for",
"arg",
"in",
"args",
":",
"f... | callback is run with each arg but run a call per second | [
"callback",
"is",
"run",
"with",
"each",
"arg",
"but",
"run",
"a",
"call",
"per",
"second"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L295-L302 |
gawel/irc3 | irc3/base.py | IrcObject.add_signal_handlers | def add_signal_handlers(self):
"""Register handlers for UNIX signals (SIGHUP/SIGINT)"""
try:
self.loop.add_signal_handler(signal.SIGHUP, self.SIGHUP)
except (RuntimeError, AttributeError): # pragma: no cover
# windows
pass
try:
self.loop.a... | python | def add_signal_handlers(self):
"""Register handlers for UNIX signals (SIGHUP/SIGINT)"""
try:
self.loop.add_signal_handler(signal.SIGHUP, self.SIGHUP)
except (RuntimeError, AttributeError): # pragma: no cover
# windows
pass
try:
self.loop.a... | [
"def",
"add_signal_handlers",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"loop",
".",
"add_signal_handler",
"(",
"signal",
".",
"SIGHUP",
",",
"self",
".",
"SIGHUP",
")",
"except",
"(",
"RuntimeError",
",",
"AttributeError",
")",
":",
"# pragma: no cove... | Register handlers for UNIX signals (SIGHUP/SIGINT) | [
"Register",
"handlers",
"for",
"UNIX",
"signals",
"(",
"SIGHUP",
"/",
"SIGINT",
")"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L352-L363 |
gawel/irc3 | irc3/base.py | IrcObject.run | def run(self, forever=True):
"""start the bot"""
loop = self.create_connection()
self.add_signal_handlers()
if forever:
loop.run_forever() | python | def run(self, forever=True):
"""start the bot"""
loop = self.create_connection()
self.add_signal_handlers()
if forever:
loop.run_forever() | [
"def",
"run",
"(",
"self",
",",
"forever",
"=",
"True",
")",
":",
"loop",
"=",
"self",
".",
"create_connection",
"(",
")",
"self",
".",
"add_signal_handlers",
"(",
")",
"if",
"forever",
":",
"loop",
".",
"run_forever",
"(",
")"
] | start the bot | [
"start",
"the",
"bot"
] | train | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L365-L370 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.