partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Tree.prune
Remove all children (and descendants) below ADDRESS. Arguments: address (str): the address to be pruned
validator/sawtooth_validator/execution/scheduler_parallel.py
def prune(self, address): ''' Remove all children (and descendants) below ADDRESS. Arguments: address (str): the address to be pruned ''' try: for step in self._walk_to_address(address): node = step except AddressNotInTree: ...
def prune(self, address): ''' Remove all children (and descendants) below ADDRESS. Arguments: address (str): the address to be pruned ''' try: for step in self._walk_to_address(address): node = step except AddressNotInTree: ...
[ "Remove", "all", "children", "(", "and", "descendants", ")", "below", "ADDRESS", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L107-L121
[ "def", "prune", "(", "self", ",", "address", ")", ":", "try", ":", "for", "step", "in", "self", ".", "_walk_to_address", "(", "address", ")", ":", "node", "=", "step", "except", "AddressNotInTree", ":", "return", "node", ".", "children", ".", "clear", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Tree.walk
Returns a stream of pairs of node addresses and data, raising AddressNotInTree if ADDRESS is not in the tree. First the ancestors of ADDRESS (including itself) are yielded, earliest to latest, and then the descendants of ADDRESS are yielded in an unspecified order. Arguments: ...
validator/sawtooth_validator/execution/scheduler_parallel.py
def walk(self, address): ''' Returns a stream of pairs of node addresses and data, raising AddressNotInTree if ADDRESS is not in the tree. First the ancestors of ADDRESS (including itself) are yielded, earliest to latest, and then the descendants of ADDRESS are yielded i...
def walk(self, address): ''' Returns a stream of pairs of node addresses and data, raising AddressNotInTree if ADDRESS is not in the tree. First the ancestors of ADDRESS (including itself) are yielded, earliest to latest, and then the descendants of ADDRESS are yielded i...
[ "Returns", "a", "stream", "of", "pairs", "of", "node", "addresses", "and", "data", "raising", "AddressNotInTree", "if", "ADDRESS", "is", "not", "in", "the", "tree", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L123-L152
[ "def", "walk", "(", "self", ",", "address", ")", ":", "for", "step", "in", "self", ".", "_walk_to_address", "(", "address", ")", ":", "node", "=", "step", "yield", "node", ".", "address", ",", "node", ".", "data", "to_process", "=", "deque", "(", ")"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PredecessorTree.find_write_predecessors
Returns all predecessor transaction ids for a write of the provided address. Arguments: address (str): the radix address Returns: a set of transaction ids
validator/sawtooth_validator/execution/scheduler_parallel.py
def find_write_predecessors(self, address): """Returns all predecessor transaction ids for a write of the provided address. Arguments: address (str): the radix address Returns: a set of transaction ids """ # A write operation must be preceded by: # ...
def find_write_predecessors(self, address): """Returns all predecessor transaction ids for a write of the provided address. Arguments: address (str): the radix address Returns: a set of transaction ids """ # A write operation must be preceded by: # ...
[ "Returns", "all", "predecessor", "transaction", "ids", "for", "a", "write", "of", "the", "provided", "address", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L254-L338
[ "def", "find_write_predecessors", "(", "self", ",", "address", ")", ":", "# A write operation must be preceded by:", "# - The \"enclosing writer\", which is the writer at the address or", "# the nearest writer higher (closer to the root) in the tree.", "# - The \"enclosing readers\", w...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PredecessorChain.add_relationship
Add a predecessor-successor relationship between one txn id and a set of predecessors. Args: txn_id (str): The transaction id of the transaction. predecessors (set): The transaction ids of the transaction's predecessors Returns: None
validator/sawtooth_validator/execution/scheduler_parallel.py
def add_relationship(self, txn_id, predecessors): """Add a predecessor-successor relationship between one txn id and a set of predecessors. Args: txn_id (str): The transaction id of the transaction. predecessors (set): The transaction ids of the transacti...
def add_relationship(self, txn_id, predecessors): """Add a predecessor-successor relationship between one txn id and a set of predecessors. Args: txn_id (str): The transaction id of the transaction. predecessors (set): The transaction ids of the transacti...
[ "Add", "a", "predecessor", "-", "successor", "relationship", "between", "one", "txn", "id", "and", "a", "set", "of", "predecessors", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L422-L439
[ "def", "add_relationship", "(", "self", ",", "txn_id", ",", "predecessors", ")", ":", "all_pred", "=", "set", "(", "predecessors", ")", "for", "pred", "in", "predecessors", ":", "all_pred", ".", "update", "(", "self", ".", "_predecessors_by_id", "[", "pred",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PredecessorChain.is_predecessor_of_other
Returns whether the predecessor is a predecessor or a predecessor of a predecessor...of any of the others. Args: predecessor (str): The txn id of the predecessor. others (list(str)): The txn id of the successor. Returns: (bool)
validator/sawtooth_validator/execution/scheduler_parallel.py
def is_predecessor_of_other(self, predecessor, others): """Returns whether the predecessor is a predecessor or a predecessor of a predecessor...of any of the others. Args: predecessor (str): The txn id of the predecessor. others (list(str)): The txn id of the successor. ...
def is_predecessor_of_other(self, predecessor, others): """Returns whether the predecessor is a predecessor or a predecessor of a predecessor...of any of the others. Args: predecessor (str): The txn id of the predecessor. others (list(str)): The txn id of the successor. ...
[ "Returns", "whether", "the", "predecessor", "is", "a", "predecessor", "or", "a", "predecessor", "of", "a", "predecessor", "...", "of", "any", "of", "the", "others", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L441-L454
[ "def", "is_predecessor_of_other", "(", "self", ",", "predecessor", ",", "others", ")", ":", "return", "any", "(", "predecessor", "in", "self", ".", "_predecessors_by_id", "[", "o", "]", "for", "o", "in", "others", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._find_input_dependencies
Use the predecessor tree to find dependencies based on inputs. Returns: A list of transaction ids.
validator/sawtooth_validator/execution/scheduler_parallel.py
def _find_input_dependencies(self, inputs): """Use the predecessor tree to find dependencies based on inputs. Returns: A list of transaction ids. """ dependencies = [] for address in inputs: dependencies.extend( self._predecessor_tree.find_read_predec...
def _find_input_dependencies(self, inputs): """Use the predecessor tree to find dependencies based on inputs. Returns: A list of transaction ids. """ dependencies = [] for address in inputs: dependencies.extend( self._predecessor_tree.find_read_predec...
[ "Use", "the", "predecessor", "tree", "to", "find", "dependencies", "based", "on", "inputs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L508-L517
[ "def", "_find_input_dependencies", "(", "self", ",", "inputs", ")", ":", "dependencies", "=", "[", "]", "for", "address", "in", "inputs", ":", "dependencies", ".", "extend", "(", "self", ".", "_predecessor_tree", ".", "find_read_predecessors", "(", "address", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._find_output_dependencies
Use the predecessor tree to find dependencies based on outputs. Returns: A list of transaction ids.
validator/sawtooth_validator/execution/scheduler_parallel.py
def _find_output_dependencies(self, outputs): """Use the predecessor tree to find dependencies based on outputs. Returns: A list of transaction ids. """ dependencies = [] for address in outputs: dependencies.extend( self._predecessor_tree.find_write_p...
def _find_output_dependencies(self, outputs): """Use the predecessor tree to find dependencies based on outputs. Returns: A list of transaction ids. """ dependencies = [] for address in outputs: dependencies.extend( self._predecessor_tree.find_write_p...
[ "Use", "the", "predecessor", "tree", "to", "find", "dependencies", "based", "on", "outputs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L519-L528
[ "def", "_find_output_dependencies", "(", "self", ",", "outputs", ")", ":", "dependencies", "=", "[", "]", "for", "address", "in", "outputs", ":", "dependencies", ".", "extend", "(", "self", ".", "_predecessor_tree", ".", "find_write_predecessors", "(", "address"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._get_contexts_for_squash
Starting with the batch referenced by batch_signature, iterate back through the batches and for each valid batch collect the context_id. At the end remove contexts for txns that are other txn's predecessors. Args: batch_signature (str): The batch to start from, moving back through ...
validator/sawtooth_validator/execution/scheduler_parallel.py
def _get_contexts_for_squash(self, batch_signature): """Starting with the batch referenced by batch_signature, iterate back through the batches and for each valid batch collect the context_id. At the end remove contexts for txns that are other txn's predecessors. Args: batch...
def _get_contexts_for_squash(self, batch_signature): """Starting with the batch referenced by batch_signature, iterate back through the batches and for each valid batch collect the context_id. At the end remove contexts for txns that are other txn's predecessors. Args: batch...
[ "Starting", "with", "the", "batch", "referenced", "by", "batch_signature", "iterate", "back", "through", "the", "batches", "and", "for", "each", "valid", "batch", "collect", "the", "context_id", ".", "At", "the", "end", "remove", "contexts", "for", "txns", "th...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L631-L665
[ "def", "_get_contexts_for_squash", "(", "self", ",", "batch_signature", ")", ":", "batch", "=", "self", ".", "_batches_by_id", "[", "batch_signature", "]", ".", "batch", "index", "=", "self", ".", "_batches", ".", "index", "(", "batch", ")", "contexts", "=",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._is_txn_to_replay
Decide if possible_successor should be replayed. Args: txn_id (str): Id of txn in failed batch. possible_successor (str): Id of txn to possibly replay. already_seen (list): A list of possible_successors that have been replayed. Returns: (...
validator/sawtooth_validator/execution/scheduler_parallel.py
def _is_txn_to_replay(self, txn_id, possible_successor, already_seen): """Decide if possible_successor should be replayed. Args: txn_id (str): Id of txn in failed batch. possible_successor (str): Id of txn to possibly replay. already_seen (list): A list of possible_s...
def _is_txn_to_replay(self, txn_id, possible_successor, already_seen): """Decide if possible_successor should be replayed. Args: txn_id (str): Id of txn in failed batch. possible_successor (str): Id of txn to possibly replay. already_seen (list): A list of possible_s...
[ "Decide", "if", "possible_successor", "should", "be", "replayed", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L744-L764
[ "def", "_is_txn_to_replay", "(", "self", ",", "txn_id", ",", "possible_successor", ",", "already_seen", ")", ":", "is_successor", "=", "self", ".", "_is_predecessor_of_possible_successor", "(", "txn_id", ",", "possible_successor", ")", "in_different_batch", "=", "not"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._remove_subsequent_result_because_of_batch_failure
Remove transactions from scheduled and txn_results for successors of txns in a failed batch. These transactions will now, or in the future be rescheduled in next_transaction; giving a replay ability. Args: sig (str): Transaction header signature
validator/sawtooth_validator/execution/scheduler_parallel.py
def _remove_subsequent_result_because_of_batch_failure(self, sig): """Remove transactions from scheduled and txn_results for successors of txns in a failed batch. These transactions will now, or in the future be rescheduled in next_transaction; giving a replay ability. Args: ...
def _remove_subsequent_result_because_of_batch_failure(self, sig): """Remove transactions from scheduled and txn_results for successors of txns in a failed batch. These transactions will now, or in the future be rescheduled in next_transaction; giving a replay ability. Args: ...
[ "Remove", "transactions", "from", "scheduled", "and", "txn_results", "for", "successors", "of", "txns", "in", "a", "failed", "batch", ".", "These", "transactions", "will", "now", "or", "in", "the", "future", "be", "rescheduled", "in", "next_transaction", ";", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L766-L793
[ "def", "_remove_subsequent_result_because_of_batch_failure", "(", "self", ",", "sig", ")", ":", "batch", "=", "self", ".", "_batches_by_txn_id", "[", "sig", "]", "seen", "=", "[", "]", "for", "txn", "in", "batch", ".", "transactions", ":", "txn_id", "=", "tx...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._set_least_batch_id
Set the first batch id that doesn't have all results. Args: txn_signature (str): The txn identifier of the transaction with results being set.
validator/sawtooth_validator/execution/scheduler_parallel.py
def _set_least_batch_id(self, txn_signature): """Set the first batch id that doesn't have all results. Args: txn_signature (str): The txn identifier of the transaction with results being set. """ batch = self._batches_by_txn_id[txn_signature] least...
def _set_least_batch_id(self, txn_signature): """Set the first batch id that doesn't have all results. Args: txn_signature (str): The txn identifier of the transaction with results being set. """ batch = self._batches_by_txn_id[txn_signature] least...
[ "Set", "the", "first", "batch", "id", "that", "doesn", "t", "have", "all", "results", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L812-L848
[ "def", "_set_least_batch_id", "(", "self", ",", "txn_signature", ")", ":", "batch", "=", "self", ".", "_batches_by_txn_id", "[", "txn_signature", "]", "least_index", "=", "self", ".", "_index_of_batch", "(", "self", ".", "_batches_by_id", "[", "self", ".", "_l...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ParallelScheduler._txn_is_in_valid_batch
Returns whether the transaction is in a valid batch. Args: txn_id (str): The transaction header signature. Returns: (bool): True if the txn's batch is valid, False otherwise.
validator/sawtooth_validator/execution/scheduler_parallel.py
def _txn_is_in_valid_batch(self, txn_id): """Returns whether the transaction is in a valid batch. Args: txn_id (str): The transaction header signature. Returns: (bool): True if the txn's batch is valid, False otherwise. """ batch = self._batches_by_txn_...
def _txn_is_in_valid_batch(self, txn_id): """Returns whether the transaction is in a valid batch. Args: txn_id (str): The transaction header signature. Returns: (bool): True if the txn's batch is valid, False otherwise. """ batch = self._batches_by_txn_...
[ "Returns", "whether", "the", "transaction", "is", "in", "a", "valid", "batch", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L898-L915
[ "def", "_txn_is_in_valid_batch", "(", "self", ",", "txn_id", ")", ":", "batch", "=", "self", ".", "_batches_by_txn_id", "[", "txn_id", "]", "# Return whether every transaction in the batch with a", "# transaction result is valid", "return", "all", "(", "self", ".", "_tx...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_keygen
Executes the key generation operation, given the parsed arguments. Args: args (:obj:`Namespace`): The parsed args.
cli/sawtooth_cli/admin_command/keygen.py
def do_keygen(args): """Executes the key generation operation, given the parsed arguments. Args: args (:obj:`Namespace`): The parsed args. """ if args.key_name is not None: key_name = args.key_name else: key_name = 'validator' key_dir = get_key_dir() if not os.path...
def do_keygen(args): """Executes the key generation operation, given the parsed arguments. Args: args (:obj:`Namespace`): The parsed args. """ if args.key_name is not None: key_name = args.key_name else: key_name = 'validator' key_dir = get_key_dir() if not os.path...
[ "Executes", "the", "key", "generation", "operation", "given", "the", "parsed", "arguments", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/admin_command/keygen.py#L65-L133
[ "def", "do_keygen", "(", "args", ")", ":", "if", "args", ".", "key_name", "is", "not", "None", ":", "key_name", "=", "args", ".", "key_name", "else", ":", "key_name", "=", "'validator'", "key_dir", "=", "get_key_dir", "(", ")", "if", "not", "os", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
size
Determines the height and width of the console window Returns: tuple of int: The height in lines, then width in characters
cli/sawtooth_cli/tty.py
def size(): """Determines the height and width of the console window Returns: tuple of int: The height in lines, then width in characters """ try: assert os != 'nt' and sys.stdout.isatty() rows, columns = os.popen('stty size', 'r').read().split() except (AssertionErr...
def size(): """Determines the height and width of the console window Returns: tuple of int: The height in lines, then width in characters """ try: assert os != 'nt' and sys.stdout.isatty() rows, columns = os.popen('stty size', 'r').read().split() except (AssertionErr...
[ "Determines", "the", "height", "and", "width", "of", "the", "console", "window" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/tty.py#L24-L37
[ "def", "size", "(", ")", ":", "try", ":", "assert", "os", "!=", "'nt'", "and", "sys", ".", "stdout", ".", "isatty", "(", ")", "rows", ",", "columns", "=", "os", ".", "popen", "(", "'stty size'", ",", "'r'", ")", ".", "read", "(", ")", ".", "spl...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.send_peers
Sends a message containing our peers to the connection identified by connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket.
validator/sawtooth_validator/gossip/gossip.py
def send_peers(self, connection_id): """Sends a message containing our peers to the connection identified by connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. """ with self._lock...
def send_peers(self, connection_id): """Sends a message containing our peers to the connection identified by connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. """ with self._lock...
[ "Sends", "a", "message", "containing", "our", "peers", "to", "the", "connection", "identified", "by", "connection_id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L153-L177
[ "def", "send_peers", "(", "self", ",", "connection_id", ")", ":", "with", "self", ".", "_lock", ":", "# Needs to actually be the list of advertised endpoints of", "# our peers", "peer_endpoints", "=", "list", "(", "self", ".", "_peers", ".", "values", "(", ")", ")...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.add_candidate_peer_endpoints
Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with.
validator/sawtooth_validator/gossip/gossip.py
def add_candidate_peer_endpoints(self, peer_endpoints): """Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with. """ if self._topol...
def add_candidate_peer_endpoints(self, peer_endpoints): """Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with. """ if self._topol...
[ "Adds", "candidate", "endpoints", "to", "the", "list", "of", "endpoints", "to", "attempt", "to", "peer", "with", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L179-L191
[ "def", "add_candidate_peer_endpoints", "(", "self", ",", "peer_endpoints", ")", ":", "if", "self", ".", "_topology", ":", "self", ".", "_topology", ".", "add_candidate_peer_endpoints", "(", "peer_endpoints", ")", "else", ":", "LOGGER", ".", "debug", "(", "\"Coul...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.get_peers_public_keys
Returns the list of public keys for all peers.
validator/sawtooth_validator/gossip/gossip.py
def get_peers_public_keys(self): """Returns the list of public keys for all peers.""" with self._lock: # Use a generator inside the list comprehension to filter out None # values in a single pass return [key for key in (self._network.connection_id_...
def get_peers_public_keys(self): """Returns the list of public keys for all peers.""" with self._lock: # Use a generator inside the list comprehension to filter out None # values in a single pass return [key for key in (self._network.connection_id_...
[ "Returns", "the", "list", "of", "public", "keys", "for", "all", "peers", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L204-L213
[ "def", "get_peers_public_keys", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "# Use a generator inside the list comprehension to filter out None", "# values in a single pass", "return", "[", "key", "for", "key", "in", "(", "self", ".", "_network", ".", "c...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.register_peer
Registers a connected connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. endpoint (str): The publically reachable endpoint of the new peer
validator/sawtooth_validator/gossip/gossip.py
def register_peer(self, connection_id, endpoint): """Registers a connected connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. endpoint (str): The publically reachable endpoint of the new ...
def register_peer(self, connection_id, endpoint): """Registers a connected connection_id. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. endpoint (str): The publically reachable endpoint of the new ...
[ "Registers", "a", "connected", "connection_id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L221-L247
[ "def", "register_peer", "(", "self", ",", "connection_id", ",", "endpoint", ")", ":", "with", "self", ".", "_lock", ":", "if", "len", "(", "self", ".", "_peers", ")", "<", "self", ".", "_maximum_peer_connectivity", ":", "self", ".", "_peers", "[", "conne...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.unregister_peer
Removes a connection_id from the registry. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket.
validator/sawtooth_validator/gossip/gossip.py
def unregister_peer(self, connection_id): """Removes a connection_id from the registry. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. """ public_key = self.peer_to_public_key(connection_id) ...
def unregister_peer(self, connection_id): """Removes a connection_id from the registry. Args: connection_id (str): A unique identifier which identifies an connection on the network server socket. """ public_key = self.peer_to_public_key(connection_id) ...
[ "Removes", "a", "connection_id", "from", "the", "registry", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L249-L271
[ "def", "unregister_peer", "(", "self", ",", "connection_id", ")", ":", "public_key", "=", "self", ".", "peer_to_public_key", "(", "connection_id", ")", "if", "public_key", ":", "self", ".", "_consensus_notifier", ".", "notify_peer_disconnected", "(", "public_key", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.send
Sends a message via the network. Args: message_type (str): The type of the message. message (bytes): The message to be sent. connection_id (str): The connection to send it to.
validator/sawtooth_validator/gossip/gossip.py
def send(self, message_type, message, connection_id, one_way=False): """Sends a message via the network. Args: message_type (str): The type of the message. message (bytes): The message to be sent. connection_id (str): The connection to send it to. """ ...
def send(self, message_type, message, connection_id, one_way=False): """Sends a message via the network. Args: message_type (str): The type of the message. message (bytes): The message to be sent. connection_id (str): The connection to send it to. """ ...
[ "Sends", "a", "message", "via", "the", "network", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L363-L379
[ "def", "send", "(", "self", ",", "message_type", ",", "message", ",", "connection_id", ",", "one_way", "=", "False", ")", ":", "try", ":", "self", ".", "_network", ".", "send", "(", "message_type", ",", "message", ",", "connection_id", ",", "one_way", "=...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Gossip.broadcast
Broadcast gossip messages. Broadcast the message to all peers unless they are in the excluded list. Args: gossip_message: The message to be broadcast. message_type: Type of the message. exclude: A list of connection_ids that should be excluded from this ...
validator/sawtooth_validator/gossip/gossip.py
def broadcast(self, gossip_message, message_type, exclude=None): """Broadcast gossip messages. Broadcast the message to all peers unless they are in the excluded list. Args: gossip_message: The message to be broadcast. message_type: Type of the message. ...
def broadcast(self, gossip_message, message_type, exclude=None): """Broadcast gossip messages. Broadcast the message to all peers unless they are in the excluded list. Args: gossip_message: The message to be broadcast. message_type: Type of the message. ...
[ "Broadcast", "gossip", "messages", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L381-L404
[ "def", "broadcast", "(", "self", ",", "gossip_message", ",", "message_type", ",", "exclude", "=", "None", ")", ":", "with", "self", ".", "_lock", ":", "if", "exclude", "is", "None", ":", "exclude", "=", "[", "]", "for", "connection_id", "in", "self", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConnectionManager.add_candidate_peer_endpoints
Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with.
validator/sawtooth_validator/gossip/gossip.py
def add_candidate_peer_endpoints(self, peer_endpoints): """Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with. """ with self._loc...
def add_candidate_peer_endpoints(self, peer_endpoints): """Adds candidate endpoints to the list of endpoints to attempt to peer with. Args: peer_endpoints ([str]): A list of public uri's which the validator can attempt to peer with. """ with self._loc...
[ "Adds", "candidate", "endpoints", "to", "the", "list", "of", "endpoints", "to", "attempt", "to", "peer", "with", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L704-L715
[ "def", "add_candidate_peer_endpoints", "(", "self", ",", "peer_endpoints", ")", ":", "with", "self", ".", "_lock", ":", "for", "endpoint", "in", "peer_endpoints", ":", "if", "endpoint", "not", "in", "self", ".", "_candidate_peer_endpoints", ":", "self", ".", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConnectionManager.connect_success
Check to see if the successful connection is meant to be peered with. If not, it should be used to get the peers from the endpoint.
validator/sawtooth_validator/gossip/gossip.py
def connect_success(self, connection_id): """ Check to see if the successful connection is meant to be peered with. If not, it should be used to get the peers from the endpoint. """ endpoint = self._network.connection_id_to_endpoint(connection_id) endpoint_info = self._te...
def connect_success(self, connection_id): """ Check to see if the successful connection is meant to be peered with. If not, it should be used to get the peers from the endpoint. """ endpoint = self._network.connection_id_to_endpoint(connection_id) endpoint_info = self._te...
[ "Check", "to", "see", "if", "the", "successful", "connection", "is", "meant", "to", "be", "peered", "with", ".", "If", "not", "it", "should", "be", "used", "to", "get", "the", "peers", "from", "the", "endpoint", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/gossip.py#L923-L948
[ "def", "connect_success", "(", "self", ",", "connection_id", ")", ":", "endpoint", "=", "self", ".", "_network", ".", "connection_id_to_endpoint", "(", "connection_id", ")", "endpoint_info", "=", "self", ".", "_temp_endpoints", ".", "get", "(", "endpoint", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
prepare_vec_result
Returns pair of byte pointer and size value for use as return parameters in a LIBRARY call
validator/sawtooth_validator/ffi.py
def prepare_vec_result(pointer_type=ctypes.c_uint8): """Returns pair of byte pointer and size value for use as return parameters in a LIBRARY call """ return ( ctypes.POINTER(pointer_type)(), ctypes.c_size_t(0), ctypes.c_size_t(0), )
def prepare_vec_result(pointer_type=ctypes.c_uint8): """Returns pair of byte pointer and size value for use as return parameters in a LIBRARY call """ return ( ctypes.POINTER(pointer_type)(), ctypes.c_size_t(0), ctypes.c_size_t(0), )
[ "Returns", "pair", "of", "byte", "pointer", "and", "size", "value", "for", "use", "as", "return", "parameters", "in", "a", "LIBRARY", "call" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/ffi.py#L93-L101
[ "def", "prepare_vec_result", "(", "pointer_type", "=", "ctypes", ".", "c_uint8", ")", ":", "return", "(", "ctypes", ".", "POINTER", "(", "pointer_type", ")", "(", ")", ",", "ctypes", ".", "c_size_t", "(", "0", ")", ",", "ctypes", ".", "c_size_t", "(", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
OwnedPointer.drop
Explicitly drop this pointer. The memory will be deallocated via the drop_ffi_call_fn passed to the constructor.
validator/sawtooth_validator/ffi.py
def drop(self): """Explicitly drop this pointer. The memory will be deallocated via the drop_ffi_call_fn passed to the constructor. """ if self._ptr: LIBRARY.call(self._drop_ffi_fn, self._ptr) self._ptr = None
def drop(self): """Explicitly drop this pointer. The memory will be deallocated via the drop_ffi_call_fn passed to the constructor. """ if self._ptr: LIBRARY.call(self._drop_ffi_fn, self._ptr) self._ptr = None
[ "Explicitly", "drop", "this", "pointer", ".", "The", "memory", "will", "be", "deallocated", "via", "the", "drop_ffi_call_fn", "passed", "to", "the", "constructor", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/ffi.py#L135-L141
[ "def", "drop", "(", "self", ")", ":", "if", "self", ".", "_ptr", ":", "LIBRARY", ".", "call", "(", "self", ".", "_drop_ffi_fn", ",", "self", ".", "_ptr", ")", "self", ".", "_ptr", "=", "None" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
get_default_path_config
Returns the default PathConfig as calculated based on SAWTOOTH_HOME (if set) and operating system.
validator/sawtooth_validator/config/path.py
def get_default_path_config(): """Returns the default PathConfig as calculated based on SAWTOOTH_HOME (if set) and operating system. """ if 'SAWTOOTH_HOME' in os.environ: home_dir = os.environ['SAWTOOTH_HOME'] return PathConfig( config_dir=os.path.join(home_dir, 'etc'), ...
def get_default_path_config(): """Returns the default PathConfig as calculated based on SAWTOOTH_HOME (if set) and operating system. """ if 'SAWTOOTH_HOME' in os.environ: home_dir = os.environ['SAWTOOTH_HOME'] return PathConfig( config_dir=os.path.join(home_dir, 'etc'), ...
[ "Returns", "the", "default", "PathConfig", "as", "calculated", "based", "on", "SAWTOOTH_HOME", "(", "if", "set", ")", "and", "operating", "system", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/config/path.py#L29-L59
[ "def", "get_default_path_config", "(", ")", ":", "if", "'SAWTOOTH_HOME'", "in", "os", ".", "environ", ":", "home_dir", "=", "os", ".", "environ", "[", "'SAWTOOTH_HOME'", "]", "return", "PathConfig", "(", "config_dir", "=", "os", ".", "path", ".", "join", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
load_toml_path_config
Returns a PathConfig created by loading a TOML file from the filesystem.
validator/sawtooth_validator/config/path.py
def load_toml_path_config(filename): """Returns a PathConfig created by loading a TOML file from the filesystem. """ if not os.path.exists(filename): LOGGER.info( "Skipping path loading from non-existent config file: %s", filename) return PathConfig() LOGGER....
def load_toml_path_config(filename): """Returns a PathConfig created by loading a TOML file from the filesystem. """ if not os.path.exists(filename): LOGGER.info( "Skipping path loading from non-existent config file: %s", filename) return PathConfig() LOGGER....
[ "Returns", "a", "PathConfig", "created", "by", "loading", "a", "TOML", "file", "from", "the", "filesystem", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/config/path.py#L62-L97
[ "def", "load_toml_path_config", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "LOGGER", ".", "info", "(", "\"Skipping path loading from non-existent config file: %s\"", ",", "filename", ")", "return", "PathCon...
8cf473bc2207e51f02bd182d825158a57d72b098
train
merge_path_config
Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority).
validator/sawtooth_validator/config/path.py
def merge_path_config(configs, config_dir_override): """ Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority). """ config_dir = None log_dir = None data_dir = None key_dir = None policy_dir ...
def merge_path_config(configs, config_dir_override): """ Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority). """ config_dir = None log_dir = None data_dir = None key_dir = None policy_dir ...
[ "Given", "a", "list", "of", "PathConfig", "objects", "merges", "them", "into", "a", "single", "PathConfig", "giving", "priority", "in", "the", "order", "of", "the", "configs", "(", "first", "has", "highest", "priority", ")", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/config/path.py#L100-L131
[ "def", "merge_path_config", "(", "configs", ",", "config_dir_override", ")", ":", "config_dir", "=", "None", "log_dir", "=", "None", "data_dir", "=", "None", "key_dir", "=", "None", "policy_dir", "=", "None", "for", "config", "in", "reversed", "(", "configs", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
GenesisController.requires_genesis
Determines if the system should be put in genesis mode Returns: bool: return whether or not a genesis block is required to be generated. Raises: InvalidGenesisStateError: raises this error if there is invalid combination of the following: genesis...
validator/sawtooth_validator/journal/genesis.py
def requires_genesis(self): """ Determines if the system should be put in genesis mode Returns: bool: return whether or not a genesis block is required to be generated. Raises: InvalidGenesisStateError: raises this error if there is invalid ...
def requires_genesis(self): """ Determines if the system should be put in genesis mode Returns: bool: return whether or not a genesis block is required to be generated. Raises: InvalidGenesisStateError: raises this error if there is invalid ...
[ "Determines", "if", "the", "system", "should", "be", "put", "in", "genesis", "mode" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/genesis.py#L88-L131
[ "def", "requires_genesis", "(", "self", ")", ":", "genesis_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_data_dir", ",", "'genesis.batch'", ")", "has_genesis_batches", "=", "Path", "(", "genesis_file", ")", ".", "is_file", "(", ")", "LOGG...
8cf473bc2207e51f02bd182d825158a57d72b098
train
GenesisController.start
Starts the genesis block creation process. Will call the given `on_done` callback on successful completion. Args: on_done (function): a function called on completion Raises: InvalidGenesisStateError: raises this error if a genesis block is unable to be ...
validator/sawtooth_validator/journal/genesis.py
def start(self, on_done): """ Starts the genesis block creation process. Will call the given `on_done` callback on successful completion. Args: on_done (function): a function called on completion Raises: InvalidGenesisStateError: raises this error if a ...
def start(self, on_done): """ Starts the genesis block creation process. Will call the given `on_done` callback on successful completion. Args: on_done (function): a function called on completion Raises: InvalidGenesisStateError: raises this error if a ...
[ "Starts", "the", "genesis", "block", "creation", "process", ".", "Will", "call", "the", "given", "on_done", "callback", "on", "successful", "completion", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/genesis.py#L133-L236
[ "def", "start", "(", "self", ",", "on_done", ")", ":", "genesis_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_data_dir", ",", "'genesis.batch'", ")", "try", ":", "with", "open", "(", "genesis_file", ",", "'rb'", ")", "as", "batch_file...
8cf473bc2207e51f02bd182d825158a57d72b098
train
GenesisController._get_block_publisher
Returns the block publisher based on the consensus module set by the "sawtooth_settings" transaction family. Args: state_hash (str): The current state root hash for reading settings. Raises: InvalidGenesisStateError: if any errors occur getting the Block...
validator/sawtooth_validator/journal/genesis.py
def _get_block_publisher(self, state_hash): """Returns the block publisher based on the consensus module set by the "sawtooth_settings" transaction family. Args: state_hash (str): The current state root hash for reading settings. Raises: InvalidGenesisStateError...
def _get_block_publisher(self, state_hash): """Returns the block publisher based on the consensus module set by the "sawtooth_settings" transaction family. Args: state_hash (str): The current state root hash for reading settings. Raises: InvalidGenesisStateError...
[ "Returns", "the", "block", "publisher", "based", "on", "the", "consensus", "module", "set", "by", "the", "sawtooth_settings", "transaction", "family", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/genesis.py#L238-L275
[ "def", "_get_block_publisher", "(", "self", ",", "state_hash", ")", ":", "state_view", "=", "self", ".", "_state_view_factory", ".", "create_view", "(", "state_hash", ")", "try", ":", "class", "BatchPublisher", ":", "def", "send", "(", "self", ",", "transactio...
8cf473bc2207e51f02bd182d825158a57d72b098
train
GenesisController._generate_genesis_block
Returns a blocker wrapper with the basics of the block header in place
validator/sawtooth_validator/journal/genesis.py
def _generate_genesis_block(self): """ Returns a blocker wrapper with the basics of the block header in place """ genesis_header = block_pb2.BlockHeader( block_num=0, previous_block_id=NULL_BLOCK_IDENTIFIER, signer_public_key=self._identity_signer.get_...
def _generate_genesis_block(self): """ Returns a blocker wrapper with the basics of the block header in place """ genesis_header = block_pb2.BlockHeader( block_num=0, previous_block_id=NULL_BLOCK_IDENTIFIER, signer_public_key=self._identity_signer.get_...
[ "Returns", "a", "blocker", "wrapper", "with", "the", "basics", "of", "the", "block", "header", "in", "place" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/genesis.py#L277-L286
[ "def", "_generate_genesis_block", "(", "self", ")", ":", "genesis_header", "=", "block_pb2", ".", "BlockHeader", "(", "block_num", "=", "0", ",", "previous_block_id", "=", "NULL_BLOCK_IDENTIFIER", ",", "signer_public_key", "=", "self", ".", "_identity_signer", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
GenesisController._sign_block
The block should be complete and the final signature from the publishing validator (this validator) needs to be added.
validator/sawtooth_validator/journal/genesis.py
def _sign_block(self, block): """ The block should be complete and the final signature from the publishing validator (this validator) needs to be added. """ block_header = block.block_header header_bytes = block_header.SerializeToString() signature = self._identit...
def _sign_block(self, block): """ The block should be complete and the final signature from the publishing validator (this validator) needs to be added. """ block_header = block.block_header header_bytes = block_header.SerializeToString() signature = self._identit...
[ "The", "block", "should", "be", "complete", "and", "the", "final", "signature", "from", "the", "publishing", "validator", "(", "this", "validator", ")", "needs", "to", "be", "added", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/genesis.py#L288-L297
[ "def", "_sign_block", "(", "self", ",", "block", ")", ":", "block_header", "=", "block", ".", "block_header", "header_bytes", "=", "block_header", ".", "SerializeToString", "(", ")", "signature", "=", "self", ".", "_identity_signer", ".", "sign", "(", "header_...
8cf473bc2207e51f02bd182d825158a57d72b098
train
TimedCache._purge_expired
Remove all expired entries from the cache.
validator/sawtooth_validator/journal/timed_cache.py
def _purge_expired(self): """ Remove all expired entries from the cache. """ time_horizon = time.time() - self._keep_time new_cache = {} for (k, v) in self._cache.items(): if v.timestamp > time_horizon: new_cache[k] = v self._cache = ne...
def _purge_expired(self): """ Remove all expired entries from the cache. """ time_horizon = time.time() - self._keep_time new_cache = {} for (k, v) in self._cache.items(): if v.timestamp > time_horizon: new_cache[k] = v self._cache = ne...
[ "Remove", "all", "expired", "entries", "from", "the", "cache", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/timed_cache.py#L95-L104
[ "def", "_purge_expired", "(", "self", ")", ":", "time_horizon", "=", "time", ".", "time", "(", ")", "-", "self", ".", "_keep_time", "new_cache", "=", "{", "}", "for", "(", "k", ",", "v", ")", "in", "self", ".", "_cache", ".", "items", "(", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_get_config
Determines if there is a log config in the config directory and returns it. If it does not exist, return None. Returns: log_config (dict): The dictionary to pass to logging.config.dictConfig
validator/sawtooth_validator/config/logs.py
def _get_config(): """Determines if there is a log config in the config directory and returns it. If it does not exist, return None. Returns: log_config (dict): The dictionary to pass to logging.config.dictConfig """ conf_file = os.path.join(_get_config_dir(), 'log_config.toml') if o...
def _get_config(): """Determines if there is a log config in the config directory and returns it. If it does not exist, return None. Returns: log_config (dict): The dictionary to pass to logging.config.dictConfig """ conf_file = os.path.join(_get_config_dir(), 'log_config.toml') if o...
[ "Determines", "if", "there", "is", "a", "log", "config", "in", "the", "config", "directory", "and", "returns", "it", ".", "If", "it", "does", "not", "exist", "return", "None", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/config/logs.py#L36-L57
[ "def", "_get_config", "(", ")", ":", "conf_file", "=", "os", ".", "path", ".", "join", "(", "_get_config_dir", "(", ")", ",", "'log_config.toml'", ")", "if", "os", ".", "path", ".", "exists", "(", "conf_file", ")", ":", "with", "open", "(", "conf_file"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_peer_parser
Adds argument parser for the peer command Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object
cli/sawtooth_cli/peer.py
def add_peer_parser(subparsers, parent_parser): """Adds argument parser for the peer command Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add_parser( 'peer', help='Disp...
def add_peer_parser(subparsers, parent_parser): """Adds argument parser for the peer command Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add_parser( 'peer', help='Disp...
[ "Adds", "argument", "parser", "for", "the", "peer", "command" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/peer.py#L23-L38
[ "def", "add_peer_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'peer'", ",", "help", "=", "'Displays information about validator peers'", ",", "description", "=", "\"Provides a subcommand to list a valida...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockPublisher.pending_batch_info
Returns a tuple of the current size of the pending batch queue and the current queue limit.
validator/sawtooth_validator/journal/publisher.py
def pending_batch_info(self): """Returns a tuple of the current size of the pending batch queue and the current queue limit. """ c_length = ctypes.c_int(0) c_limit = ctypes.c_int(0) self._call( 'pending_batch_info', ctypes.byref(c_length), ...
def pending_batch_info(self): """Returns a tuple of the current size of the pending batch queue and the current queue limit. """ c_length = ctypes.c_int(0) c_limit = ctypes.c_int(0) self._call( 'pending_batch_info', ctypes.byref(c_length), ...
[ "Returns", "a", "tuple", "of", "the", "current", "size", "of", "the", "pending", "batch", "queue", "and", "the", "current", "queue", "limit", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/publisher.py#L242-L253
[ "def", "pending_batch_info", "(", "self", ")", ":", "c_length", "=", "ctypes", ".", "c_int", "(", "0", ")", "c_limit", "=", "ctypes", ".", "c_int", "(", "0", ")", "self", ".", "_call", "(", "'pending_batch_info'", ",", "ctypes", ".", "byref", "(", "c_l...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockPublisher.on_chain_updated
The existing chain has been updated, the current head block has changed. :param chain_head: the new head of block_chain, can be None if no block publishing is desired. :param committed_batches: the set of batches that were committed as part of the new chain. :param unco...
validator/sawtooth_validator/journal/publisher.py
def on_chain_updated(self, chain_head, committed_batches=None, uncommitted_batches=None): """ The existing chain has been updated, the current head block has changed. :param chain_head: the new head of block_chain, can be None if ...
def on_chain_updated(self, chain_head, committed_batches=None, uncommitted_batches=None): """ The existing chain has been updated, the current head block has changed. :param chain_head: the new head of block_chain, can be None if ...
[ "The", "existing", "chain", "has", "been", "updated", "the", "current", "head", "block", "has", "changed", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/publisher.py#L266-L291
[ "def", "on_chain_updated", "(", "self", ",", "chain_head", ",", "committed_batches", "=", "None", ",", "uncommitted_batches", "=", "None", ")", ":", "try", ":", "self", ".", "_py_call", "(", "'on_chain_updated'", ",", "ctypes", ".", "py_object", "(", "chain_he...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_SendReceive._receive_message
Internal coroutine for receiving messages
validator/sawtooth_validator/networking/interconnect.py
def _receive_message(self): """ Internal coroutine for receiving messages """ while True: try: if self._socket.getsockopt(zmq.TYPE) == zmq.ROUTER: zmq_identity, msg_bytes = \ yield from self._socket.recv_multipart() ...
def _receive_message(self): """ Internal coroutine for receiving messages """ while True: try: if self._socket.getsockopt(zmq.TYPE) == zmq.ROUTER: zmq_identity, msg_bytes = \ yield from self._socket.recv_multipart() ...
[ "Internal", "coroutine", "for", "receiving", "messages" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L359-L391
[ "def", "_receive_message", "(", "self", ")", ":", "while", "True", ":", "try", ":", "if", "self", ".", "_socket", ".", "getsockopt", "(", "zmq", ".", "TYPE", ")", "==", "zmq", ".", "ROUTER", ":", "zmq_identity", ",", "msg_bytes", "=", "yield", "from", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_SendReceive.send_message
:param msg: protobuf validator_pb2.Message
validator/sawtooth_validator/networking/interconnect.py
def send_message(self, msg, connection_id=None): """ :param msg: protobuf validator_pb2.Message """ zmq_identity = None if connection_id is not None and self._connections is not None: if connection_id in self._connections: connection_info = self._conne...
def send_message(self, msg, connection_id=None): """ :param msg: protobuf validator_pb2.Message """ zmq_identity = None if connection_id is not None and self._connections is not None: if connection_id in self._connections: connection_info = self._conne...
[ ":", "param", "msg", ":", "protobuf", "validator_pb2", ".", "Message" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L397-L427
[ "def", "send_message", "(", "self", ",", "msg", ",", "connection_id", "=", "None", ")", ":", "zmq_identity", "=", "None", "if", "connection_id", "is", "not", "None", "and", "self", ".", "_connections", "is", "not", "None", ":", "if", "connection_id", "in",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_SendReceive.send_last_message
Should be used instead of send_message, when you want to close the connection once the message is sent. :param msg: protobuf validator_pb2.Message
validator/sawtooth_validator/networking/interconnect.py
def send_last_message(self, msg, connection_id=None): """ Should be used instead of send_message, when you want to close the connection once the message is sent. :param msg: protobuf validator_pb2.Message """ zmq_identity = None if connection_id is not None and s...
def send_last_message(self, msg, connection_id=None): """ Should be used instead of send_message, when you want to close the connection once the message is sent. :param msg: protobuf validator_pb2.Message """ zmq_identity = None if connection_id is not None and s...
[ "Should", "be", "used", "instead", "of", "send_message", "when", "you", "want", "to", "close", "the", "connection", "once", "the", "message", "is", "sent", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L449-L479
[ "def", "send_last_message", "(", "self", ",", "msg", ",", "connection_id", "=", "None", ")", ":", "zmq_identity", "=", "None", "if", "connection_id", "is", "not", "None", "and", "self", ".", "_connections", "is", "not", "None", ":", "if", "connection_id", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_SendReceive.setup
Setup the asyncio event loop. Args: socket_type (int from zmq.*): One of zmq.DEALER or zmq.ROUTER complete_or_error_queue (queue.Queue): A way to propagate errors back to the calling thread. Needed since this function is directly used in Thread. ...
validator/sawtooth_validator/networking/interconnect.py
def setup(self, socket_type, complete_or_error_queue): """Setup the asyncio event loop. Args: socket_type (int from zmq.*): One of zmq.DEALER or zmq.ROUTER complete_or_error_queue (queue.Queue): A way to propagate errors back to the calling thread. Needed since t...
def setup(self, socket_type, complete_or_error_queue): """Setup the asyncio event loop. Args: socket_type (int from zmq.*): One of zmq.DEALER or zmq.ROUTER complete_or_error_queue (queue.Queue): A way to propagate errors back to the calling thread. Needed since t...
[ "Setup", "the", "asyncio", "event", "loop", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L481-L590
[ "def", "setup", "(", "self", ",", "socket_type", ",", "complete_or_error_queue", ")", ":", "try", ":", "if", "self", ".", "_secured", ":", "if", "self", ".", "_server_public_key", "is", "None", "or", "self", ".", "_server_private_key", "is", "None", ":", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.connection_id_to_public_key
Get stored public key for a connection.
validator/sawtooth_validator/networking/interconnect.py
def connection_id_to_public_key(self, connection_id): """ Get stored public key for a connection. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.public_key except KeyE...
def connection_id_to_public_key(self, connection_id): """ Get stored public key for a connection. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.public_key except KeyE...
[ "Get", "stored", "public", "key", "for", "a", "connection", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L762-L771
[ "def", "connection_id_to_public_key", "(", "self", ",", "connection_id", ")", ":", "with", "self", ".", "_connections_lock", ":", "try", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id", "]", "return", "connection_info", ".", "public_...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.public_key_to_connection_id
Get stored connection id for a public key.
validator/sawtooth_validator/networking/interconnect.py
def public_key_to_connection_id(self, public_key): """ Get stored connection id for a public key. """ with self._connections_lock: for connection_id, connection_info in self._connections.items(): if connection_info.public_key == public_key: ...
def public_key_to_connection_id(self, public_key): """ Get stored connection id for a public key. """ with self._connections_lock: for connection_id, connection_info in self._connections.items(): if connection_info.public_key == public_key: ...
[ "Get", "stored", "connection", "id", "for", "a", "public", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L773-L782
[ "def", "public_key_to_connection_id", "(", "self", ",", "public_key", ")", ":", "with", "self", ".", "_connections_lock", ":", "for", "connection_id", ",", "connection_info", "in", "self", ".", "_connections", ".", "items", "(", ")", ":", "if", "connection_info"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.connection_id_to_endpoint
Get stored public key for a connection.
validator/sawtooth_validator/networking/interconnect.py
def connection_id_to_endpoint(self, connection_id): """ Get stored public key for a connection. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.uri except KeyError: ...
def connection_id_to_endpoint(self, connection_id): """ Get stored public key for a connection. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.uri except KeyError: ...
[ "Get", "stored", "public", "key", "for", "a", "connection", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L784-L793
[ "def", "connection_id_to_endpoint", "(", "self", ",", "connection_id", ")", ":", "with", "self", ".", "_connections_lock", ":", "try", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id", "]", "return", "connection_info", ".", "uri", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.get_connection_status
Get status of the connection during Role enforcement.
validator/sawtooth_validator/networking/interconnect.py
def get_connection_status(self, connection_id): """ Get status of the connection during Role enforcement. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.status except ...
def get_connection_status(self, connection_id): """ Get status of the connection during Role enforcement. """ with self._connections_lock: try: connection_info = self._connections[connection_id] return connection_info.status except ...
[ "Get", "status", "of", "the", "connection", "during", "Role", "enforcement", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L795-L804
[ "def", "get_connection_status", "(", "self", ",", "connection_id", ")", ":", "with", "self", ".", "_connections_lock", ":", "try", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id", "]", "return", "connection_info", ".", "status", "e...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.allow_inbound_connection
Determines if an additional incoming network connection should be permitted. Returns: bool
validator/sawtooth_validator/networking/interconnect.py
def allow_inbound_connection(self): """Determines if an additional incoming network connection should be permitted. Returns: bool """ LOGGER.debug("Determining whether inbound connection should " "be allowed. num connections: %s max %s", ...
def allow_inbound_connection(self): """Determines if an additional incoming network connection should be permitted. Returns: bool """ LOGGER.debug("Determining whether inbound connection should " "be allowed. num connections: %s max %s", ...
[ "Determines", "if", "an", "additional", "incoming", "network", "connection", "should", "be", "permitted", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L821-L832
[ "def", "allow_inbound_connection", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"Determining whether inbound connection should \"", "\"be allowed. num connections: %s max %s\"", ",", "len", "(", "self", ".", "_connections", ")", ",", "self", ".", "_max_incoming_c...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.add_outbound_connection
Adds an outbound connection to the network. Args: uri (str): The zmq-style (e.g. tcp://hostname:port) uri to attempt to connect to.
validator/sawtooth_validator/networking/interconnect.py
def add_outbound_connection(self, uri): """Adds an outbound connection to the network. Args: uri (str): The zmq-style (e.g. tcp://hostname:port) uri to attempt to connect to. """ LOGGER.debug("Adding connection to %s", uri) conn = OutboundConnection( ...
def add_outbound_connection(self, uri): """Adds an outbound connection to the network. Args: uri (str): The zmq-style (e.g. tcp://hostname:port) uri to attempt to connect to. """ LOGGER.debug("Adding connection to %s", uri) conn = OutboundConnection( ...
[ "Adds", "an", "outbound", "connection", "to", "the", "network", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L834-L868
[ "def", "add_outbound_connection", "(", "self", ",", "uri", ")", ":", "LOGGER", ".", "debug", "(", "\"Adding connection to %s\"", ",", "uri", ")", "conn", "=", "OutboundConnection", "(", "connections", "=", "self", ".", "_connections", ",", "endpoint", "=", "ur...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.send_connect_request
Send ConnectionRequest to an inbound connection. This allows the validator to be authorized by the incoming connection.
validator/sawtooth_validator/networking/interconnect.py
def send_connect_request(self, connection_id): """ Send ConnectionRequest to an inbound connection. This allows the validator to be authorized by the incoming connection. """ connect_message = ConnectionRequest(endpoint=self._public_endpoint) self._safe_send( ...
def send_connect_request(self, connection_id): """ Send ConnectionRequest to an inbound connection. This allows the validator to be authorized by the incoming connection. """ connect_message = ConnectionRequest(endpoint=self._public_endpoint) self._safe_send( ...
[ "Send", "ConnectionRequest", "to", "an", "inbound", "connection", ".", "This", "allows", "the", "validator", "to", "be", "authorized", "by", "the", "incoming", "connection", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L870-L882
[ "def", "send_connect_request", "(", "self", ",", "connection_id", ")", ":", "connect_message", "=", "ConnectionRequest", "(", "endpoint", "=", "self", ".", "_public_endpoint", ")", "self", ".", "_safe_send", "(", "validator_pb2", ".", "Message", ".", "NETWORK_CONN...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.send
Send a message of message_type :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message.* enum value :param data: bytes serialized protobuf :return: future.Future
validator/sawtooth_validator/networking/interconnect.py
def send(self, message_type, data, connection_id, callback=None, one_way=False): """ Send a message of message_type :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message.* enum value :param data: bytes serialized ...
def send(self, message_type, data, connection_id, callback=None, one_way=False): """ Send a message of message_type :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message.* enum value :param data: bytes serialized ...
[ "Send", "a", "message", "of", "message_type", ":", "param", "connection_id", ":", "the", "identity", "for", "the", "connection", "to", "send", "to", ":", "param", "message_type", ":", "validator_pb2", ".", "Message", ".", "*", "enum", "value", ":", "param", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1038-L1076
[ "def", "send", "(", "self", ",", "message_type", ",", "data", ",", "connection_id", ",", "callback", "=", "None", ",", "one_way", "=", "False", ")", ":", "if", "connection_id", "not", "in", "self", ".", "_connections", ":", "raise", "ValueError", "(", "\...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.get_connection_id_by_endpoint
Returns the connection id associated with a publically reachable endpoint or raises KeyError if the endpoint is not found. Args: endpoint (str): A zmq-style uri which identifies a publically reachable endpoint.
validator/sawtooth_validator/networking/interconnect.py
def get_connection_id_by_endpoint(self, endpoint): """Returns the connection id associated with a publically reachable endpoint or raises KeyError if the endpoint is not found. Args: endpoint (str): A zmq-style uri which identifies a publically reachable endp...
def get_connection_id_by_endpoint(self, endpoint): """Returns the connection id associated with a publically reachable endpoint or raises KeyError if the endpoint is not found. Args: endpoint (str): A zmq-style uri which identifies a publically reachable endp...
[ "Returns", "the", "connection", "id", "associated", "with", "a", "publically", "reachable", "endpoint", "or", "raises", "KeyError", "if", "the", "endpoint", "is", "not", "found", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1097-L1111
[ "def", "get_connection_id_by_endpoint", "(", "self", ",", "endpoint", ")", ":", "with", "self", ".", "_connections_lock", ":", "for", "connection_id", "in", "self", ".", "_connections", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.update_connection_endpoint
Adds the endpoint to the connection definition. When the connection is created by the send/receive thread, we do not yet have the endpoint of the remote node. That is not known until we process the incoming ConnectRequest. Args: connection_id (str): The identifier for the co...
validator/sawtooth_validator/networking/interconnect.py
def update_connection_endpoint(self, connection_id, endpoint): """Adds the endpoint to the connection definition. When the connection is created by the send/receive thread, we do not yet have the endpoint of the remote node. That is not known until we process the incoming ConnectRequest....
def update_connection_endpoint(self, connection_id, endpoint): """Adds the endpoint to the connection definition. When the connection is created by the send/receive thread, we do not yet have the endpoint of the remote node. That is not known until we process the incoming ConnectRequest....
[ "Adds", "the", "endpoint", "to", "the", "connection", "definition", ".", "When", "the", "connection", "is", "created", "by", "the", "send", "/", "receive", "thread", "we", "do", "not", "yet", "have", "the", "endpoint", "of", "the", "remote", "node", ".", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1113-L1138
[ "def", "update_connection_endpoint", "(", "self", ",", "connection_id", ",", "endpoint", ")", ":", "if", "connection_id", "in", "self", ".", "_connections", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id", "]", "self", ".", "_conne...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.update_connection_public_key
Adds the public_key to the connection definition. Args: connection_id (str): The identifier for the connection. public_key (str): The public key used to enforce permissions on connections.
validator/sawtooth_validator/networking/interconnect.py
def update_connection_public_key(self, connection_id, public_key): """Adds the public_key to the connection definition. Args: connection_id (str): The identifier for the connection. public_key (str): The public key used to enforce permissions on connections. ...
def update_connection_public_key(self, connection_id, public_key): """Adds the public_key to the connection definition. Args: connection_id (str): The identifier for the connection. public_key (str): The public key used to enforce permissions on connections. ...
[ "Adds", "the", "public_key", "to", "the", "connection", "definition", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1140-L1162
[ "def", "update_connection_public_key", "(", "self", ",", "connection_id", ",", "public_key", ")", ":", "if", "connection_id", "in", "self", ".", "_connections", ":", "connection_info", "=", "self", ".", "_connections", "[", "connection_id", "]", "self", ".", "_c...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Interconnect.send_last_message
Send a message of message_type and close the connection. :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message.* enum value :param data: bytes serialized protobuf :return: future.Future
validator/sawtooth_validator/networking/interconnect.py
def send_last_message(self, message_type, data, connection_id, callback=None, one_way=False): """ Send a message of message_type and close the connection. :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message...
def send_last_message(self, message_type, data, connection_id, callback=None, one_way=False): """ Send a message of message_type and close the connection. :param connection_id: the identity for the connection to send to :param message_type: validator_pb2.Message...
[ "Send", "a", "message", "of", "message_type", "and", "close", "the", "connection", ".", ":", "param", "connection_id", ":", "the", "identity", "for", "the", "connection", "to", "send", "to", ":", "param", "message_type", ":", "validator_pb2", ".", "Message", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1217-L1251
[ "def", "send_last_message", "(", "self", ",", "message_type", ",", "data", ",", "connection_id", ",", "callback", "=", "None", ",", "one_way", "=", "False", ")", ":", "if", "connection_id", "not", "in", "self", ".", "_connections", ":", "raise", "ValueError"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
OutboundConnection.send
Sends a message of message_type Args: message_type (validator_pb2.Message): enum value data (bytes): serialized protobuf callback (function): a callback function to call when a response to this message is received Returns: future.Future
validator/sawtooth_validator/networking/interconnect.py
def send(self, message_type, data, callback=None, one_way=False): """Sends a message of message_type Args: message_type (validator_pb2.Message): enum value data (bytes): serialized protobuf callback (function): a callback function to call when a respo...
def send(self, message_type, data, callback=None, one_way=False): """Sends a message of message_type Args: message_type (validator_pb2.Message): enum value data (bytes): serialized protobuf callback (function): a callback function to call when a respo...
[ "Sends", "a", "message", "of", "message_type" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/interconnect.py#L1324-L1347
[ "def", "send", "(", "self", ",", "message_type", ",", "data", ",", "callback", "=", "None", ",", "one_way", "=", "False", ")", ":", "message", "=", "validator_pb2", ".", "Message", "(", "correlation_id", "=", "_generate_id", "(", ")", ",", "content", "="...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockWrapper.header
Returns the header of the block
validator/sawtooth_validator/journal/block_wrapper.py
def header(self): """ Returns the header of the block """ if self._block_header is None: self._block_header = BlockHeader() self._block_header.ParseFromString(self.block.header) return self._block_header
def header(self): """ Returns the header of the block """ if self._block_header is None: self._block_header = BlockHeader() self._block_header.ParseFromString(self.block.header) return self._block_header
[ "Returns", "the", "header", "of", "the", "block" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_wrapper.py#L73-L80
[ "def", "header", "(", "self", ")", ":", "if", "self", ".", "_block_header", "is", "None", ":", "self", ".", "_block_header", "=", "BlockHeader", "(", ")", "self", ".", "_block_header", ".", "ParseFromString", "(", "self", ".", "block", ".", "header", ")"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockWrapper.state_view_for_block
Returns the state view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a state view is to be returned state_view_factory (StateViewFactory): The state view factory used to create the StateView object Returns: ...
validator/sawtooth_validator/journal/block_wrapper.py
def state_view_for_block(block_wrapper, state_view_factory): """ Returns the state view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a state view is to be returned state_view_factory (StateViewFactory): The state view fa...
def state_view_for_block(block_wrapper, state_view_factory): """ Returns the state view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a state view is to be returned state_view_factory (StateViewFactory): The state view fa...
[ "Returns", "the", "state", "view", "for", "an", "arbitrary", "block", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_wrapper.py#L123-L140
[ "def", "state_view_for_block", "(", "block_wrapper", ",", "state_view_factory", ")", ":", "state_root_hash", "=", "block_wrapper", ".", "state_root_hash", "if", "block_wrapper", "is", "not", "None", "else", "None", "return", "state_view_factory", ".", "create_view", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockWrapper.settings_view_for_block
Returns the settings view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a settings view is to be returned settings_view_factory (SettingsViewFactory): The settings view factory used to create the SettingsView object ...
validator/sawtooth_validator/journal/block_wrapper.py
def settings_view_for_block(block_wrapper, settings_view_factory): """ Returns the settings view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a settings view is to be returned settings_view_factory (SettingsViewFactory):...
def settings_view_for_block(block_wrapper, settings_view_factory): """ Returns the settings view for an arbitrary block. Args: block_wrapper (BlockWrapper): The block for which a settings view is to be returned settings_view_factory (SettingsViewFactory):...
[ "Returns", "the", "settings", "view", "for", "an", "arbitrary", "block", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_wrapper.py#L156-L173
[ "def", "settings_view_for_block", "(", "block_wrapper", ",", "settings_view_factory", ")", ":", "state_root_hash", "=", "block_wrapper", ".", "state_root_hash", "if", "block_wrapper", "is", "not", "None", "else", "None", "return", "settings_view_factory", ".", "create_s...
8cf473bc2207e51f02bd182d825158a57d72b098
train
anonymize
Anonymize IPv4 and IPv6 :param remote_addr: to /24 (zero'd) and /48 (zero'd).
isso/utils/__init__.py
def anonymize(remote_addr): """ Anonymize IPv4 and IPv6 :param remote_addr: to /24 (zero'd) and /48 (zero'd). """ if not isinstance(remote_addr, text_type) and isinstance(remote_addr, str): remote_addr = remote_addr.decode('ascii', 'ignore') try: ipv4 = ipaddress.IPv4Address(rem...
def anonymize(remote_addr): """ Anonymize IPv4 and IPv6 :param remote_addr: to /24 (zero'd) and /48 (zero'd). """ if not isinstance(remote_addr, text_type) and isinstance(remote_addr, str): remote_addr = remote_addr.decode('ascii', 'ignore') try: ipv4 = ipaddress.IPv4Address(rem...
[ "Anonymize", "IPv4", "and", "IPv6", ":", "param", "remote_addr", ":", "to", "/", "24", "(", "zero", "d", ")", "and", "/", "48", "(", "zero", "d", ")", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/utils/__init__.py#L26-L44
[ "def", "anonymize", "(", "remote_addr", ")", ":", "if", "not", "isinstance", "(", "remote_addr", ",", "text_type", ")", "and", "isinstance", "(", "remote_addr", ",", "str", ")", ":", "remote_addr", "=", "remote_addr", ".", "decode", "(", "'ascii'", ",", "'...
78997f491044b7d694ac7170edc32030544095b7
train
thread
Extract <h1> title from web page. The title is *probably* the text node, which is the nearest H1 node in context to an element with the `isso-thread` id.
isso/utils/parse.py
def thread(data, default=u"Untitled.", id=None): """ Extract <h1> title from web page. The title is *probably* the text node, which is the nearest H1 node in context to an element with the `isso-thread` id. """ html = html5lib.parse(data, treebuilder="dom") assert html.lastChild.nodeName == "h...
def thread(data, default=u"Untitled.", id=None): """ Extract <h1> title from web page. The title is *probably* the text node, which is the nearest H1 node in context to an element with the `isso-thread` id. """ html = html5lib.parse(data, treebuilder="dom") assert html.lastChild.nodeName == "h...
[ "Extract", "<h1", ">", "title", "from", "web", "page", ".", "The", "title", "is", "*", "probably", "*", "the", "text", "node", "which", "is", "the", "nearest", "H1", "node", "in", "context", "to", "an", "element", "with", "the", "isso", "-", "thread", ...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/utils/parse.py#L21-L80
[ "def", "thread", "(", "data", ",", "default", "=", "u\"Untitled.\"", ",", "id", "=", "None", ")", ":", "html", "=", "html5lib", ".", "parse", "(", "data", ",", "treebuilder", "=", "\"dom\"", ")", "assert", "html", ".", "lastChild", ".", "nodeName", "==...
78997f491044b7d694ac7170edc32030544095b7
train
Generic.insert
Process a thread and insert its comments in the DB.
isso/migrate.py
def insert(self, thread): """Process a thread and insert its comments in the DB.""" thread_id = thread['id'] title = thread['title'] self.db.threads.new(thread_id, title) comments = list(map(self._build_comment, thread['comments'])) comments.sort(key=lambda comment: comm...
def insert(self, thread): """Process a thread and insert its comments in the DB.""" thread_id = thread['id'] title = thread['title'] self.db.threads.new(thread_id, title) comments = list(map(self._build_comment, thread['comments'])) comments.sort(key=lambda comment: comm...
[ "Process", "a", "thread", "and", "insert", "its", "comments", "in", "the", "DB", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/migrate.py#L284-L294
[ "def", "insert", "(", "self", ",", "thread", ")", ":", "thread_id", "=", "thread", "[", "'id'", "]", "title", "=", "thread", "[", "'title'", "]", "self", ".", "db", ".", "threads", ".", "new", "(", "thread_id", ",", "title", ")", "comments", "=", "...
78997f491044b7d694ac7170edc32030544095b7
train
Generic.migrate
Process the input file and fill the DB.
isso/migrate.py
def migrate(self): """Process the input file and fill the DB.""" with io.open(self.json_file, 'rt', encoding='utf8') as fh: threads = json.load(fh) progress = Progress(len(threads)) for i, thread in enumerate(threads): progress.update(i, str(i)) self....
def migrate(self): """Process the input file and fill the DB.""" with io.open(self.json_file, 'rt', encoding='utf8') as fh: threads = json.load(fh) progress = Progress(len(threads)) for i, thread in enumerate(threads): progress.update(i, str(i)) self....
[ "Process", "the", "input", "file", "and", "fill", "the", "DB", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/migrate.py#L296-L306
[ "def", "migrate", "(", "self", ")", ":", "with", "io", ".", "open", "(", "self", ".", "json_file", ",", "'rt'", ",", "encoding", "=", "'utf8'", ")", "as", "fh", ":", "threads", "=", "json", ".", "load", "(", "fh", ")", "progress", "=", "Progress", ...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.add
Add new comment to DB and return a mapping of :attribute:`fields` and database values.
isso/db/comments.py
def add(self, uri, c): """ Add new comment to DB and return a mapping of :attribute:`fields` and database values. """ if c.get("parent") is not None: ref = self.get(c["parent"]) if ref.get("parent") is not None: c["parent"] = ref["parent"]...
def add(self, uri, c): """ Add new comment to DB and return a mapping of :attribute:`fields` and database values. """ if c.get("parent") is not None: ref = self.get(c["parent"]) if ref.get("parent") is not None: c["parent"] = ref["parent"]...
[ "Add", "new", "comment", "to", "DB", "and", "return", "a", "mapping", "of", ":", "attribute", ":", "fields", "and", "database", "values", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L43-L73
[ "def", "add", "(", "self", ",", "uri", ",", "c", ")", ":", "if", "c", ".", "get", "(", "\"parent\"", ")", "is", "not", "None", ":", "ref", "=", "self", ".", "get", "(", "c", "[", "\"parent\"", "]", ")", "if", "ref", ".", "get", "(", "\"parent...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.unsubscribe
Turn off email notifications for replies to this comment.
isso/db/comments.py
def unsubscribe(self, email, id): """ Turn off email notifications for replies to this comment. """ self.db.execute([ 'UPDATE comments SET', ' notification=0', 'WHERE email=? AND (id=? OR parent=?);'], (email, id, id))
def unsubscribe(self, email, id): """ Turn off email notifications for replies to this comment. """ self.db.execute([ 'UPDATE comments SET', ' notification=0', 'WHERE email=? AND (id=? OR parent=?);'], (email, id, id))
[ "Turn", "off", "email", "notifications", "for", "replies", "to", "this", "comment", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L84-L91
[ "def", "unsubscribe", "(", "self", ",", "email", ",", "id", ")", ":", "self", ".", "db", ".", "execute", "(", "[", "'UPDATE comments SET'", ",", "' notification=0'", ",", "'WHERE email=? AND (id=? OR parent=?);'", "]", ",", "(", "email", ",", "id", ",", "...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.update
Update comment :param:`id` with values from :param:`data` and return updated comment.
isso/db/comments.py
def update(self, id, data): """ Update comment :param:`id` with values from :param:`data` and return updated comment. """ self.db.execute([ 'UPDATE comments SET', ','.join(key + '=' + '?' for key in data), 'WHERE id=?;'], list(data....
def update(self, id, data): """ Update comment :param:`id` with values from :param:`data` and return updated comment. """ self.db.execute([ 'UPDATE comments SET', ','.join(key + '=' + '?' for key in data), 'WHERE id=?;'], list(data....
[ "Update", "comment", ":", "param", ":", "id", "with", "values", "from", ":", "param", ":", "data", "and", "return", "updated", "comment", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L93-L104
[ "def", "update", "(", "self", ",", "id", ",", "data", ")", ":", "self", ".", "db", ".", "execute", "(", "[", "'UPDATE comments SET'", ",", "','", ".", "join", "(", "key", "+", "'='", "+", "'?'", "for", "key", "in", "data", ")", ",", "'WHERE id=?;'"...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.get
Search for comment :param:`id` and return a mapping of :attr:`fields` and values.
isso/db/comments.py
def get(self, id): """ Search for comment :param:`id` and return a mapping of :attr:`fields` and values. """ rv = self.db.execute( 'SELECT * FROM comments WHERE id=?', (id, )).fetchone() if rv: return dict(zip(Comments.fields, rv)) return ...
def get(self, id): """ Search for comment :param:`id` and return a mapping of :attr:`fields` and values. """ rv = self.db.execute( 'SELECT * FROM comments WHERE id=?', (id, )).fetchone() if rv: return dict(zip(Comments.fields, rv)) return ...
[ "Search", "for", "comment", ":", "param", ":", "id", "and", "return", "a", "mapping", "of", ":", "attr", ":", "fields", "and", "values", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L106-L116
[ "def", "get", "(", "self", ",", "id", ")", ":", "rv", "=", "self", ".", "db", ".", "execute", "(", "'SELECT * FROM comments WHERE id=?'", ",", "(", "id", ",", ")", ")", ".", "fetchone", "(", ")", "if", "rv", ":", "return", "dict", "(", "zip", "(", ...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.fetchall
Return comments for admin with :param:`mode`.
isso/db/comments.py
def fetchall(self, mode=5, after=0, parent='any', order_by='id', limit=100, page=0, asc=1): """ Return comments for admin with :param:`mode`. """ fields_comments = ['tid', 'id', 'parent', 'created', 'modified', 'mode', 'remote_addr', 'text', 'a...
def fetchall(self, mode=5, after=0, parent='any', order_by='id', limit=100, page=0, asc=1): """ Return comments for admin with :param:`mode`. """ fields_comments = ['tid', 'id', 'parent', 'created', 'modified', 'mode', 'remote_addr', 'text', 'a...
[ "Return", "comments", "for", "admin", "with", ":", "param", ":", "mode", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L127-L173
[ "def", "fetchall", "(", "self", ",", "mode", "=", "5", ",", "after", "=", "0", ",", "parent", "=", "'any'", ",", "order_by", "=", "'id'", ",", "limit", "=", "100", ",", "page", "=", "0", ",", "asc", "=", "1", ")", ":", "fields_comments", "=", "...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.fetch
Return comments for :param:`uri` with :param:`mode`.
isso/db/comments.py
def fetch(self, uri, mode=5, after=0, parent='any', order_by='id', asc=1, limit=None): """ Return comments for :param:`uri` with :param:`mode`. """ sql = ['SELECT comments.* FROM comments INNER JOIN threads ON', ' threads.uri=? AND comments.tid=threads.id ...
def fetch(self, uri, mode=5, after=0, parent='any', order_by='id', asc=1, limit=None): """ Return comments for :param:`uri` with :param:`mode`. """ sql = ['SELECT comments.* FROM comments INNER JOIN threads ON', ' threads.uri=? AND comments.tid=threads.id ...
[ "Return", "comments", "for", ":", "param", ":", "uri", "with", ":", "param", ":", "mode", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L175-L207
[ "def", "fetch", "(", "self", ",", "uri", ",", "mode", "=", "5", ",", "after", "=", "0", ",", "parent", "=", "'any'", ",", "order_by", "=", "'id'", ",", "asc", "=", "1", ",", "limit", "=", "None", ")", ":", "sql", "=", "[", "'SELECT comments.* FRO...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.delete
Delete a comment. There are two distinctions: a comment is referenced by another valid comment's parent attribute or stand-a-lone. In this case the comment can't be removed without losing depending comments. Hence, delete removes all visible data such as text, author, email, website sets...
isso/db/comments.py
def delete(self, id): """ Delete a comment. There are two distinctions: a comment is referenced by another valid comment's parent attribute or stand-a-lone. In this case the comment can't be removed without losing depending comments. Hence, delete removes all visible data such as...
def delete(self, id): """ Delete a comment. There are two distinctions: a comment is referenced by another valid comment's parent attribute or stand-a-lone. In this case the comment can't be removed without losing depending comments. Hence, delete removes all visible data such as...
[ "Delete", "a", "comment", ".", "There", "are", "two", "distinctions", ":", "a", "comment", "is", "referenced", "by", "another", "valid", "comment", "s", "parent", "attribute", "or", "stand", "-", "a", "-", "lone", ".", "In", "this", "case", "the", "comme...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L224-L250
[ "def", "delete", "(", "self", ",", "id", ")", ":", "refs", "=", "self", ".", "db", ".", "execute", "(", "'SELECT * FROM comments WHERE parent=?'", ",", "(", "id", ",", ")", ")", ".", "fetchone", "(", ")", "if", "refs", "is", "None", ":", "self", ".",...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.vote
+1 a given comment. Returns the new like count (may not change because the creater can't vote on his/her own comment and multiple votes from the same ip address are ignored as well).
isso/db/comments.py
def vote(self, upvote, id, remote_addr): """+1 a given comment. Returns the new like count (may not change because the creater can't vote on his/her own comment and multiple votes from the same ip address are ignored as well).""" rv = self.db.execute( 'SELECT likes, dislikes...
def vote(self, upvote, id, remote_addr): """+1 a given comment. Returns the new like count (may not change because the creater can't vote on his/her own comment and multiple votes from the same ip address are ignored as well).""" rv = self.db.execute( 'SELECT likes, dislikes...
[ "+", "1", "a", "given", "comment", ".", "Returns", "the", "new", "like", "count", "(", "may", "not", "change", "because", "the", "creater", "can", "t", "vote", "on", "his", "/", "her", "own", "comment", "and", "multiple", "votes", "from", "the", "same"...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L252-L281
[ "def", "vote", "(", "self", ",", "upvote", ",", "id", ",", "remote_addr", ")", ":", "rv", "=", "self", ".", "db", ".", "execute", "(", "'SELECT likes, dislikes, voters FROM comments WHERE id=?'", ",", "(", "id", ",", ")", ")", ".", "fetchone", "(", ")", ...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.reply_count
Return comment count for main thread and all reply threads for one url.
isso/db/comments.py
def reply_count(self, url, mode=5, after=0): """ Return comment count for main thread and all reply threads for one url. """ sql = ['SELECT comments.parent,count(*)', 'FROM comments INNER JOIN threads ON', ' threads.uri=? AND comments.tid=threads.id AND',...
def reply_count(self, url, mode=5, after=0): """ Return comment count for main thread and all reply threads for one url. """ sql = ['SELECT comments.parent,count(*)', 'FROM comments INNER JOIN threads ON', ' threads.uri=? AND comments.tid=threads.id AND',...
[ "Return", "comment", "count", "for", "main", "thread", "and", "all", "reply", "threads", "for", "one", "url", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L283-L295
[ "def", "reply_count", "(", "self", ",", "url", ",", "mode", "=", "5", ",", "after", "=", "0", ")", ":", "sql", "=", "[", "'SELECT comments.parent,count(*)'", ",", "'FROM comments INNER JOIN threads ON'", ",", "' threads.uri=? AND comments.tid=threads.id AND'", ",", ...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.count
Return comment count for one ore more urls..
isso/db/comments.py
def count(self, *urls): """ Return comment count for one ore more urls.. """ threads = dict(self.db.execute([ 'SELECT threads.uri, COUNT(comments.id) FROM comments', 'LEFT OUTER JOIN threads ON threads.id = tid AND comments.mode = 1', 'GROUP BY thread...
def count(self, *urls): """ Return comment count for one ore more urls.. """ threads = dict(self.db.execute([ 'SELECT threads.uri, COUNT(comments.id) FROM comments', 'LEFT OUTER JOIN threads ON threads.id = tid AND comments.mode = 1', 'GROUP BY thread...
[ "Return", "comment", "count", "for", "one", "ore", "more", "urls", ".." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L297-L308
[ "def", "count", "(", "self", ",", "*", "urls", ")", ":", "threads", "=", "dict", "(", "self", ".", "db", ".", "execute", "(", "[", "'SELECT threads.uri, COUNT(comments.id) FROM comments'", ",", "'LEFT OUTER JOIN threads ON threads.id = tid AND comments.mode = 1'", ",", ...
78997f491044b7d694ac7170edc32030544095b7
train
Comments.purge
Remove comments older than :param:`delta`.
isso/db/comments.py
def purge(self, delta): """ Remove comments older than :param:`delta`. """ self.db.execute([ 'DELETE FROM comments WHERE mode = 2 AND ? - created > ?;' ], (time.time(), delta)) self._remove_stale()
def purge(self, delta): """ Remove comments older than :param:`delta`. """ self.db.execute([ 'DELETE FROM comments WHERE mode = 2 AND ? - created > ?;' ], (time.time(), delta)) self._remove_stale()
[ "Remove", "comments", "older", "than", ":", "param", ":", "delta", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/db/comments.py#L310-L317
[ "def", "purge", "(", "self", ",", "delta", ")", ":", "self", ".", "db", ".", "execute", "(", "[", "'DELETE FROM comments WHERE mode = 2 AND ? - created > ?;'", "]", ",", "(", "time", ".", "time", "(", ")", ",", "delta", ")", ")", "self", ".", "_remove_stal...
78997f491044b7d694ac7170edc32030544095b7
train
timedelta
Parse :param string: into :class:`datetime.timedelta`, you can use any (logical) combination of Nw, Nd, Nh and Nm, e.g. `1h30m` for 1 hour, 30 minutes or `3w` for 3 weeks. Raises a ValueError if the input is invalid/unparseable. >>> print(timedelta("3w")) 21 days, 0:00:00 >>> print(timedelta("...
isso/config.py
def timedelta(string): """ Parse :param string: into :class:`datetime.timedelta`, you can use any (logical) combination of Nw, Nd, Nh and Nm, e.g. `1h30m` for 1 hour, 30 minutes or `3w` for 3 weeks. Raises a ValueError if the input is invalid/unparseable. >>> print(timedelta("3w")) 21 days...
def timedelta(string): """ Parse :param string: into :class:`datetime.timedelta`, you can use any (logical) combination of Nw, Nd, Nh and Nm, e.g. `1h30m` for 1 hour, 30 minutes or `3w` for 3 weeks. Raises a ValueError if the input is invalid/unparseable. >>> print(timedelta("3w")) 21 days...
[ "Parse", ":", "param", "string", ":", "into", ":", "class", ":", "datetime", ".", "timedelta", "you", "can", "use", "any", "(", "logical", ")", "combination", "of", "Nw", "Nd", "Nh", "and", "Nm", "e", ".", "g", ".", "1h30m", "for", "1", "hour", "30...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/config.py#L20-L50
[ "def", "timedelta", "(", "string", ")", ":", "keys", "=", "[", "\"weeks\"", ",", "\"days\"", ",", "\"hours\"", ",", "\"minutes\"", ",", "\"seconds\"", "]", "regex", "=", "\"\"", ".", "join", "(", "[", "\"((?P<%s>\\\\d+)%s ?)?\"", "%", "(", "k", ",", "k",...
78997f491044b7d694ac7170edc32030544095b7
train
new
Factory to create hash functions from configuration section. If an algorithm takes custom parameters, you can separate them by a colon like this: pbkdf2:arg1:arg2:arg3.
isso/utils/hash.py
def new(conf): """Factory to create hash functions from configuration section. If an algorithm takes custom parameters, you can separate them by a colon like this: pbkdf2:arg1:arg2:arg3.""" algorithm = conf.get("algorithm") salt = conf.get("salt").encode("utf-8") if algorithm == "none": ...
def new(conf): """Factory to create hash functions from configuration section. If an algorithm takes custom parameters, you can separate them by a colon like this: pbkdf2:arg1:arg2:arg3.""" algorithm = conf.get("algorithm") salt = conf.get("salt").encode("utf-8") if algorithm == "none": ...
[ "Factory", "to", "create", "hash", "functions", "from", "configuration", "section", ".", "If", "an", "algorithm", "takes", "custom", "parameters", "you", "can", "separate", "them", "by", "a", "colon", "like", "this", ":", "pbkdf2", ":", "arg1", ":", "arg2", ...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/utils/hash.py#L88-L109
[ "def", "new", "(", "conf", ")", ":", "algorithm", "=", "conf", ".", "get", "(", "\"algorithm\"", ")", "salt", "=", "conf", ".", "get", "(", "\"salt\"", ")", ".", "encode", "(", "\"utf-8\"", ")", "if", "algorithm", "==", "\"none\"", ":", "return", "Ha...
78997f491044b7d694ac7170edc32030544095b7
train
Hash.hash
Calculate hash from value (must be bytes).
isso/utils/hash.py
def hash(self, val): """Calculate hash from value (must be bytes).""" if not isinstance(val, bytes): raise _TypeError("val", "bytes", val) rv = self.compute(val) if not isinstance(val, bytes): raise _TypeError("val", "bytes", rv) return rv
def hash(self, val): """Calculate hash from value (must be bytes).""" if not isinstance(val, bytes): raise _TypeError("val", "bytes", val) rv = self.compute(val) if not isinstance(val, bytes): raise _TypeError("val", "bytes", rv) return rv
[ "Calculate", "hash", "from", "value", "(", "must", "be", "bytes", ")", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/utils/hash.py#L44-L55
[ "def", "hash", "(", "self", ",", "val", ")", ":", "if", "not", "isinstance", "(", "val", ",", "bytes", ")", ":", "raise", "_TypeError", "(", "\"val\"", ",", "\"bytes\"", ",", "val", ")", "rv", "=", "self", ".", "compute", "(", "val", ")", "if", "...
78997f491044b7d694ac7170edc32030544095b7
train
Hash.uhash
Calculate hash from unicode value and return hex value as unicode
isso/utils/hash.py
def uhash(self, val): """Calculate hash from unicode value and return hex value as unicode""" if not isinstance(val, string_types): raise _TypeError("val", "str", val) return codecs.encode(self.hash(val.encode("utf-8")), "hex_codec").decode("utf-8")
def uhash(self, val): """Calculate hash from unicode value and return hex value as unicode""" if not isinstance(val, string_types): raise _TypeError("val", "str", val) return codecs.encode(self.hash(val.encode("utf-8")), "hex_codec").decode("utf-8")
[ "Calculate", "hash", "from", "unicode", "value", "and", "return", "hex", "value", "as", "unicode" ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/utils/hash.py#L57-L63
[ "def", "uhash", "(", "self", ",", "val", ")", ":", "if", "not", "isinstance", "(", "val", ",", "string_types", ")", ":", "raise", "_TypeError", "(", "\"val\"", ",", "\"str\"", ",", "val", ")", "return", "codecs", ".", "encode", "(", "self", ".", "has...
78997f491044b7d694ac7170edc32030544095b7
train
xhr
A decorator to check for CSRF on POST/PUT/DELETE using a <form> element and JS to execute automatically (see #40 for a proof-of-concept). When an attacker uses a <form> to downvote a comment, the browser *should* add a `Content-Type: ...` header with three possible values: * application/x-www-form-url...
isso/views/comments.py
def xhr(func): """A decorator to check for CSRF on POST/PUT/DELETE using a <form> element and JS to execute automatically (see #40 for a proof-of-concept). When an attacker uses a <form> to downvote a comment, the browser *should* add a `Content-Type: ...` header with three possible values: * appl...
def xhr(func): """A decorator to check for CSRF on POST/PUT/DELETE using a <form> element and JS to execute automatically (see #40 for a proof-of-concept). When an attacker uses a <form> to downvote a comment, the browser *should* add a `Content-Type: ...` header with three possible values: * appl...
[ "A", "decorator", "to", "check", "for", "CSRF", "on", "POST", "/", "PUT", "/", "DELETE", "using", "a", "<form", ">", "element", "and", "JS", "to", "execute", "automatically", "(", "see", "#40", "for", "a", "proof", "-", "of", "-", "concept", ")", "."...
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/views/comments.py#L68-L95
[ "def", "xhr", "(", "func", ")", ":", "\"\"\"\n @apiDefine csrf\n @apiHeader {string=\"application/json\"} Content-Type\n The content type must be set to `application/json` to prevent CSRF attacks.\n \"\"\"", "def", "dec", "(", "self", ",", "env", ",", "req", ",", "*",...
78997f491044b7d694ac7170edc32030544095b7
train
API.moderate
@api {get} / get comments @apiGroup Thread @apiDescription Queries the comments of a thread. @apiParam {string} uri The URI of thread to get the comments from. @apiParam {number} [parent] Return only comments that are children of the comment with the provided ID....
isso/views/comments.py
def moderate(self, environ, request, id, action, key): try: id = self.isso.unsign(key, max_age=2**32) except (BadSignature, SignatureExpired): raise Forbidden item = self.comments.get(id) thread = self.threads.get(item['tid']) link = local("origin") + thr...
def moderate(self, environ, request, id, action, key): try: id = self.isso.unsign(key, max_age=2**32) except (BadSignature, SignatureExpired): raise Forbidden item = self.comments.get(id) thread = self.threads.get(item['tid']) link = local("origin") + thr...
[ "@api", "{", "get", "}", "/", "get", "comments", "@apiGroup", "Thread", "@apiDescription", "Queries", "the", "comments", "of", "a", "thread", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/views/comments.py#L603-L738
[ "def", "moderate", "(", "self", ",", "environ", ",", "request", ",", "id", ",", "action", ",", "key", ")", ":", "try", ":", "id", "=", "self", ".", "isso", ".", "unsign", "(", "key", ",", "max_age", "=", "2", "**", "32", ")", "except", "(", "Ba...
78997f491044b7d694ac7170edc32030544095b7
train
threaded
Decorator to execute each :param func: call in a separate thread.
isso/core.py
def threaded(func): """ Decorator to execute each :param func: call in a separate thread. """ def dec(self, *args, **kwargs): thread.start_new_thread(func, (self, ) + args, kwargs) return dec
def threaded(func): """ Decorator to execute each :param func: call in a separate thread. """ def dec(self, *args, **kwargs): thread.start_new_thread(func, (self, ) + args, kwargs) return dec
[ "Decorator", "to", "execute", "each", ":", "param", "func", ":", "call", "in", "a", "separate", "thread", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/core.py#L55-L63
[ "def", "threaded", "(", "func", ")", ":", "def", "dec", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "thread", ".", "start_new_thread", "(", "func", ",", "(", "self", ",", ")", "+", "args", ",", "kwargs", ")", "return", "dec"...
78997f491044b7d694ac7170edc32030544095b7
train
host
Reconstruct host from environment. A modified version of http://www.python.org/dev/peps/pep-0333/#url-reconstruction
isso/wsgi.py
def host(environ): # pragma: no cover """ Reconstruct host from environment. A modified version of http://www.python.org/dev/peps/pep-0333/#url-reconstruction """ url = environ['wsgi.url_scheme'] + '://' if environ.get('HTTP_HOST'): url += environ['HTTP_HOST'] else: url +=...
def host(environ): # pragma: no cover """ Reconstruct host from environment. A modified version of http://www.python.org/dev/peps/pep-0333/#url-reconstruction """ url = environ['wsgi.url_scheme'] + '://' if environ.get('HTTP_HOST'): url += environ['HTTP_HOST'] else: url +=...
[ "Reconstruct", "host", "from", "environment", ".", "A", "modified", "version", "of", "http", ":", "//", "www", ".", "python", ".", "org", "/", "dev", "/", "peps", "/", "pep", "-", "0333", "/", "#url", "-", "reconstruction" ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/wsgi.py#L27-L47
[ "def", "host", "(", "environ", ")", ":", "# pragma: no cover", "url", "=", "environ", "[", "'wsgi.url_scheme'", "]", "+", "'://'", "if", "environ", ".", "get", "(", "'HTTP_HOST'", ")", ":", "url", "+=", "environ", "[", "'HTTP_HOST'", "]", "else", ":", "u...
78997f491044b7d694ac7170edc32030544095b7
train
urlsplit
Parse :param:`name` into (netloc, port, ssl)
isso/wsgi.py
def urlsplit(name): """ Parse :param:`name` into (netloc, port, ssl) """ if not (isinstance(name, string_types)): name = str(name) if not name.startswith(('http://', 'https://')): name = 'http://' + name rv = urlparse(name) if rv.scheme == 'https' and rv.port is None: ...
def urlsplit(name): """ Parse :param:`name` into (netloc, port, ssl) """ if not (isinstance(name, string_types)): name = str(name) if not name.startswith(('http://', 'https://')): name = 'http://' + name rv = urlparse(name) if rv.scheme == 'https' and rv.port is None: ...
[ "Parse", ":", "param", ":", "name", "into", "(", "netloc", "port", "ssl", ")" ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/wsgi.py#L50-L64
[ "def", "urlsplit", "(", "name", ")", ":", "if", "not", "(", "isinstance", "(", "name", ",", "string_types", ")", ")", ":", "name", "=", "str", "(", "name", ")", "if", "not", "name", ".", "startswith", "(", "(", "'http://'", ",", "'https://'", ")", ...
78997f491044b7d694ac7170edc32030544095b7
train
urljoin
Basically the counter-part of :func:`urlsplit`.
isso/wsgi.py
def urljoin(netloc, port, ssl): """ Basically the counter-part of :func:`urlsplit`. """ rv = ("https" if ssl else "http") + "://" + netloc if ssl and port != 443 or not ssl and port != 80: rv += ":%i" % port return rv
def urljoin(netloc, port, ssl): """ Basically the counter-part of :func:`urlsplit`. """ rv = ("https" if ssl else "http") + "://" + netloc if ssl and port != 443 or not ssl and port != 80: rv += ":%i" % port return rv
[ "Basically", "the", "counter", "-", "part", "of", ":", "func", ":", "urlsplit", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/wsgi.py#L67-L75
[ "def", "urljoin", "(", "netloc", ",", "port", ",", "ssl", ")", ":", "rv", "=", "(", "\"https\"", "if", "ssl", "else", "\"http\"", ")", "+", "\"://\"", "+", "netloc", "if", "ssl", "and", "port", "!=", "443", "or", "not", "ssl", "and", "port", "!=", ...
78997f491044b7d694ac7170edc32030544095b7
train
origin
Return a function that returns a valid HTTP Origin or localhost if none found.
isso/wsgi.py
def origin(hosts): """ Return a function that returns a valid HTTP Origin or localhost if none found. """ hosts = [urlsplit(h) for h in hosts] def func(environ): if 'ISSO_CORS_ORIGIN' in environ: return environ['ISSO_CORS_ORIGIN'] if not hosts: return "...
def origin(hosts): """ Return a function that returns a valid HTTP Origin or localhost if none found. """ hosts = [urlsplit(h) for h in hosts] def func(environ): if 'ISSO_CORS_ORIGIN' in environ: return environ['ISSO_CORS_ORIGIN'] if not hosts: return "...
[ "Return", "a", "function", "that", "returns", "a", "valid", "HTTP", "Origin", "or", "localhost", "if", "none", "found", "." ]
posativ/isso
python
https://github.com/posativ/isso/blob/78997f491044b7d694ac7170edc32030544095b7/isso/wsgi.py#L78-L104
[ "def", "origin", "(", "hosts", ")", ":", "hosts", "=", "[", "urlsplit", "(", "h", ")", "for", "h", "in", "hosts", "]", "def", "func", "(", "environ", ")", ":", "if", "'ISSO_CORS_ORIGIN'", "in", "environ", ":", "return", "environ", "[", "'ISSO_CORS_ORIG...
78997f491044b7d694ac7170edc32030544095b7
train
URLOpener.urlopen
Same as urllib2.urlopen or urllib.request.urlopen, the only difference is that it links to the internal opener.
glad/opener.py
def urlopen(self, url, data=None, *args, **kwargs): """ Same as urllib2.urlopen or urllib.request.urlopen, the only difference is that it links to the internal opener. """ logger.info('opening: \'%s\'', url) if data is None: return self.opener.open(url) ...
def urlopen(self, url, data=None, *args, **kwargs): """ Same as urllib2.urlopen or urllib.request.urlopen, the only difference is that it links to the internal opener. """ logger.info('opening: \'%s\'', url) if data is None: return self.opener.open(url) ...
[ "Same", "as", "urllib2", ".", "urlopen", "or", "urllib", ".", "request", ".", "urlopen", "the", "only", "difference", "is", "that", "it", "links", "to", "the", "internal", "opener", "." ]
Dav1dde/glad
python
https://github.com/Dav1dde/glad/blob/6d1f1fe1895832b8957d58f1e8f6df8865c56f94/glad/opener.py#L75-L85
[ "def", "urlopen", "(", "self", ",", "url", ",", "data", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'opening: \\'%s\\''", ",", "url", ")", "if", "data", "is", "None", ":", "return", "self", ".", ...
6d1f1fe1895832b8957d58f1e8f6df8865c56f94
train
URLOpener.urlretrieve
Similar to urllib.urlretrieve or urllib.request.urlretrieve only that *filname* is required. :param url: URL to download. :param filename: Filename to save the content to. :param data: Valid URL-encoded data. :return: Tuple containing path and headers.
glad/opener.py
def urlretrieve(self, url, filename, data=None): """ Similar to urllib.urlretrieve or urllib.request.urlretrieve only that *filname* is required. :param url: URL to download. :param filename: Filename to save the content to. :param data: Valid URL-encoded data. :...
def urlretrieve(self, url, filename, data=None): """ Similar to urllib.urlretrieve or urllib.request.urlretrieve only that *filname* is required. :param url: URL to download. :param filename: Filename to save the content to. :param data: Valid URL-encoded data. :...
[ "Similar", "to", "urllib", ".", "urlretrieve", "or", "urllib", ".", "request", ".", "urlretrieve", "only", "that", "*", "filname", "*", "is", "required", "." ]
Dav1dde/glad
python
https://github.com/Dav1dde/glad/blob/6d1f1fe1895832b8957d58f1e8f6df8865c56f94/glad/opener.py#L87-L102
[ "def", "urlretrieve", "(", "self", ",", "url", ",", "filename", ",", "data", "=", "None", ")", ":", "logger", ".", "info", "(", "'saving: \\'%s\\' to \\'%s\\''", ",", "url", ",", "filename", ")", "if", "_is_py3", ":", "return", "_urlretrieve_with_opener", "(...
6d1f1fe1895832b8957d58f1e8f6df8865c56f94
train
parse_url
parse url and the result is tuple of (hostname, port, resource path and the flag of secure mode) url: url string.
websocket/_url.py
def parse_url(url): """ parse url and the result is tuple of (hostname, port, resource path and the flag of secure mode) url: url string. """ if ":" not in url: raise ValueError("url is invalid") scheme, url = url.split(":", 1) parsed = urlparse(url, scheme="ws") if parsed...
def parse_url(url): """ parse url and the result is tuple of (hostname, port, resource path and the flag of secure mode) url: url string. """ if ":" not in url: raise ValueError("url is invalid") scheme, url = url.split(":", 1) parsed = urlparse(url, scheme="ws") if parsed...
[ "parse", "url", "and", "the", "result", "is", "tuple", "of", "(", "hostname", "port", "resource", "path", "and", "the", "flag", "of", "secure", "mode", ")" ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_url.py#L33-L73
[ "def", "parse_url", "(", "url", ")", ":", "if", "\":\"", "not", "in", "url", ":", "raise", "ValueError", "(", "\"url is invalid\"", ")", "scheme", ",", "url", "=", "url", ".", "split", "(", "\":\"", ",", "1", ")", "parsed", "=", "urlparse", "(", "url...
3c25814664fef5b78716ed8841123ed1c0d17824
train
get_proxy_info
try to retrieve proxy host and port from environment if not provided in options. result is (proxy_host, proxy_port, proxy_auth). proxy_auth is tuple of username and password of proxy authentication information. hostname: websocket server name. is_secure: is the connection secure? (wss) ...
websocket/_url.py
def get_proxy_info( hostname, is_secure, proxy_host=None, proxy_port=0, proxy_auth=None, no_proxy=None, proxy_type='http'): """ try to retrieve proxy host and port from environment if not provided in options. result is (proxy_host, proxy_port, proxy_auth). proxy_auth is tuple of user...
def get_proxy_info( hostname, is_secure, proxy_host=None, proxy_port=0, proxy_auth=None, no_proxy=None, proxy_type='http'): """ try to retrieve proxy host and port from environment if not provided in options. result is (proxy_host, proxy_port, proxy_auth). proxy_auth is tuple of user...
[ "try", "to", "retrieve", "proxy", "host", "and", "port", "from", "environment", "if", "not", "provided", "in", "options", ".", "result", "is", "(", "proxy_host", "proxy_port", "proxy_auth", ")", ".", "proxy_auth", "is", "tuple", "of", "username", "and", "pas...
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_url.py#L118-L163
[ "def", "get_proxy_info", "(", "hostname", ",", "is_secure", ",", "proxy_host", "=", "None", ",", "proxy_port", "=", "0", ",", "proxy_auth", "=", "None", ",", "no_proxy", "=", "None", ",", "proxy_type", "=", "'http'", ")", ":", "if", "_is_no_proxy_host", "(...
3c25814664fef5b78716ed8841123ed1c0d17824
train
create_connection
connect to url and return websocket object. Connect to url and return the WebSocket object. Passing optional timeout parameter will set the timeout on the socket. If no timeout is supplied, the global default timeout setting returned by getdefauttimeout() is used. You can customize using 'options'....
websocket/_core.py
def create_connection(url, timeout=None, class_=WebSocket, **options): """ connect to url and return websocket object. Connect to url and return the WebSocket object. Passing optional timeout parameter will set the timeout on the socket. If no timeout is supplied, the global default timeout set...
def create_connection(url, timeout=None, class_=WebSocket, **options): """ connect to url and return websocket object. Connect to url and return the WebSocket object. Passing optional timeout parameter will set the timeout on the socket. If no timeout is supplied, the global default timeout set...
[ "connect", "to", "url", "and", "return", "websocket", "object", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L461-L515
[ "def", "create_connection", "(", "url", ",", "timeout", "=", "None", ",", "class_", "=", "WebSocket", ",", "*", "*", "options", ")", ":", "sockopt", "=", "options", ".", "pop", "(", "\"sockopt\"", ",", "[", "]", ")", "sslopt", "=", "options", ".", "p...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.settimeout
Set the timeout to the websocket. timeout: timeout time(second).
websocket/_core.py
def settimeout(self, timeout): """ Set the timeout to the websocket. timeout: timeout time(second). """ self.sock_opt.timeout = timeout if self.sock: self.sock.settimeout(timeout)
def settimeout(self, timeout): """ Set the timeout to the websocket. timeout: timeout time(second). """ self.sock_opt.timeout = timeout if self.sock: self.sock.settimeout(timeout)
[ "Set", "the", "timeout", "to", "the", "websocket", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L138-L146
[ "def", "settimeout", "(", "self", ",", "timeout", ")", ":", "self", ".", "sock_opt", ".", "timeout", "=", "timeout", "if", "self", ".", "sock", ":", "self", ".", "sock", ".", "settimeout", "(", "timeout", ")" ]
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.connect
Connect to url. url is websocket url scheme. ie. ws://host:port/resource You can customize using 'options'. If you set "header" list object, you can set your own custom header. >>> ws = WebSocket() >>> ws.connect("ws://echo.websocket.org/", ... header=["User-...
websocket/_core.py
def connect(self, url, **options): """ Connect to url. url is websocket url scheme. ie. ws://host:port/resource You can customize using 'options'. If you set "header" list object, you can set your own custom header. >>> ws = WebSocket() >>> ws.connect("ws://echo....
def connect(self, url, **options): """ Connect to url. url is websocket url scheme. ie. ws://host:port/resource You can customize using 'options'. If you set "header" list object, you can set your own custom header. >>> ws = WebSocket() >>> ws.connect("ws://echo....
[ "Connect", "to", "url", ".", "url", "is", "websocket", "url", "scheme", ".", "ie", ".", "ws", ":", "//", "host", ":", "port", "/", "resource", "You", "can", "customize", "using", "options", ".", "If", "you", "set", "header", "list", "object", "you", ...
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L186-L239
[ "def", "connect", "(", "self", ",", "url", ",", "*", "*", "options", ")", ":", "# FIXME: \"subprotocols\" are getting lost, not passed down", "# FIXME: \"header\", \"cookie\", \"origin\" and \"host\" too", "self", ".", "sock_opt", ".", "timeout", "=", "options", ".", "get...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.send
Send the data as string. payload: Payload must be utf-8 string or unicode, if the opcode is OPCODE_TEXT. Otherwise, it must be string(byte array) opcode: operation code to send. Please see OPCODE_XXX.
websocket/_core.py
def send(self, payload, opcode=ABNF.OPCODE_TEXT): """ Send the data as string. payload: Payload must be utf-8 string or unicode, if the opcode is OPCODE_TEXT. Otherwise, it must be string(byte array) opcode: operation code to send. Please see OPCODE_...
def send(self, payload, opcode=ABNF.OPCODE_TEXT): """ Send the data as string. payload: Payload must be utf-8 string or unicode, if the opcode is OPCODE_TEXT. Otherwise, it must be string(byte array) opcode: operation code to send. Please see OPCODE_...
[ "Send", "the", "data", "as", "string", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L241-L253
[ "def", "send", "(", "self", ",", "payload", ",", "opcode", "=", "ABNF", ".", "OPCODE_TEXT", ")", ":", "frame", "=", "ABNF", ".", "create_frame", "(", "payload", ",", "opcode", ")", "return", "self", ".", "send_frame", "(", "frame", ")" ]
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.send_frame
Send the data frame. frame: frame data created by ABNF.create_frame >>> ws = create_connection("ws://echo.websocket.org/") >>> frame = ABNF.create_frame("Hello", ABNF.OPCODE_TEXT) >>> ws.send_frame(frame) >>> cont_frame = ABNF.create_frame("My name is ", ABNF.OPCODE_CONT, 0) ...
websocket/_core.py
def send_frame(self, frame): """ Send the data frame. frame: frame data created by ABNF.create_frame >>> ws = create_connection("ws://echo.websocket.org/") >>> frame = ABNF.create_frame("Hello", ABNF.OPCODE_TEXT) >>> ws.send_frame(frame) >>> cont_frame = ABNF.c...
def send_frame(self, frame): """ Send the data frame. frame: frame data created by ABNF.create_frame >>> ws = create_connection("ws://echo.websocket.org/") >>> frame = ABNF.create_frame("Hello", ABNF.OPCODE_TEXT) >>> ws.send_frame(frame) >>> cont_frame = ABNF.c...
[ "Send", "the", "data", "frame", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L255-L281
[ "def", "send_frame", "(", "self", ",", "frame", ")", ":", "if", "self", ".", "get_mask_key", ":", "frame", ".", "get_mask_key", "=", "self", ".", "get_mask_key", "data", "=", "frame", ".", "format", "(", ")", "length", "=", "len", "(", "data", ")", "...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.ping
send ping data. payload: data payload to send server.
websocket/_core.py
def ping(self, payload=""): """ send ping data. payload: data payload to send server. """ if isinstance(payload, six.text_type): payload = payload.encode("utf-8") self.send(payload, ABNF.OPCODE_PING)
def ping(self, payload=""): """ send ping data. payload: data payload to send server. """ if isinstance(payload, six.text_type): payload = payload.encode("utf-8") self.send(payload, ABNF.OPCODE_PING)
[ "send", "ping", "data", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L286-L294
[ "def", "ping", "(", "self", ",", "payload", "=", "\"\"", ")", ":", "if", "isinstance", "(", "payload", ",", "six", ".", "text_type", ")", ":", "payload", "=", "payload", ".", "encode", "(", "\"utf-8\"", ")", "self", ".", "send", "(", "payload", ",", ...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.pong
send pong data. payload: data payload to send server.
websocket/_core.py
def pong(self, payload): """ send pong data. payload: data payload to send server. """ if isinstance(payload, six.text_type): payload = payload.encode("utf-8") self.send(payload, ABNF.OPCODE_PONG)
def pong(self, payload): """ send pong data. payload: data payload to send server. """ if isinstance(payload, six.text_type): payload = payload.encode("utf-8") self.send(payload, ABNF.OPCODE_PONG)
[ "send", "pong", "data", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L296-L304
[ "def", "pong", "(", "self", ",", "payload", ")", ":", "if", "isinstance", "(", "payload", ",", "six", ".", "text_type", ")", ":", "payload", "=", "payload", ".", "encode", "(", "\"utf-8\"", ")", "self", ".", "send", "(", "payload", ",", "ABNF", ".", ...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.recv
Receive string data(byte array) from the server. return value: string(byte array) value.
websocket/_core.py
def recv(self): """ Receive string data(byte array) from the server. return value: string(byte array) value. """ with self.readlock: opcode, data = self.recv_data() if six.PY3 and opcode == ABNF.OPCODE_TEXT: return data.decode("utf-8") eli...
def recv(self): """ Receive string data(byte array) from the server. return value: string(byte array) value. """ with self.readlock: opcode, data = self.recv_data() if six.PY3 and opcode == ABNF.OPCODE_TEXT: return data.decode("utf-8") eli...
[ "Receive", "string", "data", "(", "byte", "array", ")", "from", "the", "server", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L306-L319
[ "def", "recv", "(", "self", ")", ":", "with", "self", ".", "readlock", ":", "opcode", ",", "data", "=", "self", ".", "recv_data", "(", ")", "if", "six", ".", "PY3", "and", "opcode", "==", "ABNF", ".", "OPCODE_TEXT", ":", "return", "data", ".", "dec...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.recv_data
Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value.
websocket/_core.py
def recv_data(self, control_frame=False): """ Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value. """ opcode, fram...
def recv_data(self, control_frame=False): """ Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value. """ opcode, fram...
[ "Receive", "data", "with", "operation", "code", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L321-L331
[ "def", "recv_data", "(", "self", ",", "control_frame", "=", "False", ")", ":", "opcode", ",", "frame", "=", "self", ".", "recv_data_frame", "(", "control_frame", ")", "return", "opcode", ",", "frame", ".", "data" ]
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.recv_data_frame
Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value.
websocket/_core.py
def recv_data_frame(self, control_frame=False): """ Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value. """ while ...
def recv_data_frame(self, control_frame=False): """ Receive data with operation code. control_frame: a boolean flag indicating whether to return control frame data, defaults to False return value: tuple of operation code and string(byte array) value. """ while ...
[ "Receive", "data", "with", "operation", "code", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L333-L369
[ "def", "recv_data_frame", "(", "self", ",", "control_frame", "=", "False", ")", ":", "while", "True", ":", "frame", "=", "self", ".", "recv_frame", "(", ")", "if", "not", "frame", ":", "# handle error:", "# 'NoneType' object has no attribute 'opcode'", "raise", ...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.send_close
send close data to the server. status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string or bytes.
websocket/_core.py
def send_close(self, status=STATUS_NORMAL, reason=six.b("")): """ send close data to the server. status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string or bytes. """ if status < 0 or status >= ABNF.LENGTH_16: raise Valu...
def send_close(self, status=STATUS_NORMAL, reason=six.b("")): """ send close data to the server. status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string or bytes. """ if status < 0 or status >= ABNF.LENGTH_16: raise Valu...
[ "send", "close", "data", "to", "the", "server", "." ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L379-L390
[ "def", "send_close", "(", "self", ",", "status", "=", "STATUS_NORMAL", ",", "reason", "=", "six", ".", "b", "(", "\"\"", ")", ")", ":", "if", "status", "<", "0", "or", "status", ">=", "ABNF", ".", "LENGTH_16", ":", "raise", "ValueError", "(", "\"code...
3c25814664fef5b78716ed8841123ed1c0d17824
train
WebSocket.close
Close Websocket object status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string. timeout: timeout until receive a close frame. If None, it will wait forever until receive a close frame.
websocket/_core.py
def close(self, status=STATUS_NORMAL, reason=six.b(""), timeout=3): """ Close Websocket object status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string. timeout: timeout until receive a close frame. If None, it will wait forever...
def close(self, status=STATUS_NORMAL, reason=six.b(""), timeout=3): """ Close Websocket object status: status code to send. see STATUS_XXX. reason: the reason to close. This must be string. timeout: timeout until receive a close frame. If None, it will wait forever...
[ "Close", "Websocket", "object" ]
websocket-client/websocket-client
python
https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L392-L431
[ "def", "close", "(", "self", ",", "status", "=", "STATUS_NORMAL", ",", "reason", "=", "six", ".", "b", "(", "\"\"", ")", ",", "timeout", "=", "3", ")", ":", "if", "self", ".", "connected", ":", "if", "status", "<", "0", "or", "status", ">=", "ABN...
3c25814664fef5b78716ed8841123ed1c0d17824