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_documentation_string
stringlengths
1
47.2k
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...
Returns an ``InfluxDBClient`` instance.
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...
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.
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: ...
Method to be called via threading module.
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...
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)
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...
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)...
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...
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[...
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...
Set a high water mark on the zmq socket. Do so in a way that is cross-compatible with zeromq2 and zeromq3.
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...
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...
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 ...
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...
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(...
Take a string of the form 'fedmsg.consumers.ircbot:IRCBotConsumer' and return the IRCBotConsumer class.
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...
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...
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=...
Invoke a shell command to print cowsay output. Primary replacement for os.system calls.
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...
Returns a dict representation of the object. Recursively evaluates to_json(...) on its relationships.
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 ...
Return the to_json or id of a sqlalchemy relationship.
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)
Sign the message prior to sending the message. Args: msg (dict): The message to sign and relay.
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...
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.
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...
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...
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,...
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...
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: ...
Removes given arg (or list thereof) from Args object.
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...
Returns first found index of given value (or list of values).
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(...
Returns all arguments beginning with given string (or list thereof).
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...
Returns all arguments not containing given string (or list thereof).
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...
Returns an expanded list of all valid paths that were passed in.
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)
Returns a list of all arguments that aren't files/globs.
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('='...
Extracts assignment values from assignments.
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: ...
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.
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. """ ...
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.
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...
`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.
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...
`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.
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...
Destroy a fedmsg context
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", ...
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...
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): ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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...
Forward on messages from the bus to all IRC connections.
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...
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.
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...
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`.
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...
Called by CollectdProducer every `n` seconds.
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...
Format messages for collectd to consume.
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...
Initialize the crypto backend. The backend can be one of two plugins: - 'x509' - Uses x509 certificates. - 'gpg' - Uses GnuPG keys.
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...
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.
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: ...
Return true or false if the message is signed appropriately.
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...
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.
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. """ ...
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.
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...
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...
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...
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 ...
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, ...
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...
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...
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...
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...
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 ...
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...
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...
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...
Load the list of file paths for fedmsg configuration files. Returns: list: List of files containing fedmsg configuration.
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...
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.
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': ...
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.
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): -...
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.
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...
Return the global :class:`argparse.ArgumentParser` used by all fedmsg commands. Extra arguments can be supplied with the `declared_args` argument.
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 []
Return list of fully qualified python filenames in the given dir
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): ...
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.
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)
This is builtin in python2, but we have to roll our own on py3.
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)
Load the configuration if necessary and forward the call to the parent.
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)
Load the configuration if necessary and forward the call to the parent.
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...
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.
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']
Iterate over self._defaults and set all default values on self.
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: ...
Run the validators found in self._defaults on all the corresponding values. Raises: ValueError: If the configuration contains an invalid configuration value.
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...
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...
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...
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.
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 ...
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.
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...
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...
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...
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.
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) ...
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.
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)
Return a set of FAS usernames associated with a message.
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...
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...
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...
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...
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()
Use subprocess; feed the message to our command over stdin
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...
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.
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...
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 ...
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...
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...
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 ""
If we can handle the given message, return the remainder of the topic. Returns None if we can't handle the message.
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 """ ...
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
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...
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 ...
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 ...
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...
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. ...
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.
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...
See @L{_discoverAndVerify}
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...
Make a check_authentication request to verify this message. @returns: True if the request is valid. @rtype: bool
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") ...
Generate a check_authentication request message given an id_res message.
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...
Make association requests to the server, attempting to create a new association. @returns: a new association object @rtype: L{openid.association.Association}
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 ...
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...
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...
Normalize a URL, converting normalization failures to DiscoveryFailure
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...
Return the display_identifier if set, else return the claimed_id.
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 ...
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.
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
Sort a list of elements that have priority attributes
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...
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 ...
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 ...
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...
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]
Represent string / bytes s as base64, omitting newlines
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: ...
Remove expired associations. @return: tuple of (removed associations, remaining associations)
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 ...
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.
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() ...
Get the serialized form of this attribute fetch request. @returns: The fetch request message parameters @rtype: {unicode:unicode}
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....
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]
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...
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...
https://github.com/necaris/python3-openid/blob/4911bbc196dfd6f9eda7155df9903d668720ecbf/openid/extensions/ax.py#L287-L330