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 |
|---|---|---|---|---|---|---|---|---|---|---|
bitlabstudio/django-influxdb-metrics | influxdb_metrics/utils.py | get_client | def get_client():
"""Returns an ``InfluxDBClient`` instance."""
return InfluxDBClient(
settings.INFLUXDB_HOST,
settings.INFLUXDB_PORT,
settings.INFLUXDB_USER,
settings.INFLUXDB_PASSWORD,
settings.INFLUXDB_DATABASE,
timeout=settings.INFLUXDB_TIMEOUT,
ssl=ge... | python | def get_client():
"""Returns an ``InfluxDBClient`` instance."""
return InfluxDBClient(
settings.INFLUXDB_HOST,
settings.INFLUXDB_PORT,
settings.INFLUXDB_USER,
settings.INFLUXDB_PASSWORD,
settings.INFLUXDB_DATABASE,
timeout=settings.INFLUXDB_TIMEOUT,
ssl=ge... | [
"def",
"get_client",
"(",
")",
":",
"return",
"InfluxDBClient",
"(",
"settings",
".",
"INFLUXDB_HOST",
",",
"settings",
".",
"INFLUXDB_PORT",
",",
"settings",
".",
"INFLUXDB_USER",
",",
"settings",
".",
"INFLUXDB_PASSWORD",
",",
"settings",
".",
"INFLUXDB_DATABASE... | Returns an ``InfluxDBClient`` instance. | [
"Returns",
"an",
"InfluxDBClient",
"instance",
"."
] | train | https://github.com/bitlabstudio/django-influxdb-metrics/blob/c9f368e28a6072813454b6b549b4afa64aad778a/influxdb_metrics/utils.py#L13-L24 |
bitlabstudio/django-influxdb-metrics | influxdb_metrics/utils.py | write_points | def write_points(data, force_disable_threading=False):
"""
Writes a series to influxdb.
:param data: Array of dicts, as required by
https://github.com/influxdb/influxdb-python
:param force_disable_threading: When being called from the Celery task, we
set this to `True` so that the user does... | python | def write_points(data, force_disable_threading=False):
"""
Writes a series to influxdb.
:param data: Array of dicts, as required by
https://github.com/influxdb/influxdb-python
:param force_disable_threading: When being called from the Celery task, we
set this to `True` so that the user does... | [
"def",
"write_points",
"(",
"data",
",",
"force_disable_threading",
"=",
"False",
")",
":",
"if",
"getattr",
"(",
"settings",
",",
"'INFLUXDB_DISABLED'",
",",
"False",
")",
":",
"return",
"client",
"=",
"get_client",
"(",
")",
"use_threading",
"=",
"getattr",
... | Writes a series to influxdb.
:param data: Array of dicts, as required by
https://github.com/influxdb/influxdb-python
:param force_disable_threading: When being called from the Celery task, we
set this to `True` so that the user doesn't accidentally use Celery and
threading at the same time. | [
"Writes",
"a",
"series",
"to",
"influxdb",
"."
] | train | https://github.com/bitlabstudio/django-influxdb-metrics/blob/c9f368e28a6072813454b6b549b4afa64aad778a/influxdb_metrics/utils.py#L33-L55 |
bitlabstudio/django-influxdb-metrics | influxdb_metrics/utils.py | process_points | def process_points(client, data): # pragma: no cover
"""Method to be called via threading module."""
try:
client.write_points(data)
except Exception:
if getattr(settings, 'INFLUXDB_FAIL_SILENTLY', True):
logger.exception('Error while writing data points')
else:
... | python | def process_points(client, data): # pragma: no cover
"""Method to be called via threading module."""
try:
client.write_points(data)
except Exception:
if getattr(settings, 'INFLUXDB_FAIL_SILENTLY', True):
logger.exception('Error while writing data points')
else:
... | [
"def",
"process_points",
"(",
"client",
",",
"data",
")",
":",
"# pragma: no cover",
"try",
":",
"client",
".",
"write_points",
"(",
"data",
")",
"except",
"Exception",
":",
"if",
"getattr",
"(",
"settings",
",",
"'INFLUXDB_FAIL_SILENTLY'",
",",
"True",
")",
... | Method to be called via threading module. | [
"Method",
"to",
"be",
"called",
"via",
"threading",
"module",
"."
] | train | https://github.com/bitlabstudio/django-influxdb-metrics/blob/c9f368e28a6072813454b6b549b4afa64aad778a/influxdb_metrics/utils.py#L58-L66 |
keiichishima/pcalg | pcalg.py | _create_complete_graph | def _create_complete_graph(node_ids):
"""Create a complete graph from the list of node ids.
Args:
node_ids: a list of node ids
Returns:
An undirected graph (as a networkx.Graph)
"""
g = nx.Graph()
g.add_nodes_from(node_ids)
for (i, j) in combinations(node_ids, 2):
g... | python | def _create_complete_graph(node_ids):
"""Create a complete graph from the list of node ids.
Args:
node_ids: a list of node ids
Returns:
An undirected graph (as a networkx.Graph)
"""
g = nx.Graph()
g.add_nodes_from(node_ids)
for (i, j) in combinations(node_ids, 2):
g... | [
"def",
"_create_complete_graph",
"(",
"node_ids",
")",
":",
"g",
"=",
"nx",
".",
"Graph",
"(",
")",
"g",
".",
"add_nodes_from",
"(",
"node_ids",
")",
"for",
"(",
"i",
",",
"j",
")",
"in",
"combinations",
"(",
"node_ids",
",",
"2",
")",
":",
"g",
".... | Create a complete graph from the list of node ids.
Args:
node_ids: a list of node ids
Returns:
An undirected graph (as a networkx.Graph) | [
"Create",
"a",
"complete",
"graph",
"from",
"the",
"list",
"of",
"node",
"ids",
"."
] | train | https://github.com/keiichishima/pcalg/blob/f270e2bdb76b88c8f80a1ea07317ff4be88e2359/pcalg.py#L22-L35 |
keiichishima/pcalg | pcalg.py | estimate_skeleton | def estimate_skeleton(indep_test_func, data_matrix, alpha, **kwargs):
"""Estimate a skeleton graph from the statistis information.
Args:
indep_test_func: the function name for a conditional
independency test.
data_matrix: data (as a numpy array).
alpha: the significance leve... | python | def estimate_skeleton(indep_test_func, data_matrix, alpha, **kwargs):
"""Estimate a skeleton graph from the statistis information.
Args:
indep_test_func: the function name for a conditional
independency test.
data_matrix: data (as a numpy array).
alpha: the significance leve... | [
"def",
"estimate_skeleton",
"(",
"indep_test_func",
",",
"data_matrix",
",",
"alpha",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"method_stable",
"(",
"kwargs",
")",
":",
"return",
"(",
"'method'",
"in",
"kwargs",
")",
"and",
"kwargs",
"[",
"'method'",
"]",... | Estimate a skeleton graph from the statistis information.
Args:
indep_test_func: the function name for a conditional
independency test.
data_matrix: data (as a numpy array).
alpha: the significance level.
kwargs:
'max_reach': maximum value of l (see the code)... | [
"Estimate",
"a",
"skeleton",
"graph",
"from",
"the",
"statistis",
"information",
"."
] | train | https://github.com/keiichishima/pcalg/blob/f270e2bdb76b88c8f80a1ea07317ff4be88e2359/pcalg.py#L37-L123 |
keiichishima/pcalg | pcalg.py | estimate_cpdag | def estimate_cpdag(skel_graph, sep_set):
"""Estimate a CPDAG from the skeleton graph and separation sets
returned by the estimate_skeleton() function.
Args:
skel_graph: A skeleton graph (an undirected networkx.Graph).
sep_set: An 2D-array of separation set.
The contents look lik... | python | def estimate_cpdag(skel_graph, sep_set):
"""Estimate a CPDAG from the skeleton graph and separation sets
returned by the estimate_skeleton() function.
Args:
skel_graph: A skeleton graph (an undirected networkx.Graph).
sep_set: An 2D-array of separation set.
The contents look lik... | [
"def",
"estimate_cpdag",
"(",
"skel_graph",
",",
"sep_set",
")",
":",
"dag",
"=",
"skel_graph",
".",
"to_directed",
"(",
")",
"node_ids",
"=",
"skel_graph",
".",
"nodes",
"(",
")",
"for",
"(",
"i",
",",
"j",
")",
"in",
"combinations",
"(",
"node_ids",
... | Estimate a CPDAG from the skeleton graph and separation sets
returned by the estimate_skeleton() function.
Args:
skel_graph: A skeleton graph (an undirected networkx.Graph).
sep_set: An 2D-array of separation set.
The contents look like something like below.
sep_set[... | [
"Estimate",
"a",
"CPDAG",
"from",
"the",
"skeleton",
"graph",
"and",
"separation",
"sets",
"returned",
"by",
"the",
"estimate_skeleton",
"()",
"function",
"."
] | train | https://github.com/keiichishima/pcalg/blob/f270e2bdb76b88c8f80a1ea07317ff4be88e2359/pcalg.py#L125-L252 |
fedora-infra/fedmsg | fedmsg/utils.py | set_high_water_mark | def set_high_water_mark(socket, config):
""" Set a high water mark on the zmq socket. Do so in a way that is
cross-compatible with zeromq2 and zeromq3.
"""
if config['high_water_mark']:
if hasattr(zmq, 'HWM'):
# zeromq2
socket.setsockopt(zmq.HWM, config['high_water_mark... | python | def set_high_water_mark(socket, config):
""" Set a high water mark on the zmq socket. Do so in a way that is
cross-compatible with zeromq2 and zeromq3.
"""
if config['high_water_mark']:
if hasattr(zmq, 'HWM'):
# zeromq2
socket.setsockopt(zmq.HWM, config['high_water_mark... | [
"def",
"set_high_water_mark",
"(",
"socket",
",",
"config",
")",
":",
"if",
"config",
"[",
"'high_water_mark'",
"]",
":",
"if",
"hasattr",
"(",
"zmq",
",",
"'HWM'",
")",
":",
"# zeromq2",
"socket",
".",
"setsockopt",
"(",
"zmq",
".",
"HWM",
",",
"config"... | Set a high water mark on the zmq socket. Do so in a way that is
cross-compatible with zeromq2 and zeromq3. | [
"Set",
"a",
"high",
"water",
"mark",
"on",
"the",
"zmq",
"socket",
".",
"Do",
"so",
"in",
"a",
"way",
"that",
"is",
"cross",
"-",
"compatible",
"with",
"zeromq2",
"and",
"zeromq3",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L32-L44 |
fedora-infra/fedmsg | fedmsg/utils.py | set_tcp_keepalive | def set_tcp_keepalive(socket, config):
""" Set a series of TCP keepalive options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
We ran into a problem in FedoraInfrastructure where long-standing
connectio... | python | def set_tcp_keepalive(socket, config):
""" Set a series of TCP keepalive options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
We ran into a problem in FedoraInfrastructure where long-standing
connectio... | [
"def",
"set_tcp_keepalive",
"(",
"socket",
",",
"config",
")",
":",
"keepalive_options",
"=",
"{",
"# Map fedmsg config keys to zeromq socket constants",
"'zmq_tcp_keepalive'",
":",
"'TCP_KEEPALIVE'",
",",
"'zmq_tcp_keepalive_cnt'",
":",
"'TCP_KEEPALIVE_CNT'",
",",
"'zmq_tcp_... | Set a series of TCP keepalive options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
We ran into a problem in FedoraInfrastructure where long-standing
connections between some hosts would suddenly drop off t... | [
"Set",
"a",
"series",
"of",
"TCP",
"keepalive",
"options",
"on",
"the",
"socket",
"if",
"and",
"only",
"if",
"1",
")",
"they",
"are",
"specified",
"explicitly",
"in",
"the",
"config",
"and",
"2",
")",
"the",
"version",
"of",
"pyzmq",
"has",
"been",
"co... | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L59-L88 |
fedora-infra/fedmsg | fedmsg/utils.py | set_tcp_reconnect | def set_tcp_reconnect(socket, config):
""" Set a series of TCP reconnect options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
Once our fedmsg bus grew to include many hundreds of endpoints, we started
... | python | def set_tcp_reconnect(socket, config):
""" Set a series of TCP reconnect options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
Once our fedmsg bus grew to include many hundreds of endpoints, we started
... | [
"def",
"set_tcp_reconnect",
"(",
"socket",
",",
"config",
")",
":",
"reconnect_options",
"=",
"{",
"# Map fedmsg config keys to zeromq socket constants",
"'zmq_reconnect_ivl'",
":",
"'RECONNECT_IVL'",
",",
"'zmq_reconnect_ivl_max'",
":",
"'RECONNECT_IVL_MAX'",
",",
"}",
"fo... | Set a series of TCP reconnect options on the socket if
and only if
1) they are specified explicitly in the config and
2) the version of pyzmq has been compiled with support
Once our fedmsg bus grew to include many hundreds of endpoints, we started
notices a *lot* of SYN-ACKs in the logs. By de... | [
"Set",
"a",
"series",
"of",
"TCP",
"reconnect",
"options",
"on",
"the",
"socket",
"if",
"and",
"only",
"if",
"1",
")",
"they",
"are",
"specified",
"explicitly",
"in",
"the",
"config",
"and",
"2",
")",
"the",
"version",
"of",
"pyzmq",
"has",
"been",
"co... | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L91-L117 |
fedora-infra/fedmsg | fedmsg/utils.py | load_class | def load_class(location):
""" Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer'
and return the IRCBotConsumer class.
"""
mod_name, cls_name = location = location.strip().split(':')
tokens = mod_name.split('.')
fromlist = '[]'
if len(tokens) > 1:
fromlist = '.'.join(... | python | def load_class(location):
""" Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer'
and return the IRCBotConsumer class.
"""
mod_name, cls_name = location = location.strip().split(':')
tokens = mod_name.split('.')
fromlist = '[]'
if len(tokens) > 1:
fromlist = '.'.join(... | [
"def",
"load_class",
"(",
"location",
")",
":",
"mod_name",
",",
"cls_name",
"=",
"location",
"=",
"location",
".",
"strip",
"(",
")",
".",
"split",
"(",
"':'",
")",
"tokens",
"=",
"mod_name",
".",
"split",
"(",
"'.'",
")",
"fromlist",
"=",
"'[]'",
"... | Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer'
and return the IRCBotConsumer class. | [
"Take",
"a",
"string",
"of",
"the",
"form",
"fedmsg",
".",
"consumers",
".",
"ircbot",
":",
"IRCBotConsumer",
"and",
"return",
"the",
"IRCBotConsumer",
"class",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L120-L136 |
fedora-infra/fedmsg | fedmsg/utils.py | dict_query | def dict_query(dic, query):
""" Query a dict with 'dotted notation'. Returns an OrderedDict.
A query of "foo.bar.baz" would retrieve 'wat' from this::
dic = {
'foo': {
'bar': {
'baz': 'wat',
}
}
}
Multiple querie... | python | def dict_query(dic, query):
""" Query a dict with 'dotted notation'. Returns an OrderedDict.
A query of "foo.bar.baz" would retrieve 'wat' from this::
dic = {
'foo': {
'bar': {
'baz': 'wat',
}
}
}
Multiple querie... | [
"def",
"dict_query",
"(",
"dic",
",",
"query",
")",
":",
"if",
"not",
"isinstance",
"(",
"query",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"query must be a string, not %r\"",
"%",
"type",
"(",
"query",
")",
")",
"def",
"_bro... | Query a dict with 'dotted notation'. Returns an OrderedDict.
A query of "foo.bar.baz" would retrieve 'wat' from this::
dic = {
'foo': {
'bar': {
'baz': 'wat',
}
}
}
Multiple queries can be specified if comma-separate... | [
"Query",
"a",
"dict",
"with",
"dotted",
"notation",
".",
"Returns",
"an",
"OrderedDict",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L139-L183 |
fedora-infra/fedmsg | fedmsg/utils.py | cowsay_output | def cowsay_output(message):
""" Invoke a shell command to print cowsay output. Primary replacement for
os.system calls.
"""
command = 'cowsay "%s"' % message
ret = subprocess.Popen(
command, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=... | python | def cowsay_output(message):
""" Invoke a shell command to print cowsay output. Primary replacement for
os.system calls.
"""
command = 'cowsay "%s"' % message
ret = subprocess.Popen(
command, shell=True, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=... | [
"def",
"cowsay_output",
"(",
"message",
")",
":",
"command",
"=",
"'cowsay \"%s\"'",
"%",
"message",
"ret",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"shell",
"=",
"True",
",",
"stdin",
"=",
"subprocess",
".",
"PIPE",
",",
"stdout",
"=",
"sub... | Invoke a shell command to print cowsay output. Primary replacement for
os.system calls. | [
"Invoke",
"a",
"shell",
"command",
"to",
"print",
"cowsay",
"output",
".",
"Primary",
"replacement",
"for",
"os",
".",
"system",
"calls",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/utils.py#L186-L195 |
fedora-infra/fedmsg | fedmsg/encoding/sqla.py | to_json | def to_json(obj, seen=None):
""" Returns a dict representation of the object.
Recursively evaluates to_json(...) on its relationships.
"""
if not seen:
seen = []
properties = list(class_mapper(type(obj)).iterate_properties)
relationships = [
p.key for p in properties if type(p... | python | def to_json(obj, seen=None):
""" Returns a dict representation of the object.
Recursively evaluates to_json(...) on its relationships.
"""
if not seen:
seen = []
properties = list(class_mapper(type(obj)).iterate_properties)
relationships = [
p.key for p in properties if type(p... | [
"def",
"to_json",
"(",
"obj",
",",
"seen",
"=",
"None",
")",
":",
"if",
"not",
"seen",
":",
"seen",
"=",
"[",
"]",
"properties",
"=",
"list",
"(",
"class_mapper",
"(",
"type",
"(",
"obj",
")",
")",
".",
"iterate_properties",
")",
"relationships",
"="... | Returns a dict representation of the object.
Recursively evaluates to_json(...) on its relationships. | [
"Returns",
"a",
"dict",
"representation",
"of",
"the",
"object",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/encoding/sqla.py#L35-L57 |
fedora-infra/fedmsg | fedmsg/encoding/sqla.py | expand | def expand(obj, relation, seen):
""" Return the to_json or id of a sqlalchemy relationship. """
if hasattr(relation, 'all'):
relation = relation.all()
if hasattr(relation, '__iter__'):
return [expand(obj, item, seen) for item in relation]
if type(relation) not in seen:
return ... | python | def expand(obj, relation, seen):
""" Return the to_json or id of a sqlalchemy relationship. """
if hasattr(relation, 'all'):
relation = relation.all()
if hasattr(relation, '__iter__'):
return [expand(obj, item, seen) for item in relation]
if type(relation) not in seen:
return ... | [
"def",
"expand",
"(",
"obj",
",",
"relation",
",",
"seen",
")",
":",
"if",
"hasattr",
"(",
"relation",
",",
"'all'",
")",
":",
"relation",
"=",
"relation",
".",
"all",
"(",
")",
"if",
"hasattr",
"(",
"relation",
",",
"'__iter__'",
")",
":",
"return",... | Return the to_json or id of a sqlalchemy relationship. | [
"Return",
"the",
"to_json",
"or",
"id",
"of",
"a",
"sqlalchemy",
"relationship",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/encoding/sqla.py#L60-L72 |
fedora-infra/fedmsg | fedmsg/consumers/relay.py | SigningRelayConsumer.consume | def consume(self, msg):
"""
Sign the message prior to sending the message.
Args:
msg (dict): The message to sign and relay.
"""
msg['body'] = crypto.sign(msg['body'], **self.hub.config)
super(SigningRelayConsumer, self).consume(msg) | python | def consume(self, msg):
"""
Sign the message prior to sending the message.
Args:
msg (dict): The message to sign and relay.
"""
msg['body'] = crypto.sign(msg['body'], **self.hub.config)
super(SigningRelayConsumer, self).consume(msg) | [
"def",
"consume",
"(",
"self",
",",
"msg",
")",
":",
"msg",
"[",
"'body'",
"]",
"=",
"crypto",
".",
"sign",
"(",
"msg",
"[",
"'body'",
"]",
",",
"*",
"*",
"self",
".",
"hub",
".",
"config",
")",
"super",
"(",
"SigningRelayConsumer",
",",
"self",
... | Sign the message prior to sending the message.
Args:
msg (dict): The message to sign and relay. | [
"Sign",
"the",
"message",
"prior",
"to",
"sending",
"the",
"message",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/consumers/relay.py#L81-L89 |
fedora-infra/fedmsg | fedmsg/consumers/__init__.py | FedmsgConsumer._backlog | def _backlog(self, data):
"""Find all the datagrepper messages between 'then' and 'now'.
Put those on our work queue.
Should be called in a thread so as not to block the hub at startup.
"""
try:
data = json.loads(data)
except ValueError as e:
se... | python | def _backlog(self, data):
"""Find all the datagrepper messages between 'then' and 'now'.
Put those on our work queue.
Should be called in a thread so as not to block the hub at startup.
"""
try:
data = json.loads(data)
except ValueError as e:
se... | [
"def",
"_backlog",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"except",
"ValueError",
"as",
"e",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Status contents are %r\"",
"%",
"data",
")",
"sel... | Find all the datagrepper messages between 'then' and 'now'.
Put those on our work queue.
Should be called in a thread so as not to block the hub at startup. | [
"Find",
"all",
"the",
"datagrepper",
"messages",
"between",
"then",
"and",
"now",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/consumers/__init__.py#L161-L197 |
fedora-infra/fedmsg | fedmsg/consumers/__init__.py | FedmsgConsumer.validate | def validate(self, message):
"""
Validate the message before the consumer processes it.
This needs to raise an exception, caught by moksha.
Args:
message (dict): The message as a dictionary. This must, at a minimum,
contain the 'topic' key with a unicode str... | python | def validate(self, message):
"""
Validate the message before the consumer processes it.
This needs to raise an exception, caught by moksha.
Args:
message (dict): The message as a dictionary. This must, at a minimum,
contain the 'topic' key with a unicode str... | [
"def",
"validate",
"(",
"self",
",",
"message",
")",
":",
"if",
"hasattr",
"(",
"message",
",",
"'__json__'",
")",
":",
"message",
"=",
"message",
".",
"__json__",
"(",
")",
"if",
"isinstance",
"(",
"message",
"[",
"'body'",
"]",
",",
"six",
".",
"te... | Validate the message before the consumer processes it.
This needs to raise an exception, caught by moksha.
Args:
message (dict): The message as a dictionary. This must, at a minimum,
contain the 'topic' key with a unicode string value and 'body' key
with a d... | [
"Validate",
"the",
"message",
"before",
"the",
"consumer",
"processes",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/consumers/__init__.py#L224-L271 |
fedora-infra/fedmsg | fedmsg/consumers/__init__.py | FedmsgConsumer._consume | def _consume(self, message):
""" Called when a message is consumed.
This private method handles some administrative setup and teardown
before calling the public interface `consume` typically implemented
by a subclass.
When `moksha.blocking_mode` is set to `False` in the config,... | python | def _consume(self, message):
""" Called when a message is consumed.
This private method handles some administrative setup and teardown
before calling the public interface `consume` typically implemented
by a subclass.
When `moksha.blocking_mode` is set to `False` in the config,... | [
"def",
"_consume",
"(",
"self",
",",
"message",
")",
":",
"try",
":",
"self",
".",
"validate",
"(",
"message",
")",
"except",
"RuntimeWarning",
"as",
"e",
":",
"self",
".",
"log",
".",
"warn",
"(",
"\"Received invalid message {0}\"",
".",
"format",
"(",
... | Called when a message is consumed.
This private method handles some administrative setup and teardown
before calling the public interface `consume` typically implemented
by a subclass.
When `moksha.blocking_mode` is set to `False` in the config, this
method always returns `None... | [
"Called",
"when",
"a",
"message",
"is",
"consumed",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/consumers/__init__.py#L273-L323 |
kenneth-reitz/args | args.py | ArgsList.remove | def remove(self, x):
"""Removes given arg (or list thereof) from Args object."""
def _remove(x):
found = self.first(x)
if found is not None:
self._args.pop(found)
if _is_collection(x):
for item in x:
_remove(x)
else:
... | python | def remove(self, x):
"""Removes given arg (or list thereof) from Args object."""
def _remove(x):
found = self.first(x)
if found is not None:
self._args.pop(found)
if _is_collection(x):
for item in x:
_remove(x)
else:
... | [
"def",
"remove",
"(",
"self",
",",
"x",
")",
":",
"def",
"_remove",
"(",
"x",
")",
":",
"found",
"=",
"self",
".",
"first",
"(",
"x",
")",
"if",
"found",
"is",
"not",
"None",
":",
"self",
".",
"_args",
".",
"pop",
"(",
"found",
")",
"if",
"_i... | Removes given arg (or list thereof) from Args object. | [
"Removes",
"given",
"arg",
"(",
"or",
"list",
"thereof",
")",
"from",
"Args",
"object",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L88-L100 |
kenneth-reitz/args | args.py | ArgsList.first | def first(self, x):
"""Returns first found index of given value (or list of values)."""
def _find(x):
try:
return self.all.index(str(x))
except ValueError:
return None
if _is_collection(x):
for item in x:
found... | python | def first(self, x):
"""Returns first found index of given value (or list of values)."""
def _find(x):
try:
return self.all.index(str(x))
except ValueError:
return None
if _is_collection(x):
for item in x:
found... | [
"def",
"first",
"(",
"self",
",",
"x",
")",
":",
"def",
"_find",
"(",
"x",
")",
":",
"try",
":",
"return",
"self",
".",
"all",
".",
"index",
"(",
"str",
"(",
"x",
")",
")",
"except",
"ValueError",
":",
"return",
"None",
"if",
"_is_collection",
"(... | Returns first found index of given value (or list of values). | [
"Returns",
"first",
"found",
"index",
"of",
"given",
"value",
"(",
"or",
"list",
"of",
"values",
")",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L121-L137 |
kenneth-reitz/args | args.py | ArgsList.start_with | def start_with(self, x):
"""Returns all arguments beginning with given string
(or list thereof).
"""
_args = []
for arg in self.all:
if _is_collection(x):
for _x in x:
if arg.startswith(x):
_args.append(... | python | def start_with(self, x):
"""Returns all arguments beginning with given string
(or list thereof).
"""
_args = []
for arg in self.all:
if _is_collection(x):
for _x in x:
if arg.startswith(x):
_args.append(... | [
"def",
"start_with",
"(",
"self",
",",
"x",
")",
":",
"_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"all",
":",
"if",
"_is_collection",
"(",
"x",
")",
":",
"for",
"_x",
"in",
"x",
":",
"if",
"arg",
".",
"startswith",
"(",
"x",
")",
... | Returns all arguments beginning with given string
(or list thereof). | [
"Returns",
"all",
"arguments",
"beginning",
"with",
"given",
"string",
"(",
"or",
"list",
"thereof",
")",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L181-L198 |
kenneth-reitz/args | args.py | ArgsList.all_without | def all_without(self, x):
"""Returns all arguments not containing given string
(or list thereof).
"""
_args = []
for arg in self.all:
if _is_collection(x):
for _x in x:
if _x not in arg:
_args.append(arg... | python | def all_without(self, x):
"""Returns all arguments not containing given string
(or list thereof).
"""
_args = []
for arg in self.all:
if _is_collection(x):
for _x in x:
if _x not in arg:
_args.append(arg... | [
"def",
"all_without",
"(",
"self",
",",
"x",
")",
":",
"_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"all",
":",
"if",
"_is_collection",
"(",
"x",
")",
":",
"for",
"_x",
"in",
"x",
":",
"if",
"_x",
"not",
"in",
"arg",
":",
"_args",
... | Returns all arguments not containing given string
(or list thereof). | [
"Returns",
"all",
"arguments",
"not",
"containing",
"given",
"string",
"(",
"or",
"list",
"thereof",
")",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L297-L314 |
kenneth-reitz/args | args.py | ArgsList.files | def files(self, absolute=False):
"""Returns an expanded list of all valid paths that were passed in."""
_paths = []
for arg in self.all:
for path in _expand_path(arg):
if os.path.exists(path):
if absolute:
_paths.append(os... | python | def files(self, absolute=False):
"""Returns an expanded list of all valid paths that were passed in."""
_paths = []
for arg in self.all:
for path in _expand_path(arg):
if os.path.exists(path):
if absolute:
_paths.append(os... | [
"def",
"files",
"(",
"self",
",",
"absolute",
"=",
"False",
")",
":",
"_paths",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"all",
":",
"for",
"path",
"in",
"_expand_path",
"(",
"arg",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
... | Returns an expanded list of all valid paths that were passed in. | [
"Returns",
"an",
"expanded",
"list",
"of",
"all",
"valid",
"paths",
"that",
"were",
"passed",
"in",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L329-L342 |
kenneth-reitz/args | args.py | ArgsList.not_files | def not_files(self):
"""Returns a list of all arguments that aren't files/globs."""
_args = []
for arg in self.all:
if not len(_expand_path(arg)):
if not os.path.exists(arg):
_args.append(arg)
return ArgsList(_args, no_argv=True) | python | def not_files(self):
"""Returns a list of all arguments that aren't files/globs."""
_args = []
for arg in self.all:
if not len(_expand_path(arg)):
if not os.path.exists(arg):
_args.append(arg)
return ArgsList(_args, no_argv=True) | [
"def",
"not_files",
"(",
"self",
")",
":",
"_args",
"=",
"[",
"]",
"for",
"arg",
"in",
"self",
".",
"all",
":",
"if",
"not",
"len",
"(",
"_expand_path",
"(",
"arg",
")",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"arg",
")",
... | Returns a list of all arguments that aren't files/globs. | [
"Returns",
"a",
"list",
"of",
"all",
"arguments",
"that",
"aren",
"t",
"files",
"/",
"globs",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L345-L355 |
kenneth-reitz/args | args.py | ArgsList.assignments | def assignments(self):
"""Extracts assignment values from assignments."""
collection = OrderedDict()
for arg in self.all:
if '=' in arg:
collection.setdefault(
arg.split('=', 1)[0], ArgsList(no_argv=True))
collection[arg.split('='... | python | def assignments(self):
"""Extracts assignment values from assignments."""
collection = OrderedDict()
for arg in self.all:
if '=' in arg:
collection.setdefault(
arg.split('=', 1)[0], ArgsList(no_argv=True))
collection[arg.split('='... | [
"def",
"assignments",
"(",
"self",
")",
":",
"collection",
"=",
"OrderedDict",
"(",
")",
"for",
"arg",
"in",
"self",
".",
"all",
":",
"if",
"'='",
"in",
"arg",
":",
"collection",
".",
"setdefault",
"(",
"arg",
".",
"split",
"(",
"'='",
",",
"1",
")... | Extracts assignment values from assignments. | [
"Extracts",
"assignment",
"values",
"from",
"assignments",
"."
] | train | https://github.com/kenneth-reitz/args/blob/9460f1a35eb3055e9e4de1f0a6932e0883c72d65/args.py#L364-L376 |
fedora-infra/fedmsg | fedmsg/crypto/gpg.py | sign | def sign(message, gpg_home=None, gpg_signing_key=None, **config):
""" Insert a new field into the message dict and return it.
The new field is:
- 'signature' - the computed GPG message digest of the JSON repr
of the `msg` field.
"""
if gpg_home is None or gpg_signing_key is None:
... | python | def sign(message, gpg_home=None, gpg_signing_key=None, **config):
""" Insert a new field into the message dict and return it.
The new field is:
- 'signature' - the computed GPG message digest of the JSON repr
of the `msg` field.
"""
if gpg_home is None or gpg_signing_key is None:
... | [
"def",
"sign",
"(",
"message",
",",
"gpg_home",
"=",
"None",
",",
"gpg_signing_key",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"if",
"gpg_home",
"is",
"None",
"or",
"gpg_signing_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must set the... | Insert a new field into the message dict and return it.
The new field is:
- 'signature' - the computed GPG message digest of the JSON repr
of the `msg` field. | [
"Insert",
"a",
"new",
"field",
"into",
"the",
"message",
"dict",
"and",
"return",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/gpg.py#L157-L177 |
fedora-infra/fedmsg | fedmsg/crypto/gpg.py | validate | def validate(message, gpg_home=None, **config):
""" Return true or false if the message is signed appropriately.
Two things must be true:
1) The signature must be valid (obviously)
2) The signing key must be in the local keyring
as defined by the `gpg_home` config value.
"""
... | python | def validate(message, gpg_home=None, **config):
""" Return true or false if the message is signed appropriately.
Two things must be true:
1) The signature must be valid (obviously)
2) The signing key must be in the local keyring
as defined by the `gpg_home` config value.
"""
... | [
"def",
"validate",
"(",
"message",
",",
"gpg_home",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"if",
"gpg_home",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must set the gpg_home keyword argument.\"",
")",
"try",
":",
"_ctx",
".",
"verify",
"(... | Return true or false if the message is signed appropriately.
Two things must be true:
1) The signature must be valid (obviously)
2) The signing key must be in the local keyring
as defined by the `gpg_home` config value. | [
"Return",
"true",
"or",
"false",
"if",
"the",
"message",
"is",
"signed",
"appropriately",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/gpg.py#L180-L200 |
fedora-infra/fedmsg | fedmsg/crypto/gpg.py | Context.verify | def verify(self, data, signature=None, keyrings=None, homedir=None):
'''
`data` <string> the data to verify.
`signature` <string> The signature, if detached from the data.
`keyrings` <list of string> Additional keyrings to search in.
`homedir` <string> Override the configured hom... | python | def verify(self, data, signature=None, keyrings=None, homedir=None):
'''
`data` <string> the data to verify.
`signature` <string> The signature, if detached from the data.
`keyrings` <list of string> Additional keyrings to search in.
`homedir` <string> Override the configured hom... | [
"def",
"verify",
"(",
"self",
",",
"data",
",",
"signature",
"=",
"None",
",",
"keyrings",
"=",
"None",
",",
"homedir",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
":",
"data",
"=",
"data",
".",
"encod... | `data` <string> the data to verify.
`signature` <string> The signature, if detached from the data.
`keyrings` <list of string> Additional keyrings to search in.
`homedir` <string> Override the configured homedir. | [
"data",
"<string",
">",
"the",
"data",
"to",
"verify",
".",
"signature",
"<string",
">",
"The",
"signature",
"if",
"detached",
"from",
"the",
"data",
".",
"keyrings",
"<list",
"of",
"string",
">",
"Additional",
"keyrings",
"to",
"search",
"in",
".",
"homed... | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/gpg.py#L56-L87 |
fedora-infra/fedmsg | fedmsg/crypto/gpg.py | Context.verify_from_file | def verify_from_file(self, data_path,
sig_path=None, keyrings=None, homedir=None):
'''
`data_path` <string> The path to the data to verify.
`sig_path` <string> The signature file, if detached from the data.
`keyrings` <list of string> Additional keyrings to searc... | python | def verify_from_file(self, data_path,
sig_path=None, keyrings=None, homedir=None):
'''
`data_path` <string> The path to the data to verify.
`sig_path` <string> The signature file, if detached from the data.
`keyrings` <list of string> Additional keyrings to searc... | [
"def",
"verify_from_file",
"(",
"self",
",",
"data_path",
",",
"sig_path",
"=",
"None",
",",
"keyrings",
"=",
"None",
",",
"homedir",
"=",
"None",
")",
":",
"cmd_line",
"=",
"[",
"'gpg'",
",",
"'--homedir'",
",",
"homedir",
"or",
"self",
".",
"homedir",
... | `data_path` <string> The path to the data to verify.
`sig_path` <string> The signature file, if detached from the data.
`keyrings` <list of string> Additional keyrings to search in.
`homedir` <string> Override the configured homedir. | [
"data_path",
"<string",
">",
"The",
"path",
"to",
"the",
"data",
"to",
"verify",
".",
"sig_path",
"<string",
">",
"The",
"signature",
"file",
"if",
"detached",
"from",
"the",
"data",
".",
"keyrings",
"<list",
"of",
"string",
">",
"Additional",
"keyrings",
... | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/gpg.py#L89-L110 |
fedora-infra/fedmsg | fedmsg/core.py | FedMsgContext.destroy | def destroy(self):
""" Destroy a fedmsg context """
if getattr(self, 'publisher', None):
self.log.debug("closing fedmsg publisher")
self.log.debug("sent %i messages" % self._i)
self.publisher.close()
self.publisher = None
if getattr(self, 'contex... | python | def destroy(self):
""" Destroy a fedmsg context """
if getattr(self, 'publisher', None):
self.log.debug("closing fedmsg publisher")
self.log.debug("sent %i messages" % self._i)
self.publisher.close()
self.publisher = None
if getattr(self, 'contex... | [
"def",
"destroy",
"(",
"self",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"'publisher'",
",",
"None",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"closing fedmsg publisher\"",
")",
"self",
".",
"log",
".",
"debug",
"(",
"\"sent %i messages\"",
"... | Destroy a fedmsg context | [
"Destroy",
"a",
"fedmsg",
"context"
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/core.py#L173-L184 |
fedora-infra/fedmsg | fedmsg/core.py | FedMsgContext.publish | def publish(self, topic=None, msg=None, modname=None,
pre_fire_hook=None, **kw):
"""
Send a message over the publishing zeromq socket.
>>> import fedmsg
>>> fedmsg.publish(topic='testing', modname='test', msg={
... 'test': "Hello World",
... | python | def publish(self, topic=None, msg=None, modname=None,
pre_fire_hook=None, **kw):
"""
Send a message over the publishing zeromq socket.
>>> import fedmsg
>>> fedmsg.publish(topic='testing', modname='test', msg={
... 'test': "Hello World",
... | [
"def",
"publish",
"(",
"self",
",",
"topic",
"=",
"None",
",",
"msg",
"=",
"None",
",",
"modname",
"=",
"None",
",",
"pre_fire_hook",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"topic",
"=",
"topic",
"or",
"'unspecified'",
"msg",
"=",
"msg",
"or",... | Send a message over the publishing zeromq socket.
>>> import fedmsg
>>> fedmsg.publish(topic='testing', modname='test', msg={
... 'test': "Hello World",
... })
The above snippet will send the message ``'{test: "Hello World"}'``
over the ``<topic_pref... | [
"Send",
"a",
"message",
"over",
"the",
"publishing",
"zeromq",
"socket",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/core.py#L192-L343 |
fedora-infra/fedmsg | fedmsg/core.py | FedMsgContext.tail_messages | def tail_messages(self, topic="", passive=False, **kw):
"""
Subscribe to messages published on the sockets listed in :ref:`conf-endpoints`.
Args:
topic (six.text_type): The topic to subscribe to. The default is to
subscribe to all topics.
passive (bool): ... | python | def tail_messages(self, topic="", passive=False, **kw):
"""
Subscribe to messages published on the sockets listed in :ref:`conf-endpoints`.
Args:
topic (six.text_type): The topic to subscribe to. The default is to
subscribe to all topics.
passive (bool): ... | [
"def",
"tail_messages",
"(",
"self",
",",
"topic",
"=",
"\"\"",
",",
"passive",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"c",
".",
"get",
"(",
"'zmq_enabled'",
",",
"True",
")",
":",
"raise",
"ValueError",
"(",
"\"fedm... | Subscribe to messages published on the sockets listed in :ref:`conf-endpoints`.
Args:
topic (six.text_type): The topic to subscribe to. The default is to
subscribe to all topics.
passive (bool): If ``True``, bind to the :ref:`conf-endpoints` sockets
inste... | [
"Subscribe",
"to",
"messages",
"published",
"on",
"the",
"sockets",
"listed",
"in",
":",
"ref",
":",
"conf",
"-",
"endpoints",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/core.py#L345-L370 |
fedora-infra/fedmsg | fedmsg/crypto/x509_ng.py | sign | def sign(message, ssldir=None, certname=None, **config):
"""Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host.
Arg:
messag... | python | def sign(message, ssldir=None, certname=None, **config):
"""Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host.
Arg:
messag... | [
"def",
"sign",
"(",
"message",
",",
"ssldir",
"=",
"None",
",",
"certname",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"if",
"ssldir",
"is",
"None",
"or",
"certname",
"is",
"None",
":",
"error",
"=",
"\"You must set the ssldir and certname keyword argum... | Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host.
Arg:
message (dict): An unsigned message to sign.
ssldir (str): The... | [
"Insert",
"two",
"new",
"fields",
"into",
"the",
"message",
"dict",
"and",
"return",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509_ng.py#L53-L97 |
fedora-infra/fedmsg | fedmsg/crypto/x509_ng.py | _prep_crypto_msg | def _prep_crypto_msg(message):
"""Split the signature and certificate in the same way M2Crypto does.
M2Crypto is dropping newlines into its signature and certificate. This
exists purely to maintain backwards compatibility.
Args:
message (dict): A message with the ``signature`` and ``certificat... | python | def _prep_crypto_msg(message):
"""Split the signature and certificate in the same way M2Crypto does.
M2Crypto is dropping newlines into its signature and certificate. This
exists purely to maintain backwards compatibility.
Args:
message (dict): A message with the ``signature`` and ``certificat... | [
"def",
"_prep_crypto_msg",
"(",
"message",
")",
":",
"signature",
"=",
"message",
"[",
"'signature'",
"]",
"certificate",
"=",
"message",
"[",
"'certificate'",
"]",
"sliced_signature",
",",
"sliced_certificate",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"x",
"in"... | Split the signature and certificate in the same way M2Crypto does.
M2Crypto is dropping newlines into its signature and certificate. This
exists purely to maintain backwards compatibility.
Args:
message (dict): A message with the ``signature`` and ``certificate`` keywords.
The values o... | [
"Split",
"the",
"signature",
"and",
"certificate",
"in",
"the",
"same",
"way",
"M2Crypto",
"does",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509_ng.py#L100-L124 |
fedora-infra/fedmsg | fedmsg/crypto/x509_ng.py | validate | def validate(message, ssldir=None, **config):
"""
Validate the signature on the given message.
Four things must be true for the signature to be valid:
1) The X.509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA p... | python | def validate(message, ssldir=None, **config):
"""
Validate the signature on the given message.
Four things must be true for the signature to be valid:
1) The X.509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA p... | [
"def",
"validate",
"(",
"message",
",",
"ssldir",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"for",
"field",
"in",
"[",
"'signature'",
",",
"'certificate'",
"]",
":",
"if",
"field",
"not",
"in",
"message",
":",
"_log",
".",
"warn",
"(",
"'No %s ... | Validate the signature on the given message.
Four things must be true for the signature to be valid:
1) The X.509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA public key
contained in the X.509 cert.
4) T... | [
"Validate",
"the",
"signature",
"on",
"the",
"given",
"message",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509_ng.py#L127-L206 |
fedora-infra/fedmsg | fedmsg/crypto/x509_ng.py | _validate_signing_cert | def _validate_signing_cert(ca_certificate, certificate, crl=None):
"""
Validate an X509 certificate using pyOpenSSL.
.. note::
pyOpenSSL is a short-term solution to certificate validation. pyOpenSSL
is basically in maintenance mode and there's a desire in upstream to move
all the fu... | python | def _validate_signing_cert(ca_certificate, certificate, crl=None):
"""
Validate an X509 certificate using pyOpenSSL.
.. note::
pyOpenSSL is a short-term solution to certificate validation. pyOpenSSL
is basically in maintenance mode and there's a desire in upstream to move
all the fu... | [
"def",
"_validate_signing_cert",
"(",
"ca_certificate",
",",
"certificate",
",",
"crl",
"=",
"None",
")",
":",
"pyopenssl_cert",
"=",
"load_certificate",
"(",
"FILETYPE_PEM",
",",
"certificate",
")",
"pyopenssl_ca_cert",
"=",
"load_certificate",
"(",
"FILETYPE_PEM",
... | Validate an X509 certificate using pyOpenSSL.
.. note::
pyOpenSSL is a short-term solution to certificate validation. pyOpenSSL
is basically in maintenance mode and there's a desire in upstream to move
all the functionality into cryptography.
Args:
ca_certificate (str): A PEM-e... | [
"Validate",
"an",
"X509",
"certificate",
"using",
"pyOpenSSL",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509_ng.py#L209-L240 |
fedora-infra/fedmsg | fedmsg/consumers/ircbot.py | IRCBotConsumer.consume | def consume(self, msg):
""" Forward on messages from the bus to all IRC connections. """
log.debug("Got message %r" % msg)
topic, body = msg.get('topic'), msg.get('body')
for client in self.irc_clients:
if not client.factory.filters or (
client.factory.filter... | python | def consume(self, msg):
""" Forward on messages from the bus to all IRC connections. """
log.debug("Got message %r" % msg)
topic, body = msg.get('topic'), msg.get('body')
for client in self.irc_clients:
if not client.factory.filters or (
client.factory.filter... | [
"def",
"consume",
"(",
"self",
",",
"msg",
")",
":",
"log",
".",
"debug",
"(",
"\"Got message %r\"",
"%",
"msg",
")",
"topic",
",",
"body",
"=",
"msg",
".",
"get",
"(",
"'topic'",
")",
",",
"msg",
".",
"get",
"(",
"'body'",
")",
"for",
"client",
... | Forward on messages from the bus to all IRC connections. | [
"Forward",
"on",
"messages",
"from",
"the",
"bus",
"to",
"all",
"IRC",
"connections",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/consumers/ircbot.py#L352-L376 |
fedora-infra/fedmsg | fedmsg/commands/check.py | check | def check(timeout, consumer=None, producer=None):
"""This command is used to check the status of consumers and producers.
If no consumers and producers are provided, the status of all consumers and producers
is printed.
"""
# It's weird to say --consumers, but there are multiple, so rename the vari... | python | def check(timeout, consumer=None, producer=None):
"""This command is used to check the status of consumers and producers.
If no consumers and producers are provided, the status of all consumers and producers
is printed.
"""
# It's weird to say --consumers, but there are multiple, so rename the vari... | [
"def",
"check",
"(",
"timeout",
",",
"consumer",
"=",
"None",
",",
"producer",
"=",
"None",
")",
":",
"# It's weird to say --consumers, but there are multiple, so rename the variables",
"consumers",
",",
"producers",
"=",
"consumer",
",",
"producer",
"config",
"=",
"l... | This command is used to check the status of consumers and producers.
If no consumers and producers are provided, the status of all consumers and producers
is printed. | [
"This",
"command",
"is",
"used",
"to",
"check",
"the",
"status",
"of",
"consumers",
"and",
"producers",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/commands/check.py#L43-L97 |
fedora-infra/fedmsg | fedmsg/__init__.py | init | def init(**kw):
""" Initialize an instance of :class:`fedmsg.core.FedMsgContext`.
The config is loaded with :func:`fedmsg.config.load_config` and updated
by any keyword arguments. This config is used to initialize the context
object.
The object is stored in a thread local as
:data:`fedmsg.__l... | python | def init(**kw):
""" Initialize an instance of :class:`fedmsg.core.FedMsgContext`.
The config is loaded with :func:`fedmsg.config.load_config` and updated
by any keyword arguments. This config is used to initialize the context
object.
The object is stored in a thread local as
:data:`fedmsg.__l... | [
"def",
"init",
"(",
"*",
"*",
"kw",
")",
":",
"if",
"getattr",
"(",
"__local",
",",
"'__context'",
",",
"None",
")",
":",
"raise",
"ValueError",
"(",
"\"fedmsg already initialized\"",
")",
"# Read config from CLI args and a config file",
"config",
"=",
"fedmsg",
... | Initialize an instance of :class:`fedmsg.core.FedMsgContext`.
The config is loaded with :func:`fedmsg.config.load_config` and updated
by any keyword arguments. This config is used to initialize the context
object.
The object is stored in a thread local as
:data:`fedmsg.__local.__context`. | [
"Initialize",
"an",
"instance",
"of",
":",
"class",
":",
"fedmsg",
".",
"core",
".",
"FedMsgContext",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/__init__.py#L41-L62 |
fedora-infra/fedmsg | fedmsg/commands/collectd.py | CollectdConsumer.dump | def dump(self):
""" Called by CollectdProducer every `n` seconds. """
# Print out the collectd feedback.
# This is sent to stdout while other log messages are sent to stderr.
for k, v in sorted(self._dict.items()):
print(self.formatter(k, v))
# Reset each entry to z... | python | def dump(self):
""" Called by CollectdProducer every `n` seconds. """
# Print out the collectd feedback.
# This is sent to stdout while other log messages are sent to stderr.
for k, v in sorted(self._dict.items()):
print(self.formatter(k, v))
# Reset each entry to z... | [
"def",
"dump",
"(",
"self",
")",
":",
"# Print out the collectd feedback.",
"# This is sent to stdout while other log messages are sent to stderr.",
"for",
"k",
",",
"v",
"in",
"sorted",
"(",
"self",
".",
"_dict",
".",
"items",
"(",
")",
")",
":",
"print",
"(",
"s... | Called by CollectdProducer every `n` seconds. | [
"Called",
"by",
"CollectdProducer",
"every",
"n",
"seconds",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/commands/collectd.py#L51-L61 |
fedora-infra/fedmsg | fedmsg/commands/collectd.py | CollectdConsumer.formatter | def formatter(self, key, value):
""" Format messages for collectd to consume. """
template = "PUTVAL {host}/fedmsg/fedmsg_wallboard-{key} " +\
"interval={interval} {timestamp}:{value}"
timestamp = int(time.time())
interval = self.hub.config['collectd_interval']
return... | python | def formatter(self, key, value):
""" Format messages for collectd to consume. """
template = "PUTVAL {host}/fedmsg/fedmsg_wallboard-{key} " +\
"interval={interval} {timestamp}:{value}"
timestamp = int(time.time())
interval = self.hub.config['collectd_interval']
return... | [
"def",
"formatter",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"template",
"=",
"\"PUTVAL {host}/fedmsg/fedmsg_wallboard-{key} \"",
"+",
"\"interval={interval} {timestamp}:{value}\"",
"timestamp",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"interval"... | Format messages for collectd to consume. | [
"Format",
"messages",
"for",
"collectd",
"to",
"consume",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/commands/collectd.py#L63-L75 |
fedora-infra/fedmsg | fedmsg/crypto/__init__.py | init | def init(**config):
""" Initialize the crypto backend.
The backend can be one of two plugins:
- 'x509' - Uses x509 certificates.
- 'gpg' - Uses GnuPG keys.
"""
global _implementation
global _validate_implementations
if config.get('crypto_backend') == 'gpg':
_implementa... | python | def init(**config):
""" Initialize the crypto backend.
The backend can be one of two plugins:
- 'x509' - Uses x509 certificates.
- 'gpg' - Uses GnuPG keys.
"""
global _implementation
global _validate_implementations
if config.get('crypto_backend') == 'gpg':
_implementa... | [
"def",
"init",
"(",
"*",
"*",
"config",
")",
":",
"global",
"_implementation",
"global",
"_validate_implementations",
"if",
"config",
".",
"get",
"(",
"'crypto_backend'",
")",
"==",
"'gpg'",
":",
"_implementation",
"=",
"gpg",
"else",
":",
"_implementation",
"... | Initialize the crypto backend.
The backend can be one of two plugins:
- 'x509' - Uses x509 certificates.
- 'gpg' - Uses GnuPG keys. | [
"Initialize",
"the",
"crypto",
"backend",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/__init__.py#L166-L192 |
fedora-infra/fedmsg | fedmsg/crypto/__init__.py | sign | def sign(message, **config):
""" Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed message digest of the JSON repr.
- 'certificate' - the base64 certificate or gpg key of the signator.
"""
if not _implementation:
init(**c... | python | def sign(message, **config):
""" Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed message digest of the JSON repr.
- 'certificate' - the base64 certificate or gpg key of the signator.
"""
if not _implementation:
init(**c... | [
"def",
"sign",
"(",
"message",
",",
"*",
"*",
"config",
")",
":",
"if",
"not",
"_implementation",
":",
"init",
"(",
"*",
"*",
"config",
")",
"return",
"_implementation",
".",
"sign",
"(",
"message",
",",
"*",
"*",
"config",
")"
] | Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed message digest of the JSON repr.
- 'certificate' - the base64 certificate or gpg key of the signator. | [
"Insert",
"two",
"new",
"fields",
"into",
"the",
"message",
"dict",
"and",
"return",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/__init__.py#L195-L207 |
fedora-infra/fedmsg | fedmsg/crypto/__init__.py | validate | def validate(message, **config):
""" Return true or false if the message is signed appropriately. """
if not _validate_implementations:
init(**config)
cfg = copy.deepcopy(config)
if 'gpg_home' not in cfg:
cfg['gpg_home'] = os.path.expanduser('~/.gnupg/')
if 'ssldir' not in cfg:
... | python | def validate(message, **config):
""" Return true or false if the message is signed appropriately. """
if not _validate_implementations:
init(**config)
cfg = copy.deepcopy(config)
if 'gpg_home' not in cfg:
cfg['gpg_home'] = os.path.expanduser('~/.gnupg/')
if 'ssldir' not in cfg:
... | [
"def",
"validate",
"(",
"message",
",",
"*",
"*",
"config",
")",
":",
"if",
"not",
"_validate_implementations",
":",
"init",
"(",
"*",
"*",
"config",
")",
"cfg",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
")",
"if",
"'gpg_home'",
"not",
"in",
"cfg",
... | Return true or false if the message is signed appropriately. | [
"Return",
"true",
"or",
"false",
"if",
"the",
"message",
"is",
"signed",
"appropriately",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/__init__.py#L210-L247 |
fedora-infra/fedmsg | fedmsg/crypto/__init__.py | validate_signed_by | def validate_signed_by(message, signer, **config):
""" Validate that a message was signed by a particular certificate.
This works much like ``validate(...)``, but additionally accepts a
``signer`` argument. It will reject a message for any of the regular
circumstances, but will also reject it if its n... | python | def validate_signed_by(message, signer, **config):
""" Validate that a message was signed by a particular certificate.
This works much like ``validate(...)``, but additionally accepts a
``signer`` argument. It will reject a message for any of the regular
circumstances, but will also reject it if its n... | [
"def",
"validate_signed_by",
"(",
"message",
",",
"signer",
",",
"*",
"*",
"config",
")",
":",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"config",
")",
"config",
"[",
"'routing_nitpicky'",
"]",
"=",
"True",
"config",
"[",
"'routing_policy'",
"]",
"=",
... | Validate that a message was signed by a particular certificate.
This works much like ``validate(...)``, but additionally accepts a
``signer`` argument. It will reject a message for any of the regular
circumstances, but will also reject it if its not signed by a cert with the
argued name. | [
"Validate",
"that",
"a",
"message",
"was",
"signed",
"by",
"a",
"particular",
"certificate",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/__init__.py#L250-L262 |
fedora-infra/fedmsg | fedmsg/crypto/__init__.py | strip_credentials | def strip_credentials(message):
""" Strip credentials from a message dict.
A new dict is returned without either `signature` or `certificate` keys.
This method can be called safely; the original dict is not modified.
This function is applicable using either using the x509 or gpg backends.
"""
... | python | def strip_credentials(message):
""" Strip credentials from a message dict.
A new dict is returned without either `signature` or `certificate` keys.
This method can be called safely; the original dict is not modified.
This function is applicable using either using the x509 or gpg backends.
"""
... | [
"def",
"strip_credentials",
"(",
"message",
")",
":",
"message",
"=",
"copy",
".",
"deepcopy",
"(",
"message",
")",
"for",
"field",
"in",
"[",
"'signature'",
",",
"'certificate'",
"]",
":",
"if",
"field",
"in",
"message",
":",
"del",
"message",
"[",
"fie... | Strip credentials from a message dict.
A new dict is returned without either `signature` or `certificate` keys.
This method can be called safely; the original dict is not modified.
This function is applicable using either using the x509 or gpg backends. | [
"Strip",
"credentials",
"from",
"a",
"message",
"dict",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/__init__.py#L265-L277 |
fedora-infra/fedmsg | fedmsg/replay/__init__.py | get_replay | def get_replay(name, query, config, context=None):
"""
Query the replay endpoint for missed messages.
Args:
name (str): The replay endpoint name.
query (dict): A dictionary used to query the replay endpoint for messages.
Queries are dictionaries with the following any of the fol... | python | def get_replay(name, query, config, context=None):
"""
Query the replay endpoint for missed messages.
Args:
name (str): The replay endpoint name.
query (dict): A dictionary used to query the replay endpoint for messages.
Queries are dictionaries with the following any of the fol... | [
"def",
"get_replay",
"(",
"name",
",",
"query",
",",
"config",
",",
"context",
"=",
"None",
")",
":",
"endpoint",
"=",
"config",
".",
"get",
"(",
"'replay_endpoints'",
",",
"{",
"}",
")",
".",
"get",
"(",
"name",
",",
"None",
")",
"if",
"not",
"end... | Query the replay endpoint for missed messages.
Args:
name (str): The replay endpoint name.
query (dict): A dictionary used to query the replay endpoint for messages.
Queries are dictionaries with the following any of the following keys:
* 'seq_ids': A ``list`` of ``int``, m... | [
"Query",
"the",
"replay",
"endpoint",
"for",
"missed",
"messages",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/replay/__init__.py#L89-L150 |
fedora-infra/fedmsg | fedmsg/replay/__init__.py | check_for_replay | def check_for_replay(name, names_to_seq_id, msg, config, context=None):
"""
Check to see if messages need to be replayed.
Args:
name (str): The consumer's name.
names_to_seq_id (dict): A dictionary that maps names to the last seen sequence ID.
msg (dict): The latest message that has... | python | def check_for_replay(name, names_to_seq_id, msg, config, context=None):
"""
Check to see if messages need to be replayed.
Args:
name (str): The consumer's name.
names_to_seq_id (dict): A dictionary that maps names to the last seen sequence ID.
msg (dict): The latest message that has... | [
"def",
"check_for_replay",
"(",
"name",
",",
"names_to_seq_id",
",",
"msg",
",",
"config",
",",
"context",
"=",
"None",
")",
":",
"prev_seq_id",
"=",
"names_to_seq_id",
".",
"get",
"(",
"name",
",",
"None",
")",
"cur_seq_id",
"=",
"msg",
".",
"get",
"(",... | Check to see if messages need to be replayed.
Args:
name (str): The consumer's name.
names_to_seq_id (dict): A dictionary that maps names to the last seen sequence ID.
msg (dict): The latest message that has arrived.
config (dict): A configuration dictionary. This dictionary should ... | [
"Check",
"to",
"see",
"if",
"messages",
"need",
"to",
"be",
"replayed",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/replay/__init__.py#L153-L194 |
fedora-infra/fedmsg | fedmsg/crypto/utils.py | fix_datagrepper_message | def fix_datagrepper_message(message):
"""
See if a message is (probably) a datagrepper message and attempt to mutate
it to pass signature validation.
Datagrepper adds the 'source_name' and 'source_version' keys. If messages happen
to use those keys, they will fail message validation. Additionally, ... | python | def fix_datagrepper_message(message):
"""
See if a message is (probably) a datagrepper message and attempt to mutate
it to pass signature validation.
Datagrepper adds the 'source_name' and 'source_version' keys. If messages happen
to use those keys, they will fail message validation. Additionally, ... | [
"def",
"fix_datagrepper_message",
"(",
"message",
")",
":",
"if",
"not",
"(",
"'source_name'",
"in",
"message",
"and",
"'source_version'",
"in",
"message",
")",
":",
"return",
"message",
"# Don't mutate the original message",
"message",
"=",
"message",
".",
"copy",
... | See if a message is (probably) a datagrepper message and attempt to mutate
it to pass signature validation.
Datagrepper adds the 'source_name' and 'source_version' keys. If messages happen
to use those keys, they will fail message validation. Additionally, a 'headers'
dictionary is present on all respo... | [
"See",
"if",
"a",
"message",
"is",
"(",
"probably",
")",
"a",
"datagrepper",
"message",
"and",
"attempt",
"to",
"mutate",
"it",
"to",
"pass",
"signature",
"validation",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/utils.py#L11-L54 |
fedora-infra/fedmsg | fedmsg/crypto/utils.py | validate_policy | def validate_policy(topic, signer, routing_policy, nitpicky=False):
"""
Checks that the sender is allowed to emit messages for the given topic.
Args:
topic (str): The message topic the ``signer`` used when sending the message.
signer (str): The Common Name of the certificate used to sign th... | python | def validate_policy(topic, signer, routing_policy, nitpicky=False):
"""
Checks that the sender is allowed to emit messages for the given topic.
Args:
topic (str): The message topic the ``signer`` used when sending the message.
signer (str): The Common Name of the certificate used to sign th... | [
"def",
"validate_policy",
"(",
"topic",
",",
"signer",
",",
"routing_policy",
",",
"nitpicky",
"=",
"False",
")",
":",
"if",
"topic",
"in",
"routing_policy",
":",
"# If so.. is the signer one of those permitted senders?",
"if",
"signer",
"in",
"routing_policy",
"[",
... | Checks that the sender is allowed to emit messages for the given topic.
Args:
topic (str): The message topic the ``signer`` used when sending the message.
signer (str): The Common Name of the certificate used to sign the message.
Returns:
bool: True if the policy defined in the setting... | [
"Checks",
"that",
"the",
"sender",
"is",
"allowed",
"to",
"emit",
"messages",
"for",
"the",
"given",
"topic",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/utils.py#L57-L99 |
fedora-infra/fedmsg | fedmsg/crypto/utils.py | load_certificates | def load_certificates(ca_location, crl_location=None, invalidate_cache=False):
"""
Load the CA certificate and CRL, caching it for future use.
.. note::
Providing the location of the CA and CRL as an HTTPS URL is deprecated
and will be removed in a future release.
Args:
ca_loca... | python | def load_certificates(ca_location, crl_location=None, invalidate_cache=False):
"""
Load the CA certificate and CRL, caching it for future use.
.. note::
Providing the location of the CA and CRL as an HTTPS URL is deprecated
and will be removed in a future release.
Args:
ca_loca... | [
"def",
"load_certificates",
"(",
"ca_location",
",",
"crl_location",
"=",
"None",
",",
"invalidate_cache",
"=",
"False",
")",
":",
"if",
"crl_location",
"is",
"None",
":",
"crl_location",
"=",
"''",
"try",
":",
"if",
"invalidate_cache",
":",
"del",
"_cached_ce... | Load the CA certificate and CRL, caching it for future use.
.. note::
Providing the location of the CA and CRL as an HTTPS URL is deprecated
and will be removed in a future release.
Args:
ca_location (str): The location of the Certificate Authority certificate. This should
... | [
"Load",
"the",
"CA",
"certificate",
"and",
"CRL",
"caching",
"it",
"for",
"future",
"use",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/utils.py#L102-L144 |
fedora-infra/fedmsg | fedmsg/crypto/utils.py | _load_certificate | def _load_certificate(location):
"""
Load a certificate from the given location.
Args:
location (str): The location to load. This can either be an HTTPS URL or an absolute file
path. This is intended to be used with PEM-encoded certificates and therefore assumes
ASCII encodi... | python | def _load_certificate(location):
"""
Load a certificate from the given location.
Args:
location (str): The location to load. This can either be an HTTPS URL or an absolute file
path. This is intended to be used with PEM-encoded certificates and therefore assumes
ASCII encodi... | [
"def",
"_load_certificate",
"(",
"location",
")",
":",
"if",
"location",
".",
"startswith",
"(",
"'https://'",
")",
":",
"_log",
".",
"info",
"(",
"'Downloading x509 certificate from %s'",
",",
"location",
")",
"with",
"requests",
".",
"Session",
"(",
")",
"as... | Load a certificate from the given location.
Args:
location (str): The location to load. This can either be an HTTPS URL or an absolute file
path. This is intended to be used with PEM-encoded certificates and therefore assumes
ASCII encoding.
Returns:
str: The PEM-encode... | [
"Load",
"a",
"certificate",
"from",
"the",
"given",
"location",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/utils.py#L147-L173 |
fedora-infra/fedmsg | fedmsg/config.py | _get_config_files | def _get_config_files():
"""
Load the list of file paths for fedmsg configuration files.
Returns:
list: List of files containing fedmsg configuration.
"""
config_paths = []
if os.environ.get('FEDMSG_CONFIG'):
config_location = os.environ['FEDMSG_CONFIG']
else:
config... | python | def _get_config_files():
"""
Load the list of file paths for fedmsg configuration files.
Returns:
list: List of files containing fedmsg configuration.
"""
config_paths = []
if os.environ.get('FEDMSG_CONFIG'):
config_location = os.environ['FEDMSG_CONFIG']
else:
config... | [
"def",
"_get_config_files",
"(",
")",
":",
"config_paths",
"=",
"[",
"]",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'FEDMSG_CONFIG'",
")",
":",
"config_location",
"=",
"os",
".",
"environ",
"[",
"'FEDMSG_CONFIG'",
"]",
"else",
":",
"config_location",
"... | Load the list of file paths for fedmsg configuration files.
Returns:
list: List of files containing fedmsg configuration. | [
"Load",
"the",
"list",
"of",
"file",
"paths",
"for",
"fedmsg",
"configuration",
"files",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L741-L765 |
fedora-infra/fedmsg | fedmsg/config.py | _validate_none_or_type | def _validate_none_or_type(t):
"""
Create a validator that checks if a setting is either None or a given type.
Args:
t: The type to assert.
Returns:
callable: A callable that will validate a setting for that type.
"""
def _validate(setting):
"""
Check the settin... | python | def _validate_none_or_type(t):
"""
Create a validator that checks if a setting is either None or a given type.
Args:
t: The type to assert.
Returns:
callable: A callable that will validate a setting for that type.
"""
def _validate(setting):
"""
Check the settin... | [
"def",
"_validate_none_or_type",
"(",
"t",
")",
":",
"def",
"_validate",
"(",
"setting",
")",
":",
"\"\"\"\n Check the setting to make sure it's the right type.\n\n Args:\n setting (object): The setting to check.\n\n Returns:\n object: The unmodifie... | Create a validator that checks if a setting is either None or a given type.
Args:
t: The type to assert.
Returns:
callable: A callable that will validate a setting for that type. | [
"Create",
"a",
"validator",
"that",
"checks",
"if",
"a",
"setting",
"is",
"either",
"None",
"or",
"a",
"given",
"type",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L800-L826 |
fedora-infra/fedmsg | fedmsg/config.py | _validate_bool | def _validate_bool(value):
"""
Validate a setting is a bool.
Returns:
bool: The value as a boolean.
Raises:
ValueError: If the value can't be parsed as a bool string or isn't already bool.
"""
if isinstance(value, six.text_type):
if value.strip().lower() == 'true':
... | python | def _validate_bool(value):
"""
Validate a setting is a bool.
Returns:
bool: The value as a boolean.
Raises:
ValueError: If the value can't be parsed as a bool string or isn't already bool.
"""
if isinstance(value, six.text_type):
if value.strip().lower() == 'true':
... | [
"def",
"_validate_bool",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"if",
"value",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"==",
"'true'",
":",
"value",
"=",
"True",
"elif",
"value",
".... | Validate a setting is a bool.
Returns:
bool: The value as a boolean.
Raises:
ValueError: If the value can't be parsed as a bool string or isn't already bool. | [
"Validate",
"a",
"setting",
"is",
"a",
"bool",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L829-L850 |
fedora-infra/fedmsg | fedmsg/config.py | load_config | def load_config(extra_args=None,
doc=None,
filenames=None,
invalidate_cache=False,
fedmsg_command=False,
disable_defaults=False):
""" Setup a runtime config dict by integrating the following sources
(ordered by precedence):
-... | python | def load_config(extra_args=None,
doc=None,
filenames=None,
invalidate_cache=False,
fedmsg_command=False,
disable_defaults=False):
""" Setup a runtime config dict by integrating the following sources
(ordered by precedence):
-... | [
"def",
"load_config",
"(",
"extra_args",
"=",
"None",
",",
"doc",
"=",
"None",
",",
"filenames",
"=",
"None",
",",
"invalidate_cache",
"=",
"False",
",",
"fedmsg_command",
"=",
"False",
",",
"disable_defaults",
"=",
"False",
")",
":",
"warnings",
".",
"war... | Setup a runtime config dict by integrating the following sources
(ordered by precedence):
- defaults (unless disable_defaults = True)
- config file
- command line arguments
If the ``fedmsg_command`` argument is False, no command line arguments are
checked. | [
"Setup",
"a",
"runtime",
"config",
"dict",
"by",
"integrating",
"the",
"following",
"sources",
"(",
"ordered",
"by",
"precedence",
")",
":"
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1228-L1330 |
fedora-infra/fedmsg | fedmsg/config.py | build_parser | def build_parser(declared_args, doc, config=None, prog=None):
""" Return the global :class:`argparse.ArgumentParser` used by all fedmsg
commands.
Extra arguments can be supplied with the `declared_args` argument.
"""
config = config or copy.deepcopy(defaults)
prog = prog or sys.argv[0]
pa... | python | def build_parser(declared_args, doc, config=None, prog=None):
""" Return the global :class:`argparse.ArgumentParser` used by all fedmsg
commands.
Extra arguments can be supplied with the `declared_args` argument.
"""
config = config or copy.deepcopy(defaults)
prog = prog or sys.argv[0]
pa... | [
"def",
"build_parser",
"(",
"declared_args",
",",
"doc",
",",
"config",
"=",
"None",
",",
"prog",
"=",
"None",
")",
":",
"config",
"=",
"config",
"or",
"copy",
".",
"deepcopy",
"(",
"defaults",
")",
"prog",
"=",
"prog",
"or",
"sys",
".",
"argv",
"[",... | Return the global :class:`argparse.ArgumentParser` used by all fedmsg
commands.
Extra arguments can be supplied with the `declared_args` argument. | [
"Return",
"the",
"global",
":",
"class",
":",
"argparse",
".",
"ArgumentParser",
"used",
"by",
"all",
"fedmsg",
"commands",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1333-L1415 |
fedora-infra/fedmsg | fedmsg/config.py | _gather_configs_in | def _gather_configs_in(directory):
""" Return list of fully qualified python filenames in the given dir """
try:
return sorted([
os.path.join(directory, fname)
for fname in os.listdir(directory)
if fname.endswith('.py')
])
except OSError:
return [] | python | def _gather_configs_in(directory):
""" Return list of fully qualified python filenames in the given dir """
try:
return sorted([
os.path.join(directory, fname)
for fname in os.listdir(directory)
if fname.endswith('.py')
])
except OSError:
return [] | [
"def",
"_gather_configs_in",
"(",
"directory",
")",
":",
"try",
":",
"return",
"sorted",
"(",
"[",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"fname",
")",
"for",
"fname",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
"if",
"fname",
... | Return list of fully qualified python filenames in the given dir | [
"Return",
"list",
"of",
"fully",
"qualified",
"python",
"filenames",
"in",
"the",
"given",
"dir"
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1424-L1433 |
fedora-infra/fedmsg | fedmsg/config.py | _recursive_update | def _recursive_update(d1, d2):
""" Little helper function that does what d1.update(d2) does,
but works nice and recursively with dicts of dicts of dicts.
It's not necessarily very efficient.
"""
for k in set(d1).intersection(d2):
if isinstance(d1[k], dict) and isinstance(d2[k], dict):
... | python | def _recursive_update(d1, d2):
""" Little helper function that does what d1.update(d2) does,
but works nice and recursively with dicts of dicts of dicts.
It's not necessarily very efficient.
"""
for k in set(d1).intersection(d2):
if isinstance(d1[k], dict) and isinstance(d2[k], dict):
... | [
"def",
"_recursive_update",
"(",
"d1",
",",
"d2",
")",
":",
"for",
"k",
"in",
"set",
"(",
"d1",
")",
".",
"intersection",
"(",
"d2",
")",
":",
"if",
"isinstance",
"(",
"d1",
"[",
"k",
"]",
",",
"dict",
")",
"and",
"isinstance",
"(",
"d2",
"[",
... | Little helper function that does what d1.update(d2) does,
but works nice and recursively with dicts of dicts of dicts.
It's not necessarily very efficient. | [
"Little",
"helper",
"function",
"that",
"does",
"what",
"d1",
".",
"update",
"(",
"d2",
")",
"does",
"but",
"works",
"nice",
"and",
"recursively",
"with",
"dicts",
"of",
"dicts",
"of",
"dicts",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1436-L1452 |
fedora-infra/fedmsg | fedmsg/config.py | execfile | def execfile(fname, variables):
""" This is builtin in python2, but we have to roll our own on py3. """
with open(fname) as f:
code = compile(f.read(), fname, 'exec')
exec(code, variables) | python | def execfile(fname, variables):
""" This is builtin in python2, but we have to roll our own on py3. """
with open(fname) as f:
code = compile(f.read(), fname, 'exec')
exec(code, variables) | [
"def",
"execfile",
"(",
"fname",
",",
"variables",
")",
":",
"with",
"open",
"(",
"fname",
")",
"as",
"f",
":",
"code",
"=",
"compile",
"(",
"f",
".",
"read",
"(",
")",
",",
"fname",
",",
"'exec'",
")",
"exec",
"(",
"code",
",",
"variables",
")"
... | This is builtin in python2, but we have to roll our own on py3. | [
"This",
"is",
"builtin",
"in",
"python2",
"but",
"we",
"have",
"to",
"roll",
"our",
"own",
"on",
"py3",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1455-L1459 |
fedora-infra/fedmsg | fedmsg/config.py | FedmsgConfig.get | def get(self, *args, **kw):
"""Load the configuration if necessary and forward the call to the parent."""
if not self._loaded:
self.load_config()
return super(FedmsgConfig, self).get(*args, **kw) | python | def get(self, *args, **kw):
"""Load the configuration if necessary and forward the call to the parent."""
if not self._loaded:
self.load_config()
return super(FedmsgConfig, self).get(*args, **kw) | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_loaded",
":",
"self",
".",
"load_config",
"(",
")",
"return",
"super",
"(",
"FedmsgConfig",
",",
"self",
")",
".",
"get",
"(",
"*",
"args",
... | Load the configuration if necessary and forward the call to the parent. | [
"Load",
"the",
"configuration",
"if",
"necessary",
"and",
"forward",
"the",
"call",
"to",
"the",
"parent",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1118-L1122 |
fedora-infra/fedmsg | fedmsg/config.py | FedmsgConfig.copy | def copy(self, *args, **kw):
"""Load the configuration if necessary and forward the call to the parent."""
if not self._loaded:
self.load_config()
return super(FedmsgConfig, self).copy(*args, **kw) | python | def copy(self, *args, **kw):
"""Load the configuration if necessary and forward the call to the parent."""
if not self._loaded:
self.load_config()
return super(FedmsgConfig, self).copy(*args, **kw) | [
"def",
"copy",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"self",
".",
"_loaded",
":",
"self",
".",
"load_config",
"(",
")",
"return",
"super",
"(",
"FedmsgConfig",
",",
"self",
")",
".",
"copy",
"(",
"*",
"args",
... | Load the configuration if necessary and forward the call to the parent. | [
"Load",
"the",
"configuration",
"if",
"necessary",
"and",
"forward",
"the",
"call",
"to",
"the",
"parent",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1124-L1128 |
fedora-infra/fedmsg | fedmsg/config.py | FedmsgConfig.load_config | def load_config(self, settings=None):
"""
Load the configuration either from the config file, or from the given settings.
Args:
settings (dict): If given, the settings are pulled from this dictionary. Otherwise, the
config file is used.
"""
self._load... | python | def load_config(self, settings=None):
"""
Load the configuration either from the config file, or from the given settings.
Args:
settings (dict): If given, the settings are pulled from this dictionary. Otherwise, the
config file is used.
"""
self._load... | [
"def",
"load_config",
"(",
"self",
",",
"settings",
"=",
"None",
")",
":",
"self",
".",
"_load_defaults",
"(",
")",
"if",
"settings",
":",
"self",
".",
"update",
"(",
"settings",
")",
"else",
":",
"config_paths",
"=",
"_get_config_files",
"(",
")",
"for"... | Load the configuration either from the config file, or from the given settings.
Args:
settings (dict): If given, the settings are pulled from this dictionary. Otherwise, the
config file is used. | [
"Load",
"the",
"configuration",
"either",
"from",
"the",
"config",
"file",
"or",
"from",
"the",
"given",
"settings",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1130-L1147 |
fedora-infra/fedmsg | fedmsg/config.py | FedmsgConfig._load_defaults | def _load_defaults(self):
"""Iterate over self._defaults and set all default values on self."""
for k, v in self._defaults.items():
self[k] = v['default'] | python | def _load_defaults(self):
"""Iterate over self._defaults and set all default values on self."""
for k, v in self._defaults.items():
self[k] = v['default'] | [
"def",
"_load_defaults",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_defaults",
".",
"items",
"(",
")",
":",
"self",
"[",
"k",
"]",
"=",
"v",
"[",
"'default'",
"]"
] | Iterate over self._defaults and set all default values on self. | [
"Iterate",
"over",
"self",
".",
"_defaults",
"and",
"set",
"all",
"default",
"values",
"on",
"self",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1149-L1152 |
fedora-infra/fedmsg | fedmsg/config.py | FedmsgConfig._validate | def _validate(self):
"""
Run the validators found in self._defaults on all the corresponding values.
Raises:
ValueError: If the configuration contains an invalid configuration value.
"""
errors = []
for k in self._defaults.keys():
try:
... | python | def _validate(self):
"""
Run the validators found in self._defaults on all the corresponding values.
Raises:
ValueError: If the configuration contains an invalid configuration value.
"""
errors = []
for k in self._defaults.keys():
try:
... | [
"def",
"_validate",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"k",
"in",
"self",
".",
"_defaults",
".",
"keys",
"(",
")",
":",
"try",
":",
"validator",
"=",
"self",
".",
"_defaults",
"[",
"k",
"]",
"[",
"'validator'",
"]",
"if",
"val... | Run the validators found in self._defaults on all the corresponding values.
Raises:
ValueError: If the configuration contains an invalid configuration value. | [
"Run",
"the",
"validators",
"found",
"in",
"self",
".",
"_defaults",
"on",
"all",
"the",
"corresponding",
"values",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/config.py#L1154-L1172 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | make_processors | def make_processors(**config):
""" Initialize all of the text processors.
You'll need to call this once before using any of the other functions in
this module.
>>> import fedmsg.config
>>> import fedmsg.meta
>>> config = fedmsg.config.load_config([], None)
>>> fedmsg.meta.m... | python | def make_processors(**config):
""" Initialize all of the text processors.
You'll need to call this once before using any of the other functions in
this module.
>>> import fedmsg.config
>>> import fedmsg.meta
>>> config = fedmsg.config.load_config([], None)
>>> fedmsg.meta.m... | [
"def",
"make_processors",
"(",
"*",
"*",
"config",
")",
":",
"global",
"processors",
"# If they're already initialized, then fine.",
"if",
"processors",
":",
"return",
"import",
"pkg_resources",
"processors",
"=",
"[",
"]",
"for",
"processor",
"in",
"pkg_resources",
... | Initialize all of the text processors.
You'll need to call this once before using any of the other functions in
this module.
>>> import fedmsg.config
>>> import fedmsg.meta
>>> config = fedmsg.config.load_config([], None)
>>> fedmsg.meta.make_processors(**config)
>>> te... | [
"Initialize",
"all",
"of",
"the",
"text",
"processors",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L88-L124 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2processor | def msg2processor(msg, **config):
""" For a given message return the text processor that can handle it.
This will raise a :class:`fedmsg.meta.ProcessorsNotInitialized` exception
if :func:`fedmsg.meta.make_processors` hasn't been called yet.
"""
for processor in processors:
if processor.hand... | python | def msg2processor(msg, **config):
""" For a given message return the text processor that can handle it.
This will raise a :class:`fedmsg.meta.ProcessorsNotInitialized` exception
if :func:`fedmsg.meta.make_processors` hasn't been called yet.
"""
for processor in processors:
if processor.hand... | [
"def",
"msg2processor",
"(",
"msg",
",",
"*",
"*",
"config",
")",
":",
"for",
"processor",
"in",
"processors",
":",
"if",
"processor",
".",
"handle_msg",
"(",
"msg",
",",
"*",
"*",
"config",
")",
"is",
"not",
"None",
":",
"return",
"processor",
"else",... | For a given message return the text processor that can handle it.
This will raise a :class:`fedmsg.meta.ProcessorsNotInitialized` exception
if :func:`fedmsg.meta.make_processors` hasn't been called yet. | [
"For",
"a",
"given",
"message",
"return",
"the",
"text",
"processor",
"that",
"can",
"handle",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L127-L137 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | graceful | def graceful(cls):
""" A decorator to protect against message structure changes.
Many of our processors expect messages to be in a certain format. If the
format changes, they may start to fail and raise exceptions. This decorator
is in place to catch and log those exceptions and to gracefully return
... | python | def graceful(cls):
""" A decorator to protect against message structure changes.
Many of our processors expect messages to be in a certain format. If the
format changes, they may start to fail and raise exceptions. This decorator
is in place to catch and log those exceptions and to gracefully return
... | [
"def",
"graceful",
"(",
"cls",
")",
":",
"def",
"_wrapper",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"__wrapper",
"(",
"msg",
",",
"*",
"*",
"config",
")",
":",
"try",
":",
"return",
"f",
"(",
"msg",
",",
"*",
... | A decorator to protect against message structure changes.
Many of our processors expect messages to be in a certain format. If the
format changes, they may start to fail and raise exceptions. This decorator
is in place to catch and log those exceptions and to gracefully return
default values. | [
"A",
"decorator",
"to",
"protect",
"against",
"message",
"structure",
"changes",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L140-L158 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | conglomerate | def conglomerate(messages, subject=None, lexers=False, **config):
""" Return a list of messages with some of them grouped into conglomerate
messages. Conglomerate messages represent several other messages.
For example, you might pass this function a list of 40 messages.
38 of those are git.commit mess... | python | def conglomerate(messages, subject=None, lexers=False, **config):
""" Return a list of messages with some of them grouped into conglomerate
messages. Conglomerate messages represent several other messages.
For example, you might pass this function a list of 40 messages.
38 of those are git.commit mess... | [
"def",
"conglomerate",
"(",
"messages",
",",
"subject",
"=",
"None",
",",
"lexers",
"=",
"False",
",",
"*",
"*",
"config",
")",
":",
"# First, give every registered processor a chance to do its work",
"for",
"processor",
"in",
"processors",
":",
"messages",
"=",
"... | Return a list of messages with some of them grouped into conglomerate
messages. Conglomerate messages represent several other messages.
For example, you might pass this function a list of 40 messages.
38 of those are git.commit messages, 1 is a bodhi.update message, and 1 is
a badge.award message. Th... | [
"Return",
"a",
"list",
"of",
"messages",
"with",
"some",
"of",
"them",
"grouped",
"into",
"conglomerate",
"messages",
".",
"Conglomerate",
"messages",
"represent",
"several",
"other",
"messages",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L179-L217 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2repr | def msg2repr(msg, processor, **config):
""" Return a human-readable or "natural language" representation of a
dict-like fedmsg message. Think of this as the 'top-most level' function
in this module.
"""
fmt = u"{title} -- {subtitle} {link}"
title = msg2title(msg, **config)
subtitle = proce... | python | def msg2repr(msg, processor, **config):
""" Return a human-readable or "natural language" representation of a
dict-like fedmsg message. Think of this as the 'top-most level' function
in this module.
"""
fmt = u"{title} -- {subtitle} {link}"
title = msg2title(msg, **config)
subtitle = proce... | [
"def",
"msg2repr",
"(",
"msg",
",",
"processor",
",",
"*",
"*",
"config",
")",
":",
"fmt",
"=",
"u\"{title} -- {subtitle} {link}\"",
"title",
"=",
"msg2title",
"(",
"msg",
",",
"*",
"*",
"config",
")",
"subtitle",
"=",
"processor",
".",
"subtitle",
"(",
... | Return a human-readable or "natural language" representation of a
dict-like fedmsg message. Think of this as the 'top-most level' function
in this module. | [
"Return",
"a",
"human",
"-",
"readable",
"or",
"natural",
"language",
"representation",
"of",
"a",
"dict",
"-",
"like",
"fedmsg",
"message",
".",
"Think",
"of",
"this",
"as",
"the",
"top",
"-",
"most",
"level",
"function",
"in",
"this",
"module",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L222-L232 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2long_form | def msg2long_form(msg, processor, **config):
""" Return a 'long form' text representation of a message.
For most message, this will just default to the terse subtitle, but for
some messages a long paragraph-structured block of text may be returned.
"""
result = processor.long_form(msg, **config)
... | python | def msg2long_form(msg, processor, **config):
""" Return a 'long form' text representation of a message.
For most message, this will just default to the terse subtitle, but for
some messages a long paragraph-structured block of text may be returned.
"""
result = processor.long_form(msg, **config)
... | [
"def",
"msg2long_form",
"(",
"msg",
",",
"processor",
",",
"*",
"*",
"config",
")",
":",
"result",
"=",
"processor",
".",
"long_form",
"(",
"msg",
",",
"*",
"*",
"config",
")",
"if",
"not",
"result",
":",
"result",
"=",
"processor",
".",
"subtitle",
... | Return a 'long form' text representation of a message.
For most message, this will just default to the terse subtitle, but for
some messages a long paragraph-structured block of text may be returned. | [
"Return",
"a",
"long",
"form",
"text",
"representation",
"of",
"a",
"message",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L251-L260 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2usernames | def msg2usernames(msg, processor=None, legacy=False, **config):
""" Return a set of FAS usernames associated with a message. """
return processor.usernames(msg, **config) | python | def msg2usernames(msg, processor=None, legacy=False, **config):
""" Return a set of FAS usernames associated with a message. """
return processor.usernames(msg, **config) | [
"def",
"msg2usernames",
"(",
"msg",
",",
"processor",
"=",
"None",
",",
"legacy",
"=",
"False",
",",
"*",
"*",
"config",
")",
":",
"return",
"processor",
".",
"usernames",
"(",
"msg",
",",
"*",
"*",
"config",
")"
] | Return a set of FAS usernames associated with a message. | [
"Return",
"a",
"set",
"of",
"FAS",
"usernames",
"associated",
"with",
"a",
"message",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L293-L295 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2agent | def msg2agent(msg, processor=None, legacy=False, **config):
""" Return the single username who is the "agent" for an event.
An "agent" is the one responsible for the event taking place, for example,
if one person gives karma to another, then both usernames are returned by
msg2usernames, but only the on... | python | def msg2agent(msg, processor=None, legacy=False, **config):
""" Return the single username who is the "agent" for an event.
An "agent" is the one responsible for the event taking place, for example,
if one person gives karma to another, then both usernames are returned by
msg2usernames, but only the on... | [
"def",
"msg2agent",
"(",
"msg",
",",
"processor",
"=",
"None",
",",
"legacy",
"=",
"False",
",",
"*",
"*",
"config",
")",
":",
"if",
"processor",
".",
"agent",
"is",
"not",
"NotImplemented",
":",
"return",
"processor",
".",
"agent",
"(",
"msg",
",",
... | Return the single username who is the "agent" for an event.
An "agent" is the one responsible for the event taking place, for example,
if one person gives karma to another, then both usernames are returned by
msg2usernames, but only the one who gave the karma is returned by
msg2agent.
If the proce... | [
"Return",
"the",
"single",
"username",
"who",
"is",
"the",
"agent",
"for",
"an",
"event",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L299-L325 |
fedora-infra/fedmsg | fedmsg/meta/__init__.py | msg2subjective | def msg2subjective(msg, processor, subject, **config):
""" Return a human-readable text representation of a dict-like
fedmsg message from the subjective perspective of a user.
For example, if the subject viewing the message is "oddshocks"
and the message would normally translate into "oddshocks comment... | python | def msg2subjective(msg, processor, subject, **config):
""" Return a human-readable text representation of a dict-like
fedmsg message from the subjective perspective of a user.
For example, if the subject viewing the message is "oddshocks"
and the message would normally translate into "oddshocks comment... | [
"def",
"msg2subjective",
"(",
"msg",
",",
"processor",
",",
"subject",
",",
"*",
"*",
"config",
")",
":",
"text",
"=",
"processor",
".",
"subjective",
"(",
"msg",
",",
"subject",
",",
"*",
"*",
"config",
")",
"if",
"not",
"text",
":",
"text",
"=",
... | Return a human-readable text representation of a dict-like
fedmsg message from the subjective perspective of a user.
For example, if the subject viewing the message is "oddshocks"
and the message would normally translate into "oddshocks commented on
ticket #174", it would instead translate into "you co... | [
"Return",
"a",
"human",
"-",
"readable",
"text",
"representation",
"of",
"a",
"dict",
"-",
"like",
"fedmsg",
"message",
"from",
"the",
"subjective",
"perspective",
"of",
"a",
"user",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/__init__.py#L366-L377 |
fedora-infra/fedmsg | fedmsg/commands/trigger.py | TriggerCommand.run_command | def run_command(self, command, message):
""" Use subprocess; feed the message to our command over stdin """
proc = subprocess.Popen([
'echo \'%s\' | %s' % (fedmsg.encoding.dumps(message), command)
], shell=True, executable='/bin/bash')
return proc.wait() | python | def run_command(self, command, message):
""" Use subprocess; feed the message to our command over stdin """
proc = subprocess.Popen([
'echo \'%s\' | %s' % (fedmsg.encoding.dumps(message), command)
], shell=True, executable='/bin/bash')
return proc.wait() | [
"def",
"run_command",
"(",
"self",
",",
"command",
",",
"message",
")",
":",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'echo \\'%s\\' | %s'",
"%",
"(",
"fedmsg",
".",
"encoding",
".",
"dumps",
"(",
"message",
")",
",",
"command",
")",
"]",
",... | Use subprocess; feed the message to our command over stdin | [
"Use",
"subprocess",
";",
"feed",
"the",
"message",
"to",
"our",
"command",
"over",
"stdin"
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/commands/trigger.py#L76-L81 |
fedora-infra/fedmsg | fedmsg/crypto/x509.py | _m2crypto_sign | def _m2crypto_sign(message, ssldir=None, certname=None, **config):
""" Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host.
"""
i... | python | def _m2crypto_sign(message, ssldir=None, certname=None, **config):
""" Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host.
"""
i... | [
"def",
"_m2crypto_sign",
"(",
"message",
",",
"ssldir",
"=",
"None",
",",
"certname",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"if",
"ssldir",
"is",
"None",
"or",
"certname",
"is",
"None",
":",
"error",
"=",
"\"You must set the ssldir and certname key... | Insert two new fields into the message dict and return it.
Those fields are:
- 'signature' - the computed RSA message digest of the JSON repr.
- 'certificate' - the base64 X509 certificate of the sending host. | [
"Insert",
"two",
"new",
"fields",
"into",
"the",
"message",
"dict",
"and",
"return",
"it",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509.py#L61-L91 |
fedora-infra/fedmsg | fedmsg/crypto/x509.py | _m2crypto_validate | def _m2crypto_validate(message, ssldir=None, **config):
""" Return true or false if the message is signed appropriately.
Four things must be true:
1) The X509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA public key... | python | def _m2crypto_validate(message, ssldir=None, **config):
""" Return true or false if the message is signed appropriately.
Four things must be true:
1) The X509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA public key... | [
"def",
"_m2crypto_validate",
"(",
"message",
",",
"ssldir",
"=",
"None",
",",
"*",
"*",
"config",
")",
":",
"if",
"ssldir",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"You must set the ssldir keyword argument.\"",
")",
"def",
"fail",
"(",
"reason",
")",
... | Return true or false if the message is signed appropriately.
Four things must be true:
1) The X509 cert must be signed by our CA
2) The cert must not be in our CRL.
3) We must be able to verify the signature using the RSA public key
contained in the X509 cert.
4) The topic of the ... | [
"Return",
"true",
"or",
"false",
"if",
"the",
"message",
"is",
"signed",
"appropriately",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/crypto/x509.py#L94-L225 |
fedora-infra/fedmsg | fedmsg/meta/base.py | BaseProcessor.conglomerate | def conglomerate(self, messages, **config):
""" Given N messages, return another list that has some of them
grouped together into a common 'item'.
A conglomeration of messages should be of the following form::
{
'subtitle': 'relrod pushed commits to ghc and 487 other pack... | python | def conglomerate(self, messages, **config):
""" Given N messages, return another list that has some of them
grouped together into a common 'item'.
A conglomeration of messages should be of the following form::
{
'subtitle': 'relrod pushed commits to ghc and 487 other pack... | [
"def",
"conglomerate",
"(",
"self",
",",
"messages",
",",
"*",
"*",
"config",
")",
":",
"for",
"conglomerator",
"in",
"self",
".",
"conglomerator_objects",
":",
"messages",
"=",
"conglomerator",
".",
"conglomerate",
"(",
"messages",
",",
"*",
"*",
"config",
... | Given N messages, return another list that has some of them
grouped together into a common 'item'.
A conglomeration of messages should be of the following form::
{
'subtitle': 'relrod pushed commits to ghc and 487 other packages',
'link': None, # This could be someth... | [
"Given",
"N",
"messages",
"return",
"another",
"list",
"that",
"has",
"some",
"of",
"them",
"grouped",
"together",
"into",
"a",
"common",
"item",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/base.py#L103-L144 |
fedora-infra/fedmsg | fedmsg/meta/base.py | BaseProcessor.handle_msg | def handle_msg(self, msg, **config):
"""
If we can handle the given message, return the remainder of the topic.
Returns None if we can't handle the message.
"""
match = self.__prefix__.match(msg['topic'])
if match:
return match.groups()[-1] or "" | python | def handle_msg(self, msg, **config):
"""
If we can handle the given message, return the remainder of the topic.
Returns None if we can't handle the message.
"""
match = self.__prefix__.match(msg['topic'])
if match:
return match.groups()[-1] or "" | [
"def",
"handle_msg",
"(",
"self",
",",
"msg",
",",
"*",
"*",
"config",
")",
":",
"match",
"=",
"self",
".",
"__prefix__",
".",
"match",
"(",
"msg",
"[",
"'topic'",
"]",
")",
"if",
"match",
":",
"return",
"match",
".",
"groups",
"(",
")",
"[",
"-"... | If we can handle the given message, return the remainder of the topic.
Returns None if we can't handle the message. | [
"If",
"we",
"can",
"handle",
"the",
"given",
"message",
"return",
"the",
"remainder",
"of",
"the",
"topic",
"."
] | train | https://github.com/fedora-infra/fedmsg/blob/c21d6b3ce023fc3c0e881c704f5b55fb6e6392d7/fedmsg/meta/base.py#L146-L154 |
necaris/python3-openid | openid/extensions/draft/pape2.py | Request.parseExtensionArgs | def parseExtensionArgs(self, args):
"""Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace
@rtype: None
@raises ValueError: When the max_auth_age is not parseable as
an integer
"""
... | python | def parseExtensionArgs(self, args):
"""Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace
@rtype: None
@raises ValueError: When the max_auth_age is not parseable as
an integer
"""
... | [
"def",
"parseExtensionArgs",
"(",
"self",
",",
"args",
")",
":",
"# preferred_auth_policies is a space-separated list of policy URIs",
"self",
".",
"preferred_auth_policies",
"=",
"[",
"]",
"policies_str",
"=",
"args",
".",
"get",
"(",
"'preferred_auth_policies'",
")",
... | Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace
@rtype: None
@raises ValueError: When the max_auth_age is not parseable as
an integer | [
"Set",
"the",
"state",
"of",
"this",
"request",
"to",
"be",
"that",
"expressed",
"in",
"these",
"PAPE",
"arguments"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/draft/pape2.py#L101-L132 |
necaris/python3-openid | openid/consumer/consumer.py | Consumer.begin | def begin(self, user_url, anonymous=False):
"""Start the OpenID authentication process. See steps 1-2 in
the overview at the top of this file.
@param user_url: Identity URL given by the user. This method
performs a textual transformation of the URL to try and
make sure i... | python | def begin(self, user_url, anonymous=False):
"""Start the OpenID authentication process. See steps 1-2 in
the overview at the top of this file.
@param user_url: Identity URL given by the user. This method
performs a textual transformation of the URL to try and
make sure i... | [
"def",
"begin",
"(",
"self",
",",
"user_url",
",",
"anonymous",
"=",
"False",
")",
":",
"disco",
"=",
"Discovery",
"(",
"self",
".",
"session",
",",
"user_url",
",",
"self",
".",
"session_key_prefix",
")",
"try",
":",
"service",
"=",
"disco",
".",
"get... | Start the OpenID authentication process. See steps 1-2 in
the overview at the top of this file.
@param user_url: Identity URL given by the user. This method
performs a textual transformation of the URL to try and
make sure it is normalized. For example, a user_url of
... | [
"Start",
"the",
"OpenID",
"authentication",
"process",
".",
"See",
"steps",
"1",
"-",
"2",
"in",
"the",
"overview",
"at",
"the",
"top",
"of",
"this",
"file",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L312-L359 |
necaris/python3-openid | openid/consumer/consumer.py | Consumer.beginWithoutDiscovery | def beginWithoutDiscovery(self, service, anonymous=False):
"""Start OpenID verification without doing OpenID server
discovery. This method is used internally by Consumer.begin
after discovery is performed, and exists to provide an
interface for library users needing to perform their own
... | python | def beginWithoutDiscovery(self, service, anonymous=False):
"""Start OpenID verification without doing OpenID server
discovery. This method is used internally by Consumer.begin
after discovery is performed, and exists to provide an
interface for library users needing to perform their own
... | [
"def",
"beginWithoutDiscovery",
"(",
"self",
",",
"service",
",",
"anonymous",
"=",
"False",
")",
":",
"auth_req",
"=",
"self",
".",
"consumer",
".",
"begin",
"(",
"service",
")",
"self",
".",
"session",
"[",
"self",
".",
"_token_key",
"]",
"=",
"auth_re... | Start OpenID verification without doing OpenID server
discovery. This method is used internally by Consumer.begin
after discovery is performed, and exists to provide an
interface for library users needing to perform their own
discovery.
@param service: an OpenID service endpoint... | [
"Start",
"OpenID",
"verification",
"without",
"doing",
"OpenID",
"server",
"discovery",
".",
"This",
"method",
"is",
"used",
"internally",
"by",
"Consumer",
".",
"begin",
"after",
"discovery",
"is",
"performed",
"and",
"exists",
"to",
"provide",
"an",
"interface... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L361-L390 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._checkReturnTo | def _checkReturnTo(self, message, return_to):
"""Check an OpenID message and its openid.return_to value
against a return_to URL from an application. Return True on
success, False on failure.
"""
# Check the openid.return_to args against args in the original
# message.
... | python | def _checkReturnTo(self, message, return_to):
"""Check an OpenID message and its openid.return_to value
against a return_to URL from an application. Return True on
success, False on failure.
"""
# Check the openid.return_to args against args in the original
# message.
... | [
"def",
"_checkReturnTo",
"(",
"self",
",",
"message",
",",
"return_to",
")",
":",
"# Check the openid.return_to args against args in the original",
"# message.",
"try",
":",
"self",
".",
"_verifyReturnToArgs",
"(",
"message",
".",
"toPostArgs",
"(",
")",
")",
"except"... | Check an OpenID message and its openid.return_to value
against a return_to URL from an application. Return True on
success, False on failure. | [
"Check",
"an",
"OpenID",
"message",
"and",
"its",
"openid",
".",
"return_to",
"value",
"against",
"a",
"return_to",
"URL",
"from",
"an",
"application",
".",
"Return",
"True",
"on",
"success",
"False",
"on",
"failure",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L665-L692 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._verifyDiscoveredServices | def _verifyDiscoveredServices(self, claimed_id, services,
to_match_endpoints):
"""See @L{_discoverAndVerify}"""
# Search the services resulting from discovery to find one
# that matches the information from the assertion
failure_messages = []
fo... | python | def _verifyDiscoveredServices(self, claimed_id, services,
to_match_endpoints):
"""See @L{_discoverAndVerify}"""
# Search the services resulting from discovery to find one
# that matches the information from the assertion
failure_messages = []
fo... | [
"def",
"_verifyDiscoveredServices",
"(",
"self",
",",
"claimed_id",
",",
"services",
",",
"to_match_endpoints",
")",
":",
"# Search the services resulting from discovery to find one",
"# that matches the information from the assertion",
"failure_messages",
"=",
"[",
"]",
"for",
... | See @L{_discoverAndVerify} | [
"See"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L1077-L1102 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._checkAuth | def _checkAuth(self, message, server_url):
"""Make a check_authentication request to verify this message.
@returns: True if the request is valid.
@rtype: bool
"""
logging.info('Using OpenID check_authentication')
request = self._createCheckAuthRequest(message)
if... | python | def _checkAuth(self, message, server_url):
"""Make a check_authentication request to verify this message.
@returns: True if the request is valid.
@rtype: bool
"""
logging.info('Using OpenID check_authentication')
request = self._createCheckAuthRequest(message)
if... | [
"def",
"_checkAuth",
"(",
"self",
",",
"message",
",",
"server_url",
")",
":",
"logging",
".",
"info",
"(",
"'Using OpenID check_authentication'",
")",
"request",
"=",
"self",
".",
"_createCheckAuthRequest",
"(",
"message",
")",
"if",
"request",
"is",
"None",
... | Make a check_authentication request to verify this message.
@returns: True if the request is valid.
@rtype: bool | [
"Make",
"a",
"check_authentication",
"request",
"to",
"verify",
"this",
"message",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L1104-L1121 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._createCheckAuthRequest | def _createCheckAuthRequest(self, message):
"""Generate a check_authentication request message given an
id_res message.
"""
signed = message.getArg(OPENID_NS, 'signed')
if signed:
if isinstance(signed, bytes):
signed = str(signed, encoding="utf-8")
... | python | def _createCheckAuthRequest(self, message):
"""Generate a check_authentication request message given an
id_res message.
"""
signed = message.getArg(OPENID_NS, 'signed')
if signed:
if isinstance(signed, bytes):
signed = str(signed, encoding="utf-8")
... | [
"def",
"_createCheckAuthRequest",
"(",
"self",
",",
"message",
")",
":",
"signed",
"=",
"message",
".",
"getArg",
"(",
"OPENID_NS",
",",
"'signed'",
")",
"if",
"signed",
":",
"if",
"isinstance",
"(",
"signed",
",",
"bytes",
")",
":",
"signed",
"=",
"str"... | Generate a check_authentication request message given an
id_res message. | [
"Generate",
"a",
"check_authentication",
"request",
"message",
"given",
"an",
"id_res",
"message",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L1123-L1142 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._negotiateAssociation | def _negotiateAssociation(self, endpoint):
"""Make association requests to the server, attempting to
create a new association.
@returns: a new association object
@rtype: L{openid.association.Association}
"""
# Get our preferred session/association type from the negotiat... | python | def _negotiateAssociation(self, endpoint):
"""Make association requests to the server, attempting to
create a new association.
@returns: a new association object
@rtype: L{openid.association.Association}
"""
# Get our preferred session/association type from the negotiat... | [
"def",
"_negotiateAssociation",
"(",
"self",
",",
"endpoint",
")",
":",
"# Get our preferred session/association type from the negotiatior.",
"assoc_type",
",",
"session_type",
"=",
"self",
".",
"negotiator",
".",
"getAllowedType",
"(",
")",
"try",
":",
"assoc",
"=",
... | Make association requests to the server, attempting to
create a new association.
@returns: a new association object
@rtype: L{openid.association.Association} | [
"Make",
"association",
"requests",
"to",
"the",
"server",
"attempting",
"to",
"create",
"a",
"new",
"association",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L1187-L1223 |
necaris/python3-openid | openid/consumer/consumer.py | GenericConsumer._getOpenID1SessionType | def _getOpenID1SessionType(self, assoc_response):
"""Given an association response message, extract the OpenID
1.X session type.
This function mostly takes care of the 'no-encryption' default
behavior in OpenID 1.
If the association type is plain-text, this function will
... | python | def _getOpenID1SessionType(self, assoc_response):
"""Given an association response message, extract the OpenID
1.X session type.
This function mostly takes care of the 'no-encryption' default
behavior in OpenID 1.
If the association type is plain-text, this function will
... | [
"def",
"_getOpenID1SessionType",
"(",
"self",
",",
"assoc_response",
")",
":",
"# If it's an OpenID 1 message, allow session_type to default",
"# to None (which signifies \"no-encryption\")",
"session_type",
"=",
"assoc_response",
".",
"getArg",
"(",
"OPENID1_NS",
",",
"'session_... | Given an association response message, extract the OpenID
1.X session type.
This function mostly takes care of the 'no-encryption' default
behavior in OpenID 1.
If the association type is plain-text, this function will
return 'no-encryption'
@returns: The association t... | [
"Given",
"an",
"association",
"response",
"message",
"extract",
"the",
"OpenID",
"1",
".",
"X",
"session",
"type",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/consumer.py#L1343-L1379 |
necaris/python3-openid | openid/consumer/discover.py | normalizeURL | def normalizeURL(url):
"""Normalize a URL, converting normalization failures to
DiscoveryFailure"""
try:
normalized = urinorm.urinorm(url)
except ValueError as why:
raise DiscoveryFailure('Normalizing identifier: %s' % (why, ), None)
else:
return urllib.parse.urldefrag(normal... | python | def normalizeURL(url):
"""Normalize a URL, converting normalization failures to
DiscoveryFailure"""
try:
normalized = urinorm.urinorm(url)
except ValueError as why:
raise DiscoveryFailure('Normalizing identifier: %s' % (why, ), None)
else:
return urllib.parse.urldefrag(normal... | [
"def",
"normalizeURL",
"(",
"url",
")",
":",
"try",
":",
"normalized",
"=",
"urinorm",
".",
"urinorm",
"(",
"url",
")",
"except",
"ValueError",
"as",
"why",
":",
"raise",
"DiscoveryFailure",
"(",
"'Normalizing identifier: %s'",
"%",
"(",
"why",
",",
")",
"... | Normalize a URL, converting normalization failures to
DiscoveryFailure | [
"Normalize",
"a",
"URL",
"converting",
"normalization",
"failures",
"to",
"DiscoveryFailure"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/discover.py#L290-L298 |
necaris/python3-openid | openid/consumer/discover.py | OpenIDServiceEndpoint.getDisplayIdentifier | def getDisplayIdentifier(self):
"""Return the display_identifier if set, else return the claimed_id.
"""
if self.display_identifier is not None:
return self.display_identifier
if self.claimed_id is None:
return None
else:
return urllib.parse.ur... | python | def getDisplayIdentifier(self):
"""Return the display_identifier if set, else return the claimed_id.
"""
if self.display_identifier is not None:
return self.display_identifier
if self.claimed_id is None:
return None
else:
return urllib.parse.ur... | [
"def",
"getDisplayIdentifier",
"(",
"self",
")",
":",
"if",
"self",
".",
"display_identifier",
"is",
"not",
"None",
":",
"return",
"self",
".",
"display_identifier",
"if",
"self",
".",
"claimed_id",
"is",
"None",
":",
"return",
"None",
"else",
":",
"return",... | Return the display_identifier if set, else return the claimed_id. | [
"Return",
"the",
"display_identifier",
"if",
"set",
"else",
"return",
"the",
"claimed_id",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/consumer/discover.py#L84-L92 |
necaris/python3-openid | openid/yadis/etxrd.py | parseXRDS | def parseXRDS(text):
"""Parse the given text as an XRDS document.
@return: ElementTree containing an XRDS document
@raises XRDSError: When there is a parse error or the document does
not contain an XRDS.
"""
try:
# lxml prefers to parse bytestrings, and occasionally chokes on a
... | python | def parseXRDS(text):
"""Parse the given text as an XRDS document.
@return: ElementTree containing an XRDS document
@raises XRDSError: When there is a parse error or the document does
not contain an XRDS.
"""
try:
# lxml prefers to parse bytestrings, and occasionally chokes on a
... | [
"def",
"parseXRDS",
"(",
"text",
")",
":",
"try",
":",
"# lxml prefers to parse bytestrings, and occasionally chokes on a",
"# combination of text strings and declared XML encodings -- see",
"# https://github.com/necaris/python3-openid/issues/19",
"# To avoid this, we ensure that the 'text' we... | Parse the given text as an XRDS document.
@return: ElementTree containing an XRDS document
@raises XRDSError: When there is a parse error or the document does
not contain an XRDS. | [
"Parse",
"the",
"given",
"text",
"as",
"an",
"XRDS",
"document",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/yadis/etxrd.py#L49-L76 |
necaris/python3-openid | openid/yadis/etxrd.py | prioSort | def prioSort(elements):
"""Sort a list of elements that have priority attributes"""
# Randomize the services before sorting so that equal priority
# elements are load-balanced.
random.shuffle(elements)
sorted_elems = sorted(elements, key=getPriority)
return sorted_elems | python | def prioSort(elements):
"""Sort a list of elements that have priority attributes"""
# Randomize the services before sorting so that equal priority
# elements are load-balanced.
random.shuffle(elements)
sorted_elems = sorted(elements, key=getPriority)
return sorted_elems | [
"def",
"prioSort",
"(",
"elements",
")",
":",
"# Randomize the services before sorting so that equal priority",
"# elements are load-balanced.",
"random",
".",
"shuffle",
"(",
"elements",
")",
"sorted_elems",
"=",
"sorted",
"(",
"elements",
",",
"key",
"=",
"getPriority",... | Sort a list of elements that have priority attributes | [
"Sort",
"a",
"list",
"of",
"elements",
"that",
"have",
"priority",
"attributes"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/yadis/etxrd.py#L251-L258 |
necaris/python3-openid | openid/oidutil.py | importSafeElementTree | def importSafeElementTree(module_names=None):
"""Find a working ElementTree implementation that is not vulnerable
to XXE, using `defusedxml`.
>>> XXESafeElementTree = importSafeElementTree()
@param module_names: The names of modules to try to use as
a safe ElementTree. Defaults to C{L{xxe_safe... | python | def importSafeElementTree(module_names=None):
"""Find a working ElementTree implementation that is not vulnerable
to XXE, using `defusedxml`.
>>> XXESafeElementTree = importSafeElementTree()
@param module_names: The names of modules to try to use as
a safe ElementTree. Defaults to C{L{xxe_safe... | [
"def",
"importSafeElementTree",
"(",
"module_names",
"=",
"None",
")",
":",
"if",
"module_names",
"is",
"None",
":",
"module_names",
"=",
"xxe_safe_elementtree_modules",
"try",
":",
"return",
"importElementTree",
"(",
"module_names",
")",
"except",
"ImportError",
":... | Find a working ElementTree implementation that is not vulnerable
to XXE, using `defusedxml`.
>>> XXESafeElementTree = importSafeElementTree()
@param module_names: The names of modules to try to use as
a safe ElementTree. Defaults to C{L{xxe_safe_elementtree_modules}}
@returns: An ElementTree ... | [
"Find",
"a",
"working",
"ElementTree",
"implementation",
"that",
"is",
"not",
"vulnerable",
"to",
"XXE",
"using",
"defusedxml",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/oidutil.py#L69-L87 |
necaris/python3-openid | openid/oidutil.py | appendArgs | def appendArgs(url, args):
"""Append query arguments to a HTTP(s) URL. If the URL already has
query arguemtns, these arguments will be added, and the existing
arguments will be preserved. Duplicate arguments will not be
detected or collapsed (both will appear in the output).
@param url: The url to ... | python | def appendArgs(url, args):
"""Append query arguments to a HTTP(s) URL. If the URL already has
query arguemtns, these arguments will be added, and the existing
arguments will be preserved. Duplicate arguments will not be
detected or collapsed (both will appear in the output).
@param url: The url to ... | [
"def",
"appendArgs",
"(",
"url",
",",
"args",
")",
":",
"if",
"hasattr",
"(",
"args",
",",
"'items'",
")",
":",
"args",
"=",
"sorted",
"(",
"args",
".",
"items",
"(",
")",
")",
"else",
":",
"args",
"=",
"list",
"(",
"args",
")",
"if",
"not",
"i... | Append query arguments to a HTTP(s) URL. If the URL already has
query arguemtns, these arguments will be added, and the existing
arguments will be preserved. Duplicate arguments will not be
detected or collapsed (both will appear in the output).
@param url: The url to which the arguments will be append... | [
"Append",
"query",
"arguments",
"to",
"a",
"HTTP",
"(",
"s",
")",
"URL",
".",
"If",
"the",
"URL",
"already",
"has",
"query",
"arguemtns",
"these",
"arguments",
"will",
"be",
"added",
"and",
"the",
"existing",
"arguments",
"will",
"be",
"preserved",
".",
... | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/oidutil.py#L149-L197 |
necaris/python3-openid | openid/oidutil.py | toBase64 | def toBase64(s):
"""Represent string / bytes s as base64, omitting newlines"""
if isinstance(s, str):
s = s.encode("utf-8")
return binascii.b2a_base64(s)[:-1] | python | def toBase64(s):
"""Represent string / bytes s as base64, omitting newlines"""
if isinstance(s, str):
s = s.encode("utf-8")
return binascii.b2a_base64(s)[:-1] | [
"def",
"toBase64",
"(",
"s",
")",
":",
"if",
"isinstance",
"(",
"s",
",",
"str",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"\"utf-8\"",
")",
"return",
"binascii",
".",
"b2a_base64",
"(",
"s",
")",
"[",
":",
"-",
"1",
"]"
] | Represent string / bytes s as base64, omitting newlines | [
"Represent",
"string",
"/",
"bytes",
"s",
"as",
"base64",
"omitting",
"newlines"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/oidutil.py#L200-L204 |
necaris/python3-openid | openid/store/memstore.py | ServerAssocs.cleanup | def cleanup(self):
"""Remove expired associations.
@return: tuple of (removed associations, remaining associations)
"""
remove = []
for handle, assoc in self.assocs.items():
if assoc.expiresIn == 0:
remove.append(handle)
for handle in remove:
... | python | def cleanup(self):
"""Remove expired associations.
@return: tuple of (removed associations, remaining associations)
"""
remove = []
for handle, assoc in self.assocs.items():
if assoc.expiresIn == 0:
remove.append(handle)
for handle in remove:
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"remove",
"=",
"[",
"]",
"for",
"handle",
",",
"assoc",
"in",
"self",
".",
"assocs",
".",
"items",
"(",
")",
":",
"if",
"assoc",
".",
"expiresIn",
"==",
"0",
":",
"remove",
".",
"append",
"(",
"handle",
")... | Remove expired associations.
@return: tuple of (removed associations, remaining associations) | [
"Remove",
"expired",
"associations",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/store/memstore.py#L38-L49 |
necaris/python3-openid | openid/extensions/ax.py | AXMessage._checkMode | def _checkMode(self, ax_args):
"""Raise an exception if the mode in the attribute exchange
arguments does not match what is expected for this class.
@raises NotAXMessage: When there is no mode value in ax_args at all.
@raises AXError: When mode does not match.
"""
mode ... | python | def _checkMode(self, ax_args):
"""Raise an exception if the mode in the attribute exchange
arguments does not match what is expected for this class.
@raises NotAXMessage: When there is no mode value in ax_args at all.
@raises AXError: When mode does not match.
"""
mode ... | [
"def",
"_checkMode",
"(",
"self",
",",
"ax_args",
")",
":",
"mode",
"=",
"ax_args",
".",
"get",
"(",
"'mode'",
")",
"if",
"isinstance",
"(",
"mode",
",",
"bytes",
")",
":",
"mode",
"=",
"str",
"(",
"mode",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"i... | Raise an exception if the mode in the attribute exchange
arguments does not match what is expected for this class.
@raises NotAXMessage: When there is no mode value in ax_args at all.
@raises AXError: When mode does not match. | [
"Raise",
"an",
"exception",
"if",
"the",
"mode",
"in",
"the",
"attribute",
"exchange",
"arguments",
"does",
"not",
"match",
"what",
"is",
"expected",
"for",
"this",
"class",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L73-L88 |
necaris/python3-openid | openid/extensions/ax.py | FetchRequest.getExtensionArgs | def getExtensionArgs(self):
"""Get the serialized form of this attribute fetch request.
@returns: The fetch request message parameters
@rtype: {unicode:unicode}
"""
aliases = NamespaceMap()
required = []
if_available = []
ax_args = self._newArgs()
... | python | def getExtensionArgs(self):
"""Get the serialized form of this attribute fetch request.
@returns: The fetch request message parameters
@rtype: {unicode:unicode}
"""
aliases = NamespaceMap()
required = []
if_available = []
ax_args = self._newArgs()
... | [
"def",
"getExtensionArgs",
"(",
"self",
")",
":",
"aliases",
"=",
"NamespaceMap",
"(",
")",
"required",
"=",
"[",
"]",
"if_available",
"=",
"[",
"]",
"ax_args",
"=",
"self",
".",
"_newArgs",
"(",
")",
"for",
"type_uri",
",",
"attribute",
"in",
"self",
... | Get the serialized form of this attribute fetch request.
@returns: The fetch request message parameters
@rtype: {unicode:unicode} | [
"Get",
"the",
"serialized",
"form",
"of",
"this",
"attribute",
"fetch",
"request",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L222-L270 |
necaris/python3-openid | openid/extensions/ax.py | FetchRequest.getRequiredAttrs | def getRequiredAttrs(self):
"""Get the type URIs for all attributes that have been marked
as required.
@returns: A list of the type URIs for attributes that have
been marked as required.
@rtype: [str]
"""
required = []
for type_uri, attribute in self.... | python | def getRequiredAttrs(self):
"""Get the type URIs for all attributes that have been marked
as required.
@returns: A list of the type URIs for attributes that have
been marked as required.
@rtype: [str]
"""
required = []
for type_uri, attribute in self.... | [
"def",
"getRequiredAttrs",
"(",
"self",
")",
":",
"required",
"=",
"[",
"]",
"for",
"type_uri",
",",
"attribute",
"in",
"self",
".",
"requested_attributes",
".",
"items",
"(",
")",
":",
"if",
"attribute",
".",
"required",
":",
"required",
".",
"append",
... | Get the type URIs for all attributes that have been marked
as required.
@returns: A list of the type URIs for attributes that have
been marked as required.
@rtype: [str] | [
"Get",
"the",
"type",
"URIs",
"for",
"all",
"attributes",
"that",
"have",
"been",
"marked",
"as",
"required",
"."
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L272-L285 |
necaris/python3-openid | openid/extensions/ax.py | FetchRequest.fromOpenIDRequest | def fromOpenIDRequest(cls, openid_request):
"""Extract a FetchRequest from an OpenID message
@param openid_request: The OpenID authentication request
containing the attribute fetch request
@type openid_request: C{L{openid.server.server.CheckIDRequest}}
@rtype: C{L{FetchRequ... | python | def fromOpenIDRequest(cls, openid_request):
"""Extract a FetchRequest from an OpenID message
@param openid_request: The OpenID authentication request
containing the attribute fetch request
@type openid_request: C{L{openid.server.server.CheckIDRequest}}
@rtype: C{L{FetchRequ... | [
"def",
"fromOpenIDRequest",
"(",
"cls",
",",
"openid_request",
")",
":",
"message",
"=",
"openid_request",
".",
"message",
"ax_args",
"=",
"message",
".",
"getArgs",
"(",
"cls",
".",
"ns_uri",
")",
"self",
"=",
"cls",
"(",
")",
"try",
":",
"self",
".",
... | Extract a FetchRequest from an OpenID message
@param openid_request: The OpenID authentication request
containing the attribute fetch request
@type openid_request: C{L{openid.server.server.CheckIDRequest}}
@rtype: C{L{FetchRequest}} or C{None}
@returns: The FetchRequest ext... | [
"Extract",
"a",
"FetchRequest",
"from",
"an",
"OpenID",
"message"
] | train | https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L287-L330 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.