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 | Output.generate | Generates a Output from a specifically formed tuple or list.
Note:
If a ThresholdCondition has to be generated where the threshold
is always the number of subconditions it is split between, a
list of the following structure is sufficient:
[(a... | bigchaindb/common/transaction.py | def generate(cls, public_keys, amount):
"""Generates a Output from a specifically formed tuple or list.
Note:
If a ThresholdCondition has to be generated where the threshold
is always the number of subconditions it is split between, a
list of the foll... | def generate(cls, public_keys, amount):
"""Generates a Output from a specifically formed tuple or list.
Note:
If a ThresholdCondition has to be generated where the threshold
is always the number of subconditions it is split between, a
list of the foll... | [
"Generates",
"a",
"Output",
"from",
"a",
"specifically",
"formed",
"tuple",
"or",
"list",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L360-L404 | [
"def",
"generate",
"(",
"cls",
",",
"public_keys",
",",
"amount",
")",
":",
"threshold",
"=",
"len",
"(",
"public_keys",
")",
"if",
"not",
"isinstance",
"(",
"amount",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"'`amount` must be a int'",
")",
"if",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Output._gen_condition | Generates ThresholdSha256 conditions from a list of new owners.
Note:
This method is intended only to be used with a reduce function.
For a description on how to use this method, see
:meth:`~.Output.generate`.
Args:
initial (:clas... | bigchaindb/common/transaction.py | def _gen_condition(cls, initial, new_public_keys):
"""Generates ThresholdSha256 conditions from a list of new owners.
Note:
This method is intended only to be used with a reduce function.
For a description on how to use this method, see
:meth:`~.Outpu... | def _gen_condition(cls, initial, new_public_keys):
"""Generates ThresholdSha256 conditions from a list of new owners.
Note:
This method is intended only to be used with a reduce function.
For a description on how to use this method, see
:meth:`~.Outpu... | [
"Generates",
"ThresholdSha256",
"conditions",
"from",
"a",
"list",
"of",
"new",
"owners",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L407-L451 | [
"def",
"_gen_condition",
"(",
"cls",
",",
"initial",
",",
"new_public_keys",
")",
":",
"try",
":",
"threshold",
"=",
"len",
"(",
"new_public_keys",
")",
"except",
"TypeError",
":",
"threshold",
"=",
"None",
"if",
"isinstance",
"(",
"new_public_keys",
",",
"l... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Output.from_dict | Transforms a Python dictionary to an Output object.
Note:
To pass a serialization cycle multiple times, a
Cryptoconditions Fulfillment needs to be present in the
passed-in dictionary, as Condition URIs are not serializable
anymore.
... | bigchaindb/common/transaction.py | def from_dict(cls, data):
"""Transforms a Python dictionary to an Output object.
Note:
To pass a serialization cycle multiple times, a
Cryptoconditions Fulfillment needs to be present in the
passed-in dictionary, as Condition URIs are not serializable... | def from_dict(cls, data):
"""Transforms a Python dictionary to an Output object.
Note:
To pass a serialization cycle multiple times, a
Cryptoconditions Fulfillment needs to be present in the
passed-in dictionary, as Condition URIs are not serializable... | [
"Transforms",
"a",
"Python",
"dictionary",
"to",
"an",
"Output",
"object",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L454-L478 | [
"def",
"from_dict",
"(",
"cls",
",",
"data",
")",
":",
"try",
":",
"fulfillment",
"=",
"_fulfillment_from_details",
"(",
"data",
"[",
"'condition'",
"]",
"[",
"'details'",
"]",
")",
"except",
"KeyError",
":",
"# NOTE: Hashlock condition case",
"fulfillment",
"="... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.spent_outputs | Tuple of :obj:`dict`: Inputs of this transaction. Each input
is represented as a dictionary containing a transaction id and
output index. | bigchaindb/common/transaction.py | def spent_outputs(self):
"""Tuple of :obj:`dict`: Inputs of this transaction. Each input
is represented as a dictionary containing a transaction id and
output index.
"""
return (
input_.fulfills.to_dict()
for input_ in self.inputs if input_.fulfills
... | def spent_outputs(self):
"""Tuple of :obj:`dict`: Inputs of this transaction. Each input
is represented as a dictionary containing a transaction id and
output index.
"""
return (
input_.fulfills.to_dict()
for input_ in self.inputs if input_.fulfills
... | [
"Tuple",
"of",
":",
"obj",
":",
"dict",
":",
"Inputs",
"of",
"this",
"transaction",
".",
"Each",
"input",
"is",
"represented",
"as",
"a",
"dictionary",
"containing",
"a",
"transaction",
"id",
"and",
"output",
"index",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L584-L592 | [
"def",
"spent_outputs",
"(",
"self",
")",
":",
"return",
"(",
"input_",
".",
"fulfills",
".",
"to_dict",
"(",
")",
"for",
"input_",
"in",
"self",
".",
"inputs",
"if",
"input_",
".",
"fulfills",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.create | A simple way to generate a `CREATE` transaction.
Note:
This method currently supports the following Cryptoconditions
use cases:
- Ed25519
- ThresholdSha256
Additionally, it provides support for the following BigchainDB... | bigchaindb/common/transaction.py | def create(cls, tx_signers, recipients, metadata=None, asset=None):
"""A simple way to generate a `CREATE` transaction.
Note:
This method currently supports the following Cryptoconditions
use cases:
- Ed25519
- ThresholdSha256
... | def create(cls, tx_signers, recipients, metadata=None, asset=None):
"""A simple way to generate a `CREATE` transaction.
Note:
This method currently supports the following Cryptoconditions
use cases:
- Ed25519
- ThresholdSha256
... | [
"A",
"simple",
"way",
"to",
"generate",
"a",
"CREATE",
"transaction",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L634-L663 | [
"def",
"create",
"(",
"cls",
",",
"tx_signers",
",",
"recipients",
",",
"metadata",
"=",
"None",
",",
"asset",
"=",
"None",
")",
":",
"(",
"inputs",
",",
"outputs",
")",
"=",
"cls",
".",
"validate_create",
"(",
"tx_signers",
",",
"recipients",
",",
"as... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.transfer | A simple way to generate a `TRANSFER` transaction.
Note:
Different cases for threshold conditions:
Combining multiple `inputs` with an arbitrary number of
`recipients` can yield interesting cases for the creation of
threshold conditions we'd ... | bigchaindb/common/transaction.py | def transfer(cls, inputs, recipients, asset_id, metadata=None):
"""A simple way to generate a `TRANSFER` transaction.
Note:
Different cases for threshold conditions:
Combining multiple `inputs` with an arbitrary number of
`recipients` can yield inter... | def transfer(cls, inputs, recipients, asset_id, metadata=None):
"""A simple way to generate a `TRANSFER` transaction.
Note:
Different cases for threshold conditions:
Combining multiple `inputs` with an arbitrary number of
`recipients` can yield inter... | [
"A",
"simple",
"way",
"to",
"generate",
"a",
"TRANSFER",
"transaction",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L691-L730 | [
"def",
"transfer",
"(",
"cls",
",",
"inputs",
",",
"recipients",
",",
"asset_id",
",",
"metadata",
"=",
"None",
")",
":",
"(",
"inputs",
",",
"outputs",
")",
"=",
"cls",
".",
"validate_transfer",
"(",
"inputs",
",",
"recipients",
",",
"asset_id",
",",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.to_inputs | Converts a Transaction's outputs to spendable inputs.
Note:
Takes the Transaction's outputs and derives inputs
from that can then be passed into `Transaction.transfer` as
`inputs`.
A list of integers can be passed to `indices` that
... | bigchaindb/common/transaction.py | def to_inputs(self, indices=None):
"""Converts a Transaction's outputs to spendable inputs.
Note:
Takes the Transaction's outputs and derives inputs
from that can then be passed into `Transaction.transfer` as
`inputs`.
A list of intege... | def to_inputs(self, indices=None):
"""Converts a Transaction's outputs to spendable inputs.
Note:
Takes the Transaction's outputs and derives inputs
from that can then be passed into `Transaction.transfer` as
`inputs`.
A list of intege... | [
"Converts",
"a",
"Transaction",
"s",
"outputs",
"to",
"spendable",
"inputs",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L739-L767 | [
"def",
"to_inputs",
"(",
"self",
",",
"indices",
"=",
"None",
")",
":",
"# NOTE: If no indices are passed, we just assume to take all outputs",
"# as inputs.",
"indices",
"=",
"indices",
"or",
"range",
"(",
"len",
"(",
"self",
".",
"outputs",
")",
")",
"return... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.add_input | Adds an input to a Transaction's list of inputs.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`): An Input to be added to the Transaction. | bigchaindb/common/transaction.py | def add_input(self, input_):
"""Adds an input to a Transaction's list of inputs.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`): An Input to be added to the Transaction.
"""
if not isinstance(input_, Input):
raise TypeEr... | def add_input(self, input_):
"""Adds an input to a Transaction's list of inputs.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`): An Input to be added to the Transaction.
"""
if not isinstance(input_, Input):
raise TypeEr... | [
"Adds",
"an",
"input",
"to",
"a",
"Transaction",
"s",
"list",
"of",
"inputs",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L769-L778 | [
"def",
"add_input",
"(",
"self",
",",
"input_",
")",
":",
"if",
"not",
"isinstance",
"(",
"input_",
",",
"Input",
")",
":",
"raise",
"TypeError",
"(",
"'`input_` must be a Input instance'",
")",
"self",
".",
"inputs",
".",
"append",
"(",
"input_",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.add_output | Adds an output to a Transaction's list of outputs.
Args:
output (:class:`~bigchaindb.common.transaction.
Output`): An Output to be added to the
Transaction. | bigchaindb/common/transaction.py | def add_output(self, output):
"""Adds an output to a Transaction's list of outputs.
Args:
output (:class:`~bigchaindb.common.transaction.
Output`): An Output to be added to the
Transaction.
"""
if not isinstance(output, Output)... | def add_output(self, output):
"""Adds an output to a Transaction's list of outputs.
Args:
output (:class:`~bigchaindb.common.transaction.
Output`): An Output to be added to the
Transaction.
"""
if not isinstance(output, Output)... | [
"Adds",
"an",
"output",
"to",
"a",
"Transaction",
"s",
"list",
"of",
"outputs",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L780-L790 | [
"def",
"add_output",
"(",
"self",
",",
"output",
")",
":",
"if",
"not",
"isinstance",
"(",
"output",
",",
"Output",
")",
":",
"raise",
"TypeError",
"(",
"'`output` must be an Output instance or None'",
")",
"self",
".",
"outputs",
".",
"append",
"(",
"output",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.sign | Fulfills a previous Transaction's Output by signing Inputs.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256
Furthermore, note that all keys required to f... | bigchaindb/common/transaction.py | def sign(self, private_keys):
"""Fulfills a previous Transaction's Output by signing Inputs.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256
Furt... | def sign(self, private_keys):
"""Fulfills a previous Transaction's Output by signing Inputs.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256
Furt... | [
"Fulfills",
"a",
"previous",
"Transaction",
"s",
"Output",
"by",
"signing",
"Inputs",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L792-L843 | [
"def",
"sign",
"(",
"self",
",",
"private_keys",
")",
":",
"# TODO: Singing should be possible with at least one of all private",
"# keys supplied to this method.",
"if",
"private_keys",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"private_keys",
",",
"list",
")",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction._sign_input | Signs a single Input.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
... | bigchaindb/common/transaction.py | def _sign_input(cls, input_, message, key_pairs):
"""Signs a single Input.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256.
Args:
in... | def _sign_input(cls, input_, message, key_pairs):
"""Signs a single Input.
Note:
This method works only for the following Cryptoconditions
currently:
- Ed25519Fulfillment
- ThresholdSha256.
Args:
in... | [
"Signs",
"a",
"single",
"Input",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L846-L869 | [
"def",
"_sign_input",
"(",
"cls",
",",
"input_",
",",
"message",
",",
"key_pairs",
")",
":",
"if",
"isinstance",
"(",
"input_",
".",
"fulfillment",
",",
"Ed25519Sha256",
")",
":",
"return",
"cls",
".",
"_sign_simple_signature_fulfillment",
"(",
"input_",
",",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction._sign_simple_signature_fulfillment | Signs a Ed25519Fulfillment.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The input to be signed.
message (str): The message to be signed
key_pairs (dict): The keys to sign the Transaction with. | bigchaindb/common/transaction.py | def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs):
"""Signs a Ed25519Fulfillment.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The input to be signed.
message (str): The message to be signed
k... | def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs):
"""Signs a Ed25519Fulfillment.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The input to be signed.
message (str): The message to be signed
k... | [
"Signs",
"a",
"Ed25519Fulfillment",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L872-L901 | [
"def",
"_sign_simple_signature_fulfillment",
"(",
"cls",
",",
"input_",
",",
"message",
",",
"key_pairs",
")",
":",
"# NOTE: To eliminate the dangers of accidentally signing a condition by",
"# reference, we remove the reference of input_ here",
"# intentionally. If the user ... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction._sign_threshold_signature_fulfillment | Signs a ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
message (str): The message to be signed
key_pairs (dict): The keys to sign the Transaction with. | bigchaindb/common/transaction.py | def _sign_threshold_signature_fulfillment(cls, input_, message, key_pairs):
"""Signs a ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
message (str): The message to be signed
k... | def _sign_threshold_signature_fulfillment(cls, input_, message, key_pairs):
"""Signs a ThresholdSha256.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
message (str): The message to be signed
k... | [
"Signs",
"a",
"ThresholdSha256",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L904-L948 | [
"def",
"_sign_threshold_signature_fulfillment",
"(",
"cls",
",",
"input_",
",",
"message",
",",
"key_pairs",
")",
":",
"input_",
"=",
"deepcopy",
"(",
"input_",
")",
"message",
"=",
"sha3_256",
"(",
"message",
".",
"encode",
"(",
")",
")",
"if",
"input_",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction._inputs_valid | Validates an Input against a given set of Outputs.
Note:
The number of `output_condition_uris` must be equal to the
number of Inputs a Transaction has.
Args:
output_condition_uris (:obj:`list` of :obj:`str`): A list of
Outputs... | bigchaindb/common/transaction.py | def _inputs_valid(self, output_condition_uris):
"""Validates an Input against a given set of Outputs.
Note:
The number of `output_condition_uris` must be equal to the
number of Inputs a Transaction has.
Args:
output_condition_uris (:obj:`... | def _inputs_valid(self, output_condition_uris):
"""Validates an Input against a given set of Outputs.
Note:
The number of `output_condition_uris` must be equal to the
number of Inputs a Transaction has.
Args:
output_condition_uris (:obj:`... | [
"Validates",
"an",
"Input",
"against",
"a",
"given",
"set",
"of",
"Outputs",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L982-L1012 | [
"def",
"_inputs_valid",
"(",
"self",
",",
"output_condition_uris",
")",
":",
"if",
"len",
"(",
"self",
".",
"inputs",
")",
"!=",
"len",
"(",
"output_condition_uris",
")",
":",
"raise",
"ValueError",
"(",
"'Inputs and '",
"'output_condition_uris must have the same co... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.to_dict | Transforms the object to a Python dictionary.
Returns:
dict: The Transaction as an alternative serialization format. | bigchaindb/common/transaction.py | def to_dict(self):
"""Transforms the object to a Python dictionary.
Returns:
dict: The Transaction as an alternative serialization format.
"""
return {
'inputs': [input_.to_dict() for input_ in self.inputs],
'outputs': [output.to_dict() for ou... | def to_dict(self):
"""Transforms the object to a Python dictionary.
Returns:
dict: The Transaction as an alternative serialization format.
"""
return {
'inputs': [input_.to_dict() for input_ in self.inputs],
'outputs': [output.to_dict() for ou... | [
"Transforms",
"the",
"object",
"to",
"a",
"Python",
"dictionary",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1065-L1079 | [
"def",
"to_dict",
"(",
"self",
")",
":",
"return",
"{",
"'inputs'",
":",
"[",
"input_",
".",
"to_dict",
"(",
")",
"for",
"input_",
"in",
"self",
".",
"inputs",
"]",
",",
"'outputs'",
":",
"[",
"output",
".",
"to_dict",
"(",
")",
"for",
"output",
"i... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.get_asset_id | Get the asset id from a list of :class:`~.Transactions`.
This is useful when we want to check if the multiple inputs of a
transaction are related to the same asset id.
Args:
transactions (:obj:`list` of :class:`~bigchaindb.common.
transaction.Transaction`): A list o... | bigchaindb/common/transaction.py | def get_asset_id(cls, transactions):
"""Get the asset id from a list of :class:`~.Transactions`.
This is useful when we want to check if the multiple inputs of a
transaction are related to the same asset id.
Args:
transactions (:obj:`list` of :class:`~bigchaindb.common.
... | def get_asset_id(cls, transactions):
"""Get the asset id from a list of :class:`~.Transactions`.
This is useful when we want to check if the multiple inputs of a
transaction are related to the same asset id.
Args:
transactions (:obj:`list` of :class:`~bigchaindb.common.
... | [
"Get",
"the",
"asset",
"id",
"from",
"a",
"list",
"of",
":",
"class",
":",
"~",
".",
"Transactions",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1125-L1157 | [
"def",
"get_asset_id",
"(",
"cls",
",",
"transactions",
")",
":",
"if",
"not",
"isinstance",
"(",
"transactions",
",",
"list",
")",
":",
"transactions",
"=",
"[",
"transactions",
"]",
"# create a set of the transactions' asset ids",
"asset_ids",
"=",
"{",
"tx",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.validate_id | Validate the transaction ID of a transaction
Args:
tx_body (dict): The Transaction to be transformed. | bigchaindb/common/transaction.py | def validate_id(tx_body):
"""Validate the transaction ID of a transaction
Args:
tx_body (dict): The Transaction to be transformed.
"""
# NOTE: Remove reference to avoid side effects
# tx_body = deepcopy(tx_body)
tx_body = rapidjson.loads(rapidjson.dum... | def validate_id(tx_body):
"""Validate the transaction ID of a transaction
Args:
tx_body (dict): The Transaction to be transformed.
"""
# NOTE: Remove reference to avoid side effects
# tx_body = deepcopy(tx_body)
tx_body = rapidjson.loads(rapidjson.dum... | [
"Validate",
"the",
"transaction",
"ID",
"of",
"a",
"transaction"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1160-L1183 | [
"def",
"validate_id",
"(",
"tx_body",
")",
":",
"# NOTE: Remove reference to avoid side effects",
"# tx_body = deepcopy(tx_body)",
"tx_body",
"=",
"rapidjson",
".",
"loads",
"(",
"rapidjson",
".",
"dumps",
"(",
"tx_body",
")",
")",
"try",
":",
"proposed_tx_id",
"=",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.from_dict | Transforms a Python dictionary to a Transaction object.
Args:
tx_body (dict): The Transaction to be transformed.
Returns:
:class:`~bigchaindb.common.transaction.Transaction` | bigchaindb/common/transaction.py | def from_dict(cls, tx, skip_schema_validation=True):
"""Transforms a Python dictionary to a Transaction object.
Args:
tx_body (dict): The Transaction to be transformed.
Returns:
:class:`~bigchaindb.common.transaction.Transaction`
"""
oper... | def from_dict(cls, tx, skip_schema_validation=True):
"""Transforms a Python dictionary to a Transaction object.
Args:
tx_body (dict): The Transaction to be transformed.
Returns:
:class:`~bigchaindb.common.transaction.Transaction`
"""
oper... | [
"Transforms",
"a",
"Python",
"dictionary",
"to",
"a",
"Transaction",
"object",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1187-L1206 | [
"def",
"from_dict",
"(",
"cls",
",",
"tx",
",",
"skip_schema_validation",
"=",
"True",
")",
":",
"operation",
"=",
"tx",
".",
"get",
"(",
"'operation'",
",",
"Transaction",
".",
"CREATE",
")",
"if",
"isinstance",
"(",
"tx",
",",
"dict",
")",
"else",
"T... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.from_db | Helper method that reconstructs a transaction dict that was returned
from the database. It checks what asset_id to retrieve, retrieves the
asset from the asset table and reconstructs the transaction.
Args:
bigchain (:class:`~bigchaindb.tendermint.BigchainDB`): An instance
... | bigchaindb/common/transaction.py | def from_db(cls, bigchain, tx_dict_list):
"""Helper method that reconstructs a transaction dict that was returned
from the database. It checks what asset_id to retrieve, retrieves the
asset from the asset table and reconstructs the transaction.
Args:
bigchain (:class:`~bigch... | def from_db(cls, bigchain, tx_dict_list):
"""Helper method that reconstructs a transaction dict that was returned
from the database. It checks what asset_id to retrieve, retrieves the
asset from the asset table and reconstructs the transaction.
Args:
bigchain (:class:`~bigch... | [
"Helper",
"method",
"that",
"reconstructs",
"a",
"transaction",
"dict",
"that",
"was",
"returned",
"from",
"the",
"database",
".",
"It",
"checks",
"what",
"asset_id",
"to",
"retrieve",
"retrieves",
"the",
"asset",
"from",
"the",
"asset",
"table",
"and",
"recon... | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1209-L1256 | [
"def",
"from_db",
"(",
"cls",
",",
"bigchain",
",",
"tx_dict_list",
")",
":",
"return_list",
"=",
"True",
"if",
"isinstance",
"(",
"tx_dict_list",
",",
"dict",
")",
":",
"tx_dict_list",
"=",
"[",
"tx_dict_list",
"]",
"return_list",
"=",
"False",
"tx_map",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.resolve_class | For the given `tx` based on the `operation` key return its implementation class | bigchaindb/common/transaction.py | def resolve_class(operation):
"""For the given `tx` based on the `operation` key return its implementation class"""
create_txn_class = Transaction.type_registry.get(Transaction.CREATE)
return Transaction.type_registry.get(operation, create_txn_class) | def resolve_class(operation):
"""For the given `tx` based on the `operation` key return its implementation class"""
create_txn_class = Transaction.type_registry.get(Transaction.CREATE)
return Transaction.type_registry.get(operation, create_txn_class) | [
"For",
"the",
"given",
"tx",
"based",
"on",
"the",
"operation",
"key",
"return",
"its",
"implementation",
"class"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/transaction.py#L1264-L1268 | [
"def",
"resolve_class",
"(",
"operation",
")",
":",
"create_txn_class",
"=",
"Transaction",
".",
"type_registry",
".",
"get",
"(",
"Transaction",
".",
"CREATE",
")",
"return",
"Transaction",
".",
"type_registry",
".",
"get",
"(",
"operation",
",",
"create_txn_cl... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | connect | Create a new connection to the database backend.
All arguments default to the current configuration's values if not
given.
Args:
backend (str): the name of the backend to use.
host (str): the host to connect to.
port (int): the port to connect to.
name (str): the name of th... | bigchaindb/backend/connection.py | def connect(backend=None, host=None, port=None, name=None, max_tries=None,
connection_timeout=None, replicaset=None, ssl=None, login=None, password=None,
ca_cert=None, certfile=None, keyfile=None, keyfile_passphrase=None,
crlfile=None):
"""Create a new connection to the database ... | def connect(backend=None, host=None, port=None, name=None, max_tries=None,
connection_timeout=None, replicaset=None, ssl=None, login=None, password=None,
ca_cert=None, certfile=None, keyfile=None, keyfile_passphrase=None,
crlfile=None):
"""Create a new connection to the database ... | [
"Create",
"a",
"new",
"connection",
"to",
"the",
"database",
"backend",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/connection.py#L21-L87 | [
"def",
"connect",
"(",
"backend",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"name",
"=",
"None",
",",
"max_tries",
"=",
"None",
",",
"connection_timeout",
"=",
"None",
",",
"replicaset",
"=",
"None",
",",
"ssl",
"=",
"None... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Connection.connect | Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails. | bigchaindb/backend/connection.py | def connect(self):
"""Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails.
"""
attempt = 0
for i in self.max_tries_counter:
attempt += 1
try:
self._conn = se... | def connect(self):
"""Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails.
"""
attempt = 0
for i in self.max_tries_counter:
attempt += 1
try:
self._conn = se... | [
"Try",
"to",
"connect",
"to",
"the",
"database",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/connection.py#L148-L169 | [
"def",
"connect",
"(",
"self",
")",
":",
"attempt",
"=",
"0",
"for",
"i",
"in",
"self",
".",
"max_tries_counter",
":",
"attempt",
"+=",
"1",
"try",
":",
"self",
".",
"_conn",
"=",
"self",
".",
"_connect",
"(",
")",
"except",
"ConnectionError",
"as",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | ValidatorsApi.get | API endpoint to get validators set.
Return:
A JSON string containing the validator set of the current node. | bigchaindb/web/views/validators.py | def get(self):
"""API endpoint to get validators set.
Return:
A JSON string containing the validator set of the current node.
"""
pool = current_app.config['bigchain_pool']
with pool() as bigchain:
validators = bigchain.get_validators()
return ... | def get(self):
"""API endpoint to get validators set.
Return:
A JSON string containing the validator set of the current node.
"""
pool = current_app.config['bigchain_pool']
with pool() as bigchain:
validators = bigchain.get_validators()
return ... | [
"API",
"endpoint",
"to",
"get",
"validators",
"set",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/validators.py#L10-L22 | [
"def",
"get",
"(",
"self",
")",
":",
"pool",
"=",
"current_app",
".",
"config",
"[",
"'bigchain_pool'",
"]",
"with",
"pool",
"(",
")",
"as",
"bigchain",
":",
"validators",
"=",
"bigchain",
".",
"get_validators",
"(",
")",
"return",
"validators"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.get_validator_change | Return the validator set from the most recent approved block
:return: {
'height': <block_height>,
'validators': <validator_set>
} | bigchaindb/elections/election.py | def get_validator_change(cls, bigchain):
"""Return the validator set from the most recent approved block
:return: {
'height': <block_height>,
'validators': <validator_set>
}
"""
latest_block = bigchain.get_latest_block()
if latest_block is None:
... | def get_validator_change(cls, bigchain):
"""Return the validator set from the most recent approved block
:return: {
'height': <block_height>,
'validators': <validator_set>
}
"""
latest_block = bigchain.get_latest_block()
if latest_block is None:
... | [
"Return",
"the",
"validator",
"set",
"from",
"the",
"most",
"recent",
"approved",
"block"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L43-L54 | [
"def",
"get_validator_change",
"(",
"cls",
",",
"bigchain",
")",
":",
"latest_block",
"=",
"bigchain",
".",
"get_latest_block",
"(",
")",
"if",
"latest_block",
"is",
"None",
":",
"return",
"None",
"return",
"bigchain",
".",
"get_validator_change",
"(",
"latest_b... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.get_validators | Return a dictionary of validators with key as `public_key` and
value as the `voting_power` | bigchaindb/elections/election.py | def get_validators(cls, bigchain, height=None):
"""Return a dictionary of validators with key as `public_key` and
value as the `voting_power`
"""
validators = {}
for validator in bigchain.get_validators(height):
# NOTE: we assume that Tendermint encodes public key ... | def get_validators(cls, bigchain, height=None):
"""Return a dictionary of validators with key as `public_key` and
value as the `voting_power`
"""
validators = {}
for validator in bigchain.get_validators(height):
# NOTE: we assume that Tendermint encodes public key ... | [
"Return",
"a",
"dictionary",
"of",
"validators",
"with",
"key",
"as",
"public_key",
"and",
"value",
"as",
"the",
"voting_power"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L57-L67 | [
"def",
"get_validators",
"(",
"cls",
",",
"bigchain",
",",
"height",
"=",
"None",
")",
":",
"validators",
"=",
"{",
"}",
"for",
"validator",
"in",
"bigchain",
".",
"get_validators",
"(",
"height",
")",
":",
"# NOTE: we assume that Tendermint encodes public key in ... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.recipients | Convert validator dictionary to a recipient list for `Transaction` | bigchaindb/elections/election.py | def recipients(cls, bigchain):
"""Convert validator dictionary to a recipient list for `Transaction`"""
recipients = []
for public_key, voting_power in cls.get_validators(bigchain).items():
recipients.append(([public_key], voting_power))
return recipients | def recipients(cls, bigchain):
"""Convert validator dictionary to a recipient list for `Transaction`"""
recipients = []
for public_key, voting_power in cls.get_validators(bigchain).items():
recipients.append(([public_key], voting_power))
return recipients | [
"Convert",
"validator",
"dictionary",
"to",
"a",
"recipient",
"list",
"for",
"Transaction"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L70-L77 | [
"def",
"recipients",
"(",
"cls",
",",
"bigchain",
")",
":",
"recipients",
"=",
"[",
"]",
"for",
"public_key",
",",
"voting_power",
"in",
"cls",
".",
"get_validators",
"(",
"bigchain",
")",
".",
"items",
"(",
")",
":",
"recipients",
".",
"append",
"(",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.validate | Validate election transaction
NOTE:
* A valid election is initiated by an existing validator.
* A valid election is one where voters are validators and votes are
allocated according to the voting power of each validator node.
Args:
:param bigchain: (BigchainDB) a... | bigchaindb/elections/election.py | def validate(self, bigchain, current_transactions=[]):
"""Validate election transaction
NOTE:
* A valid election is initiated by an existing validator.
* A valid election is one where voters are validators and votes are
allocated according to the voting power of each validato... | def validate(self, bigchain, current_transactions=[]):
"""Validate election transaction
NOTE:
* A valid election is initiated by an existing validator.
* A valid election is one where voters are validators and votes are
allocated according to the voting power of each validato... | [
"Validate",
"election",
"transaction"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L94-L138 | [
"def",
"validate",
"(",
"self",
",",
"bigchain",
",",
"current_transactions",
"=",
"[",
"]",
")",
":",
"input_conditions",
"=",
"[",
"]",
"duplicates",
"=",
"any",
"(",
"txn",
"for",
"txn",
"in",
"current_transactions",
"if",
"txn",
".",
"id",
"==",
"sel... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.validate_schema | Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for
`CREATE` transaction should be inherited | bigchaindb/elections/election.py | def validate_schema(cls, tx):
"""Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for
`CREATE` transaction should be inherited
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
_validate_schema(TX_SCHEMA_CREATE, tx)
if cls.TX_... | def validate_schema(cls, tx):
"""Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for
`CREATE` transaction should be inherited
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
_validate_schema(TX_SCHEMA_CREATE, tx)
if cls.TX_... | [
"Validate",
"the",
"election",
"transaction",
".",
"Since",
"ELECTION",
"extends",
"CREATE",
"transaction",
"all",
"the",
"validations",
"for",
"CREATE",
"transaction",
"should",
"be",
"inherited"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L152-L159 | [
"def",
"validate_schema",
"(",
"cls",
",",
"tx",
")",
":",
"_validate_schema",
"(",
"TX_SCHEMA_COMMON",
",",
"tx",
")",
"_validate_schema",
"(",
"TX_SCHEMA_CREATE",
",",
"tx",
")",
"if",
"cls",
".",
"TX_SCHEMA_CUSTOM",
":",
"_validate_schema",
"(",
"cls",
".",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.has_concluded | Check if the election can be concluded or not.
* Elections can only be concluded if the validator set has not changed
since the election was initiated.
* Elections can be concluded only if the current votes form a supermajority.
Custom elections may override this function and introdu... | bigchaindb/elections/election.py | def has_concluded(self, bigchain, current_votes=[]):
"""Check if the election can be concluded or not.
* Elections can only be concluded if the validator set has not changed
since the election was initiated.
* Elections can be concluded only if the current votes form a supermajority.
... | def has_concluded(self, bigchain, current_votes=[]):
"""Check if the election can be concluded or not.
* Elections can only be concluded if the validator set has not changed
since the election was initiated.
* Elections can be concluded only if the current votes form a supermajority.
... | [
"Check",
"if",
"the",
"election",
"can",
"be",
"concluded",
"or",
"not",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L194-L215 | [
"def",
"has_concluded",
"(",
"self",
",",
"bigchain",
",",
"current_votes",
"=",
"[",
"]",
")",
":",
"if",
"self",
".",
"has_validator_set_changed",
"(",
"bigchain",
")",
":",
"return",
"False",
"election_pk",
"=",
"self",
".",
"to_public_key",
"(",
"self",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.process_block | Looks for election and vote transactions inside the block, records
and processes elections.
Every election is recorded in the database.
Every vote has a chance to conclude the corresponding election. When
an election is concluded, the corresponding database record is
... | bigchaindb/elections/election.py | def process_block(cls, bigchain, new_height, txns):
"""Looks for election and vote transactions inside the block, records
and processes elections.
Every election is recorded in the database.
Every vote has a chance to conclude the corresponding election. When
an ele... | def process_block(cls, bigchain, new_height, txns):
"""Looks for election and vote transactions inside the block, records
and processes elections.
Every election is recorded in the database.
Every vote has a chance to conclude the corresponding election. When
an ele... | [
"Looks",
"for",
"election",
"and",
"vote",
"transactions",
"inside",
"the",
"block",
"records",
"and",
"processes",
"elections",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L278-L322 | [
"def",
"process_block",
"(",
"cls",
",",
"bigchain",
",",
"new_height",
",",
"txns",
")",
":",
"# elections initiated in this block",
"initiated_elections",
"=",
"cls",
".",
"_get_initiated_elections",
"(",
"new_height",
",",
"txns",
")",
"if",
"initiated_elections",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Election.rollback | Looks for election and vote transactions inside the block and
cleans up the database artifacts possibly created in `process_blocks`.
Part of the `end_block`/`commit` crash recovery. | bigchaindb/elections/election.py | def rollback(cls, bigchain, new_height, txn_ids):
"""Looks for election and vote transactions inside the block and
cleans up the database artifacts possibly created in `process_blocks`.
Part of the `end_block`/`commit` crash recovery.
"""
# delete election records for ele... | def rollback(cls, bigchain, new_height, txn_ids):
"""Looks for election and vote transactions inside the block and
cleans up the database artifacts possibly created in `process_blocks`.
Part of the `end_block`/`commit` crash recovery.
"""
# delete election records for ele... | [
"Looks",
"for",
"election",
"and",
"vote",
"transactions",
"inside",
"the",
"block",
"and",
"cleans",
"up",
"the",
"database",
"artifacts",
"possibly",
"created",
"in",
"process_blocks",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/election.py#L325-L341 | [
"def",
"rollback",
"(",
"cls",
",",
"bigchain",
",",
"new_height",
",",
"txn_ids",
")",
":",
"# delete election records for elections initiated at this height and",
"# elections concluded at this height",
"bigchain",
".",
"delete_elections",
"(",
"new_height",
")",
"txns",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Vote.validate_schema | Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER`
transaction, all the validations for `CREATE` transaction should be inherited | bigchaindb/elections/vote.py | def validate_schema(cls, tx):
"""Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER`
transaction, all the validations for `CREATE` transaction should be inherited
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
_validate_schema(TX_SCHEMA_TRANSFER, tx)
... | def validate_schema(cls, tx):
"""Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER`
transaction, all the validations for `CREATE` transaction should be inherited
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
_validate_schema(TX_SCHEMA_TRANSFER, tx)
... | [
"Validate",
"the",
"validator",
"election",
"vote",
"transaction",
".",
"Since",
"VOTE",
"extends",
"TRANSFER",
"transaction",
"all",
"the",
"validations",
"for",
"CREATE",
"transaction",
"should",
"be",
"inherited"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/elections/vote.py#L49-L55 | [
"def",
"validate_schema",
"(",
"cls",
",",
"tx",
")",
":",
"_validate_schema",
"(",
"TX_SCHEMA_COMMON",
",",
"tx",
")",
"_validate_schema",
"(",
"TX_SCHEMA_TRANSFER",
",",
"tx",
")",
"_validate_schema",
"(",
"cls",
".",
"TX_SCHEMA_CUSTOM",
",",
"tx",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | map_leafs | Map a function to the leafs of a mapping. | bigchaindb/config_utils.py | def map_leafs(func, mapping):
"""Map a function to the leafs of a mapping."""
def _inner(mapping, path=None):
if path is None:
path = []
for key, val in mapping.items():
if isinstance(val, collections.Mapping):
_inner(val, path + [key])
else:... | def map_leafs(func, mapping):
"""Map a function to the leafs of a mapping."""
def _inner(mapping, path=None):
if path is None:
path = []
for key, val in mapping.items():
if isinstance(val, collections.Mapping):
_inner(val, path + [key])
else:... | [
"Map",
"a",
"function",
"to",
"the",
"leafs",
"of",
"a",
"mapping",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L46-L61 | [
"def",
"map_leafs",
"(",
"func",
",",
"mapping",
")",
":",
"def",
"_inner",
"(",
"mapping",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"mapping",
".",
"items",
"(",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | file_config | Returns the config values found in a configuration file.
Args:
filename (str): the JSON file with the configuration values.
If ``None``, CONFIG_DEFAULT_PATH will be used.
Returns:
dict: The config values in the specified config file (or the
file at CONFIG_DEFAULT_PATH... | bigchaindb/config_utils.py | def file_config(filename=None):
"""Returns the config values found in a configuration file.
Args:
filename (str): the JSON file with the configuration values.
If ``None``, CONFIG_DEFAULT_PATH will be used.
Returns:
dict: The config values in the specified config file (or the
... | def file_config(filename=None):
"""Returns the config values found in a configuration file.
Args:
filename (str): the JSON file with the configuration values.
If ``None``, CONFIG_DEFAULT_PATH will be used.
Returns:
dict: The config values in the specified config file (or the
... | [
"Returns",
"the",
"config",
"values",
"found",
"in",
"a",
"configuration",
"file",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L90-L117 | [
"def",
"file_config",
"(",
"filename",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'On entry into file_config(), filename = {}'",
".",
"format",
"(",
"filename",
")",
")",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"CONFIG_DEFAULT_PATH",
"log... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | env_config | Return a new configuration with the values found in the environment.
The function recursively iterates over the config, checking if there is
a matching env variable. If an env variable is found, the func updates
the configuration with that value.
The name of the env variable is built combining a prefi... | bigchaindb/config_utils.py | def env_config(config):
"""Return a new configuration with the values found in the environment.
The function recursively iterates over the config, checking if there is
a matching env variable. If an env variable is found, the func updates
the configuration with that value.
The name of the env vari... | def env_config(config):
"""Return a new configuration with the values found in the environment.
The function recursively iterates over the config, checking if there is
a matching env variable. If an env variable is found, the func updates
the configuration with that value.
The name of the env vari... | [
"Return",
"a",
"new",
"configuration",
"with",
"the",
"values",
"found",
"in",
"the",
"environment",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L120-L138 | [
"def",
"env_config",
"(",
"config",
")",
":",
"def",
"load_from_env",
"(",
"value",
",",
"path",
")",
":",
"var_name",
"=",
"CONFIG_SEP",
".",
"join",
"(",
"[",
"CONFIG_PREFIX",
"]",
"+",
"list",
"(",
"map",
"(",
"lambda",
"s",
":",
"s",
".",
"upper"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | update_types | Return a new configuration where all the values types
are aligned with the ones in the default configuration | bigchaindb/config_utils.py | def update_types(config, reference, list_sep=':'):
"""Return a new configuration where all the values types
are aligned with the ones in the default configuration
"""
def _coerce(current, value):
# Coerce a value to the `current` type.
try:
# First we try to apply current to... | def update_types(config, reference, list_sep=':'):
"""Return a new configuration where all the values types
are aligned with the ones in the default configuration
"""
def _coerce(current, value):
# Coerce a value to the `current` type.
try:
# First we try to apply current to... | [
"Return",
"a",
"new",
"configuration",
"where",
"all",
"the",
"values",
"types",
"are",
"aligned",
"with",
"the",
"ones",
"in",
"the",
"default",
"configuration"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L141-L178 | [
"def",
"update_types",
"(",
"config",
",",
"reference",
",",
"list_sep",
"=",
"':'",
")",
":",
"def",
"_coerce",
"(",
"current",
",",
"value",
")",
":",
"# Coerce a value to the `current` type.",
"try",
":",
"# First we try to apply current to the value, since it",
"#... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | set_config | Set bigchaindb.config equal to the default config dict,
then update that with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default config
Note:
Any pre... | bigchaindb/config_utils.py | def set_config(config):
"""Set bigchaindb.config equal to the default config dict,
then update that with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default co... | def set_config(config):
"""Set bigchaindb.config equal to the default config dict,
then update that with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default co... | [
"Set",
"bigchaindb",
".",
"config",
"equal",
"to",
"the",
"default",
"config",
"dict",
"then",
"update",
"that",
"with",
"whatever",
"is",
"in",
"the",
"provided",
"config",
"dict",
"and",
"then",
"set",
"bigchaindb",
".",
"config",
"[",
"CONFIGURED",
"]",
... | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L181-L197 | [
"def",
"set_config",
"(",
"config",
")",
":",
"# Deep copy the default config into bigchaindb.config",
"bigchaindb",
".",
"config",
"=",
"copy",
".",
"deepcopy",
"(",
"bigchaindb",
".",
"_config",
")",
"# Update the default config with whatever is in the passed config",
"upda... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | update_config | Update bigchaindb.config with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default config | bigchaindb/config_utils.py | def update_config(config):
"""Update bigchaindb.config with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default config
"""
# Update the default config wit... | def update_config(config):
"""Update bigchaindb.config with whatever is in the provided config dict,
and then set bigchaindb.config['CONFIGURED'] = True
Args:
config (dict): the config dict to read for changes
to the default config
"""
# Update the default config wit... | [
"Update",
"bigchaindb",
".",
"config",
"with",
"whatever",
"is",
"in",
"the",
"provided",
"config",
"dict",
"and",
"then",
"set",
"bigchaindb",
".",
"config",
"[",
"CONFIGURED",
"]",
"=",
"True"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L200-L211 | [
"def",
"update_config",
"(",
"config",
")",
":",
"# Update the default config with whatever is in the passed config",
"update",
"(",
"bigchaindb",
".",
"config",
",",
"update_types",
"(",
"config",
",",
"bigchaindb",
".",
"config",
")",
")",
"bigchaindb",
".",
"config... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | write_config | Write the provided configuration to a specific location.
Args:
config (dict): a dictionary with the configuration to load.
filename (str): the name of the file that will store the new configuration. Defaults to ``None``.
If ``None``, the HOME of the current user and the string ``.bigcha... | bigchaindb/config_utils.py | def write_config(config, filename=None):
"""Write the provided configuration to a specific location.
Args:
config (dict): a dictionary with the configuration to load.
filename (str): the name of the file that will store the new configuration. Defaults to ``None``.
If ``None``, the H... | def write_config(config, filename=None):
"""Write the provided configuration to a specific location.
Args:
config (dict): a dictionary with the configuration to load.
filename (str): the name of the file that will store the new configuration. Defaults to ``None``.
If ``None``, the H... | [
"Write",
"the",
"provided",
"configuration",
"to",
"a",
"specific",
"location",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L214-L226 | [
"def",
"write_config",
"(",
"config",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"CONFIG_DEFAULT_PATH",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"config",
",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | autoconfigure | Run ``file_config`` and ``env_config`` if the module has not
been initialized. | bigchaindb/config_utils.py | def autoconfigure(filename=None, config=None, force=False):
"""Run ``file_config`` and ``env_config`` if the module has not
been initialized.
"""
if not force and is_configured():
logger.debug('System already configured, skipping autoconfiguration')
return
# start with the current c... | def autoconfigure(filename=None, config=None, force=False):
"""Run ``file_config`` and ``env_config`` if the module has not
been initialized.
"""
if not force and is_configured():
logger.debug('System already configured, skipping autoconfiguration')
return
# start with the current c... | [
"Run",
"file_config",
"and",
"env_config",
"if",
"the",
"module",
"has",
"not",
"been",
"initialized",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L233-L257 | [
"def",
"autoconfigure",
"(",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"if",
"not",
"force",
"and",
"is_configured",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"'System already configured, skipping autoconfigur... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | load_validation_plugin | Find and load the chosen validation plugin.
Args:
name (string): the name of the entry_point, as advertised in the
setup.py of the providing package.
Returns:
an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules`` | bigchaindb/config_utils.py | def load_validation_plugin(name=None):
"""Find and load the chosen validation plugin.
Args:
name (string): the name of the entry_point, as advertised in the
setup.py of the providing package.
Returns:
an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules... | def load_validation_plugin(name=None):
"""Find and load the chosen validation plugin.
Args:
name (string): the name of the entry_point, as advertised in the
setup.py of the providing package.
Returns:
an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules... | [
"Find",
"and",
"load",
"the",
"chosen",
"validation",
"plugin",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/config_utils.py#L261-L294 | [
"def",
"load_validation_plugin",
"(",
"name",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"return",
"BaseValidationRules",
"# TODO: This will return the first plugin with group `bigchaindb.validation`",
"# and name `name` in the active WorkingSet.",
"# We should prob... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | pool | Create a pool that imposes a limit on the number of stored
instances.
Args:
builder: a function to build an instance.
size: the size of the pool.
timeout(Optional[float]): the seconds to wait before raising
a ``queue.Empty`` exception if no instances are available
... | bigchaindb/utils.py | def pool(builder, size, timeout=None):
"""Create a pool that imposes a limit on the number of stored
instances.
Args:
builder: a function to build an instance.
size: the size of the pool.
timeout(Optional[float]): the seconds to wait before raising
a ``queue.Empty`` exce... | def pool(builder, size, timeout=None):
"""Create a pool that imposes a limit on the number of stored
instances.
Args:
builder: a function to build an instance.
size: the size of the pool.
timeout(Optional[float]): the seconds to wait before raising
a ``queue.Empty`` exce... | [
"Create",
"a",
"pool",
"that",
"imposes",
"a",
"limit",
"on",
"the",
"number",
"of",
"stored",
"instances",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/utils.py#L53-L103 | [
"def",
"pool",
"(",
"builder",
",",
"size",
",",
"timeout",
"=",
"None",
")",
":",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"local_pool",
"=",
"queue",
".",
"Queue",
"(",
")",
"current_size",
"=",
"0",
"@",
"contextlib",
".",
"contextmanager",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | condition_details_has_owner | Check if the public_key of owner is in the condition details
as an Ed25519Fulfillment.public_key
Args:
condition_details (dict): dict with condition details
owner (str): base58 public key of owner
Returns:
bool: True if the public key is found in the condition details, False otherw... | bigchaindb/utils.py | def condition_details_has_owner(condition_details, owner):
"""Check if the public_key of owner is in the condition details
as an Ed25519Fulfillment.public_key
Args:
condition_details (dict): dict with condition details
owner (str): base58 public key of owner
Returns:
bool: True... | def condition_details_has_owner(condition_details, owner):
"""Check if the public_key of owner is in the condition details
as an Ed25519Fulfillment.public_key
Args:
condition_details (dict): dict with condition details
owner (str): base58 public key of owner
Returns:
bool: True... | [
"Check",
"if",
"the",
"public_key",
"of",
"owner",
"is",
"in",
"the",
"condition",
"details",
"as",
"an",
"Ed25519Fulfillment",
".",
"public_key"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/utils.py#L107-L133 | [
"def",
"condition_details_has_owner",
"(",
"condition_details",
",",
"owner",
")",
":",
"if",
"'subconditions'",
"in",
"condition_details",
":",
"result",
"=",
"condition_details_has_owner",
"(",
"condition_details",
"[",
"'subconditions'",
"]",
",",
"owner",
")",
"if... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | tendermint_version_is_compatible | Check Tendermint compatability with BigchainDB server
:param running_tm_ver: Version number of the connected Tendermint instance
:type running_tm_ver: str
:return: True/False depending on the compatability with BigchainDB server
:rtype: bool | bigchaindb/utils.py | def tendermint_version_is_compatible(running_tm_ver):
"""
Check Tendermint compatability with BigchainDB server
:param running_tm_ver: Version number of the connected Tendermint instance
:type running_tm_ver: str
:return: True/False depending on the compatability with BigchainDB server
:rtype: ... | def tendermint_version_is_compatible(running_tm_ver):
"""
Check Tendermint compatability with BigchainDB server
:param running_tm_ver: Version number of the connected Tendermint instance
:type running_tm_ver: str
:return: True/False depending on the compatability with BigchainDB server
:rtype: ... | [
"Check",
"Tendermint",
"compatability",
"with",
"BigchainDB",
"server"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/utils.py#L191-L208 | [
"def",
"tendermint_version_is_compatible",
"(",
"running_tm_ver",
")",
":",
"# Splitting because version can look like this e.g. 0.22.8-40d6dc2e",
"tm_ver",
"=",
"running_tm_ver",
".",
"split",
"(",
"'-'",
")",
"if",
"not",
"tm_ver",
":",
"return",
"False",
"for",
"ver",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Lazy.run | Run the recorded chain of methods on `instance`.
Args:
instance: an object. | bigchaindb/utils.py | def run(self, instance):
"""Run the recorded chain of methods on `instance`.
Args:
instance: an object.
"""
last = instance
for item in self.stack:
if isinstance(item, str):
last = getattr(last, item)
else:
la... | def run(self, instance):
"""Run the recorded chain of methods on `instance`.
Args:
instance: an object.
"""
last = instance
for item in self.stack:
if isinstance(item, str):
last = getattr(last, item)
else:
la... | [
"Run",
"the",
"recorded",
"chain",
"of",
"methods",
"on",
"instance",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/utils.py#L163-L179 | [
"def",
"run",
"(",
"self",
",",
"instance",
")",
":",
"last",
"=",
"instance",
"for",
"item",
"in",
"self",
".",
"stack",
":",
"if",
"isinstance",
"(",
"item",
",",
"str",
")",
":",
"last",
"=",
"getattr",
"(",
"last",
",",
"item",
")",
"else",
"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | base_ws_uri | Base websocket URL that is advertised to external clients.
Useful when the websocket URL advertised to the clients needs to be
customized (typically when running behind NAT, firewall, etc.) | bigchaindb/web/views/base.py | def base_ws_uri():
"""Base websocket URL that is advertised to external clients.
Useful when the websocket URL advertised to the clients needs to be
customized (typically when running behind NAT, firewall, etc.)
"""
scheme = config['wsserver']['advertised_scheme']
host = config['wsserver']['ad... | def base_ws_uri():
"""Base websocket URL that is advertised to external clients.
Useful when the websocket URL advertised to the clients needs to be
customized (typically when running behind NAT, firewall, etc.)
"""
scheme = config['wsserver']['advertised_scheme']
host = config['wsserver']['ad... | [
"Base",
"websocket",
"URL",
"that",
"is",
"advertised",
"to",
"external",
"clients",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/base.py#L32-L42 | [
"def",
"base_ws_uri",
"(",
")",
":",
"scheme",
"=",
"config",
"[",
"'wsserver'",
"]",
"[",
"'advertised_scheme'",
"]",
"host",
"=",
"config",
"[",
"'wsserver'",
"]",
"[",
"'advertised_host'",
"]",
"port",
"=",
"config",
"[",
"'wsserver'",
"]",
"[",
"'adver... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | TransactionApi.get | API endpoint to get details about a transaction.
Args:
tx_id (str): the id of the transaction.
Return:
A JSON string containing the data about the transaction. | bigchaindb/web/views/transactions.py | def get(self, tx_id):
"""API endpoint to get details about a transaction.
Args:
tx_id (str): the id of the transaction.
Return:
A JSON string containing the data about the transaction.
"""
pool = current_app.config['bigchain_pool']
with pool() a... | def get(self, tx_id):
"""API endpoint to get details about a transaction.
Args:
tx_id (str): the id of the transaction.
Return:
A JSON string containing the data about the transaction.
"""
pool = current_app.config['bigchain_pool']
with pool() a... | [
"API",
"endpoint",
"to",
"get",
"details",
"about",
"a",
"transaction",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/transactions.py#L24-L41 | [
"def",
"get",
"(",
"self",
",",
"tx_id",
")",
":",
"pool",
"=",
"current_app",
".",
"config",
"[",
"'bigchain_pool'",
"]",
"with",
"pool",
"(",
")",
"as",
"bigchain",
":",
"tx",
"=",
"bigchain",
".",
"get_transaction",
"(",
"tx_id",
")",
"if",
"not",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | TransactionListApi.post | API endpoint to push transactions to the Federation.
Return:
A ``dict`` containing the data about the transaction. | bigchaindb/web/views/transactions.py | def post(self):
"""API endpoint to push transactions to the Federation.
Return:
A ``dict`` containing the data about the transaction.
"""
parser = reqparse.RequestParser()
parser.add_argument('mode', type=parameters.valid_mode,
default='br... | def post(self):
"""API endpoint to push transactions to the Federation.
Return:
A ``dict`` containing the data about the transaction.
"""
parser = reqparse.RequestParser()
parser.add_argument('mode', type=parameters.valid_mode,
default='br... | [
"API",
"endpoint",
"to",
"push",
"transactions",
"to",
"the",
"Federation",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/views/transactions.py#L57-L105 | [
"def",
"post",
"(",
"self",
")",
":",
"parser",
"=",
"reqparse",
".",
"RequestParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'mode'",
",",
"type",
"=",
"parameters",
".",
"valid_mode",
",",
"default",
"=",
"'broadcast_tx_async'",
")",
"args",
"=",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | FastQuery.get_outputs_by_public_key | Get outputs for a public key | bigchaindb/fastquery.py | def get_outputs_by_public_key(self, public_key):
"""Get outputs for a public key"""
txs = list(query.get_owned_ids(self.connection, public_key))
return [TransactionLink(tx['id'], index)
for tx in txs
for index, output in enumerate(tx['outputs'])
if... | def get_outputs_by_public_key(self, public_key):
"""Get outputs for a public key"""
txs = list(query.get_owned_ids(self.connection, public_key))
return [TransactionLink(tx['id'], index)
for tx in txs
for index, output in enumerate(tx['outputs'])
if... | [
"Get",
"outputs",
"for",
"a",
"public",
"key"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/fastquery.py#L16-L23 | [
"def",
"get_outputs_by_public_key",
"(",
"self",
",",
"public_key",
")",
":",
"txs",
"=",
"list",
"(",
"query",
".",
"get_owned_ids",
"(",
"self",
".",
"connection",
",",
"public_key",
")",
")",
"return",
"[",
"TransactionLink",
"(",
"tx",
"[",
"'id'",
"]"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | FastQuery.filter_spent_outputs | Remove outputs that have been spent
Args:
outputs: list of TransactionLink | bigchaindb/fastquery.py | def filter_spent_outputs(self, outputs):
"""Remove outputs that have been spent
Args:
outputs: list of TransactionLink
"""
links = [o.to_dict() for o in outputs]
txs = list(query.get_spending_transactions(self.connection, links))
spends = {TransactionLink.fro... | def filter_spent_outputs(self, outputs):
"""Remove outputs that have been spent
Args:
outputs: list of TransactionLink
"""
links = [o.to_dict() for o in outputs]
txs = list(query.get_spending_transactions(self.connection, links))
spends = {TransactionLink.fro... | [
"Remove",
"outputs",
"that",
"have",
"been",
"spent"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/fastquery.py#L25-L36 | [
"def",
"filter_spent_outputs",
"(",
"self",
",",
"outputs",
")",
":",
"links",
"=",
"[",
"o",
".",
"to_dict",
"(",
")",
"for",
"o",
"in",
"outputs",
"]",
"txs",
"=",
"list",
"(",
"query",
".",
"get_spending_transactions",
"(",
"self",
".",
"connection",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | _load_schema | Load a schema from disk | bigchaindb/common/schema/__init__.py | def _load_schema(name, path=__file__):
"""Load a schema from disk"""
path = os.path.join(os.path.dirname(path), name + '.yaml')
with open(path) as handle:
schema = yaml.safe_load(handle)
fast_schema = rapidjson.Validator(rapidjson.dumps(schema))
return path, (schema, fast_schema) | def _load_schema(name, path=__file__):
"""Load a schema from disk"""
path = os.path.join(os.path.dirname(path), name + '.yaml')
with open(path) as handle:
schema = yaml.safe_load(handle)
fast_schema = rapidjson.Validator(rapidjson.dumps(schema))
return path, (schema, fast_schema) | [
"Load",
"a",
"schema",
"from",
"disk"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/schema/__init__.py#L19-L25 | [
"def",
"_load_schema",
"(",
"name",
",",
"path",
"=",
"__file__",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"path",
")",
",",
"name",
"+",
"'.yaml'",
")",
"with",
"open",
"(",
"path",
")",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | _validate_schema | Validate data against a schema | bigchaindb/common/schema/__init__.py | def _validate_schema(schema, body):
"""Validate data against a schema"""
# Note
#
# Schema validation is currently the major CPU bottleneck of
# BigchainDB. the `jsonschema` library validates python data structures
# directly and produces nice error messages, but validation takes 4+ ms
# pe... | def _validate_schema(schema, body):
"""Validate data against a schema"""
# Note
#
# Schema validation is currently the major CPU bottleneck of
# BigchainDB. the `jsonschema` library validates python data structures
# directly and produces nice error messages, but validation takes 4+ ms
# pe... | [
"Validate",
"data",
"against",
"a",
"schema"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/schema/__init__.py#L46-L68 | [
"def",
"_validate_schema",
"(",
"schema",
",",
"body",
")",
":",
"# Note",
"#",
"# Schema validation is currently the major CPU bottleneck of",
"# BigchainDB. the `jsonschema` library validates python data structures",
"# directly and produces nice error messages, but validation takes 4+ ms"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | validate_transaction_schema | Validate a transaction dict.
TX_SCHEMA_COMMON contains properties that are common to all types of
transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top. | bigchaindb/common/schema/__init__.py | def validate_transaction_schema(tx):
"""Validate a transaction dict.
TX_SCHEMA_COMMON contains properties that are common to all types of
transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top.
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
if tx['operation'] == 'TRANSFER':
... | def validate_transaction_schema(tx):
"""Validate a transaction dict.
TX_SCHEMA_COMMON contains properties that are common to all types of
transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top.
"""
_validate_schema(TX_SCHEMA_COMMON, tx)
if tx['operation'] == 'TRANSFER':
... | [
"Validate",
"a",
"transaction",
"dict",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/common/schema/__init__.py#L71-L81 | [
"def",
"validate_transaction_schema",
"(",
"tx",
")",
":",
"_validate_schema",
"(",
"TX_SCHEMA_COMMON",
",",
"tx",
")",
"if",
"tx",
"[",
"'operation'",
"]",
"==",
"'TRANSFER'",
":",
"_validate_schema",
"(",
"TX_SCHEMA_TRANSFER",
",",
"tx",
")",
"else",
":",
"_... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.post_transaction | Submit a valid transaction to the mempool. | bigchaindb/lib.py | def post_transaction(self, transaction, mode):
"""Submit a valid transaction to the mempool."""
if not mode or mode not in self.mode_list:
raise ValidationError('Mode must be one of the following {}.'
.format(', '.join(self.mode_list)))
tx_dict = tr... | def post_transaction(self, transaction, mode):
"""Submit a valid transaction to the mempool."""
if not mode or mode not in self.mode_list:
raise ValidationError('Mode must be one of the following {}.'
.format(', '.join(self.mode_list)))
tx_dict = tr... | [
"Submit",
"a",
"valid",
"transaction",
"to",
"the",
"mempool",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L76-L90 | [
"def",
"post_transaction",
"(",
"self",
",",
"transaction",
",",
"mode",
")",
":",
"if",
"not",
"mode",
"or",
"mode",
"not",
"in",
"self",
".",
"mode_list",
":",
"raise",
"ValidationError",
"(",
"'Mode must be one of the following {}.'",
".",
"format",
"(",
"'... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.write_transaction | Submit a valid transaction to the mempool. | bigchaindb/lib.py | def write_transaction(self, transaction, mode):
# This method offers backward compatibility with the Web API.
"""Submit a valid transaction to the mempool."""
response = self.post_transaction(transaction, mode)
return self._process_post_response(response.json(), mode) | def write_transaction(self, transaction, mode):
# This method offers backward compatibility with the Web API.
"""Submit a valid transaction to the mempool."""
response = self.post_transaction(transaction, mode)
return self._process_post_response(response.json(), mode) | [
"Submit",
"a",
"valid",
"transaction",
"to",
"the",
"mempool",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L92-L96 | [
"def",
"write_transaction",
"(",
"self",
",",
"transaction",
",",
"mode",
")",
":",
"# This method offers backward compatibility with the Web API.",
"response",
"=",
"self",
".",
"post_transaction",
"(",
"transaction",
",",
"mode",
")",
"return",
"self",
".",
"_proces... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.update_utxoset | Update the UTXO set given ``transaction``. That is, remove
the outputs that the given ``transaction`` spends, and add the
outputs that the given ``transaction`` creates.
Args:
transaction (:obj:`~bigchaindb.models.Transaction`): A new
transaction incoming into the sy... | bigchaindb/lib.py | def update_utxoset(self, transaction):
"""Update the UTXO set given ``transaction``. That is, remove
the outputs that the given ``transaction`` spends, and add the
outputs that the given ``transaction`` creates.
Args:
transaction (:obj:`~bigchaindb.models.Transaction`): A ne... | def update_utxoset(self, transaction):
"""Update the UTXO set given ``transaction``. That is, remove
the outputs that the given ``transaction`` spends, and add the
outputs that the given ``transaction`` creates.
Args:
transaction (:obj:`~bigchaindb.models.Transaction`): A ne... | [
"Update",
"the",
"UTXO",
"set",
"given",
"transaction",
".",
"That",
"is",
"remove",
"the",
"outputs",
"that",
"the",
"given",
"transaction",
"spends",
"and",
"add",
"the",
"outputs",
"that",
"the",
"given",
"transaction",
"creates",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L149-L166 | [
"def",
"update_utxoset",
"(",
"self",
",",
"transaction",
")",
":",
"spent_outputs",
"=",
"[",
"spent_output",
"for",
"spent_output",
"in",
"transaction",
".",
"spent_outputs",
"]",
"if",
"spent_outputs",
":",
"self",
".",
"delete_unspent_outputs",
"(",
"*",
"sp... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.store_unspent_outputs | Store the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs. | bigchaindb/lib.py | def store_unspent_outputs(self, *unspent_outputs):
"""Store the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs.
"""
if unspent_outputs:
return backend.query... | def store_unspent_outputs(self, *unspent_outputs):
"""Store the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs.
"""
if unspent_outputs:
return backend.query... | [
"Store",
"the",
"given",
"unspent_outputs",
"(",
"utxos",
")",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L168-L177 | [
"def",
"store_unspent_outputs",
"(",
"self",
",",
"*",
"unspent_outputs",
")",
":",
"if",
"unspent_outputs",
":",
"return",
"backend",
".",
"query",
".",
"store_unspent_outputs",
"(",
"self",
".",
"connection",
",",
"*",
"unspent_outputs",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_utxoset_merkle_root | Returns the merkle root of the utxoset. This implies that
the utxoset is first put into a merkle tree.
For now, the merkle tree and its root will be computed each
time. This obviously is not efficient and a better approach
that limits the repetition of the same computation when
... | bigchaindb/lib.py | def get_utxoset_merkle_root(self):
"""Returns the merkle root of the utxoset. This implies that
the utxoset is first put into a merkle tree.
For now, the merkle tree and its root will be computed each
time. This obviously is not efficient and a better approach
that limits the re... | def get_utxoset_merkle_root(self):
"""Returns the merkle root of the utxoset. This implies that
the utxoset is first put into a merkle tree.
For now, the merkle tree and its root will be computed each
time. This obviously is not efficient and a better approach
that limits the re... | [
"Returns",
"the",
"merkle",
"root",
"of",
"the",
"utxoset",
".",
"This",
"implies",
"that",
"the",
"utxoset",
"is",
"first",
"put",
"into",
"a",
"merkle",
"tree",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L179-L211 | [
"def",
"get_utxoset_merkle_root",
"(",
"self",
")",
":",
"utxoset",
"=",
"backend",
".",
"query",
".",
"get_unspent_outputs",
"(",
"self",
".",
"connection",
")",
"# TODO Once ready, use the already pre-computed utxo_hash field.",
"# See common/transactions.py for details.",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_unspent_outputs | Get the utxoset.
Returns:
generator of unspent_outputs. | bigchaindb/lib.py | def get_unspent_outputs(self):
"""Get the utxoset.
Returns:
generator of unspent_outputs.
"""
cursor = backend.query.get_unspent_outputs(self.connection)
return (record for record in cursor) | def get_unspent_outputs(self):
"""Get the utxoset.
Returns:
generator of unspent_outputs.
"""
cursor = backend.query.get_unspent_outputs(self.connection)
return (record for record in cursor) | [
"Get",
"the",
"utxoset",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L213-L220 | [
"def",
"get_unspent_outputs",
"(",
"self",
")",
":",
"cursor",
"=",
"backend",
".",
"query",
".",
"get_unspent_outputs",
"(",
"self",
".",
"connection",
")",
"return",
"(",
"record",
"for",
"record",
"in",
"cursor",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.delete_unspent_outputs | Deletes the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs. | bigchaindb/lib.py | def delete_unspent_outputs(self, *unspent_outputs):
"""Deletes the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs.
"""
if unspent_outputs:
return backend.qu... | def delete_unspent_outputs(self, *unspent_outputs):
"""Deletes the given ``unspent_outputs`` (utxos).
Args:
*unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable
length tuple or list of unspent outputs.
"""
if unspent_outputs:
return backend.qu... | [
"Deletes",
"the",
"given",
"unspent_outputs",
"(",
"utxos",
")",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L222-L231 | [
"def",
"delete_unspent_outputs",
"(",
"self",
",",
"*",
"unspent_outputs",
")",
":",
"if",
"unspent_outputs",
":",
"return",
"backend",
".",
"query",
".",
"delete_unspent_outputs",
"(",
"self",
".",
"connection",
",",
"*",
"unspent_outputs",
")"
] | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_transactions_filtered | Get a list of transactions filtered on some criteria | bigchaindb/lib.py | def get_transactions_filtered(self, asset_id, operation=None):
"""Get a list of transactions filtered on some criteria
"""
txids = backend.query.get_txids_filtered(self.connection, asset_id,
operation)
for txid in txids:
yield ... | def get_transactions_filtered(self, asset_id, operation=None):
"""Get a list of transactions filtered on some criteria
"""
txids = backend.query.get_txids_filtered(self.connection, asset_id,
operation)
for txid in txids:
yield ... | [
"Get",
"a",
"list",
"of",
"transactions",
"filtered",
"on",
"some",
"criteria"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L260-L266 | [
"def",
"get_transactions_filtered",
"(",
"self",
",",
"asset_id",
",",
"operation",
"=",
"None",
")",
":",
"txids",
"=",
"backend",
".",
"query",
".",
"get_txids_filtered",
"(",
"self",
".",
"connection",
",",
"asset_id",
",",
"operation",
")",
"for",
"txid"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_outputs_filtered | Get a list of output links filtered on some criteria
Args:
owner (str): base58 encoded public_key.
spent (bool): If ``True`` return only the spent outputs. If
``False`` return only unspent outputs. If spent is
not specified (``None``) ... | bigchaindb/lib.py | def get_outputs_filtered(self, owner, spent=None):
"""Get a list of output links filtered on some criteria
Args:
owner (str): base58 encoded public_key.
spent (bool): If ``True`` return only the spent outputs. If
``False`` return only unspent outputs. I... | def get_outputs_filtered(self, owner, spent=None):
"""Get a list of output links filtered on some criteria
Args:
owner (str): base58 encoded public_key.
spent (bool): If ``True`` return only the spent outputs. If
``False`` return only unspent outputs. I... | [
"Get",
"a",
"list",
"of",
"output",
"links",
"filtered",
"on",
"some",
"criteria"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L268-L287 | [
"def",
"get_outputs_filtered",
"(",
"self",
",",
"owner",
",",
"spent",
"=",
"None",
")",
":",
"outputs",
"=",
"self",
".",
"fastquery",
".",
"get_outputs_by_public_key",
"(",
"owner",
")",
"if",
"spent",
"is",
"None",
":",
"return",
"outputs",
"elif",
"sp... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_block | Get the block with the specified `block_id`.
Returns the block corresponding to `block_id` or None if no match is
found.
Args:
block_id (int): block id of the block to get. | bigchaindb/lib.py | def get_block(self, block_id):
"""Get the block with the specified `block_id`.
Returns the block corresponding to `block_id` or None if no match is
found.
Args:
block_id (int): block id of the block to get.
"""
block = backend.query.get_block(self.connectio... | def get_block(self, block_id):
"""Get the block with the specified `block_id`.
Returns the block corresponding to `block_id` or None if no match is
found.
Args:
block_id (int): block id of the block to get.
"""
block = backend.query.get_block(self.connectio... | [
"Get",
"the",
"block",
"with",
"the",
"specified",
"block_id",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L326-L350 | [
"def",
"get_block",
"(",
"self",
",",
"block_id",
")",
":",
"block",
"=",
"backend",
".",
"query",
".",
"get_block",
"(",
"self",
".",
"connection",
",",
"block_id",
")",
"latest_block",
"=",
"self",
".",
"get_latest_block",
"(",
")",
"latest_block_height",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.get_block_containing_tx | Retrieve the list of blocks (block ids) containing a
transaction with transaction id `txid`
Args:
txid (str): transaction id of the transaction to query
Returns:
Block id list (list(int)) | bigchaindb/lib.py | def get_block_containing_tx(self, txid):
"""Retrieve the list of blocks (block ids) containing a
transaction with transaction id `txid`
Args:
txid (str): transaction id of the transaction to query
Returns:
Block id list (list(int))
"""
blocks ... | def get_block_containing_tx(self, txid):
"""Retrieve the list of blocks (block ids) containing a
transaction with transaction id `txid`
Args:
txid (str): transaction id of the transaction to query
Returns:
Block id list (list(int))
"""
blocks ... | [
"Retrieve",
"the",
"list",
"of",
"blocks",
"(",
"block",
"ids",
")",
"containing",
"a",
"transaction",
"with",
"transaction",
"id",
"txid"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L352-L366 | [
"def",
"get_block_containing_tx",
"(",
"self",
",",
"txid",
")",
":",
"blocks",
"=",
"list",
"(",
"backend",
".",
"query",
".",
"get_block_with_transaction",
"(",
"self",
".",
"connection",
",",
"txid",
")",
")",
"if",
"len",
"(",
"blocks",
")",
">",
"1"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.validate_transaction | Validate a transaction against the current status of the database. | bigchaindb/lib.py | def validate_transaction(self, tx, current_transactions=[]):
"""Validate a transaction against the current status of the database."""
transaction = tx
# CLEANUP: The conditional below checks for transaction in dict format.
# It would be better to only have a single format for the trans... | def validate_transaction(self, tx, current_transactions=[]):
"""Validate a transaction against the current status of the database."""
transaction = tx
# CLEANUP: The conditional below checks for transaction in dict format.
# It would be better to only have a single format for the trans... | [
"Validate",
"a",
"transaction",
"against",
"the",
"current",
"status",
"of",
"the",
"database",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L368-L385 | [
"def",
"validate_transaction",
"(",
"self",
",",
"tx",
",",
"current_transactions",
"=",
"[",
"]",
")",
":",
"transaction",
"=",
"tx",
"# CLEANUP: The conditional below checks for transaction in dict format.",
"# It would be better to only have a single format for the transaction",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.text_search | Return an iterator of assets that match the text search
Args:
search (str): Text search string to query the text index
limit (int, optional): Limit the number of returned documents.
Returns:
iter: An iterator of assets that match the text search. | bigchaindb/lib.py | def text_search(self, search, *, limit=0, table='assets'):
"""Return an iterator of assets that match the text search
Args:
search (str): Text search string to query the text index
limit (int, optional): Limit the number of returned documents.
Returns:
iter:... | def text_search(self, search, *, limit=0, table='assets'):
"""Return an iterator of assets that match the text search
Args:
search (str): Text search string to query the text index
limit (int, optional): Limit the number of returned documents.
Returns:
iter:... | [
"Return",
"an",
"iterator",
"of",
"assets",
"that",
"match",
"the",
"text",
"search"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L396-L407 | [
"def",
"text_search",
"(",
"self",
",",
"search",
",",
"*",
",",
"limit",
"=",
"0",
",",
"table",
"=",
"'assets'",
")",
":",
"return",
"backend",
".",
"query",
".",
"text_search",
"(",
"self",
".",
"connection",
",",
"search",
",",
"limit",
"=",
"lim... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.store_validator_set | Store validator set at a given `height`.
NOTE: If the validator set already exists at that `height` then an
exception will be raised. | bigchaindb/lib.py | def store_validator_set(self, height, validators):
"""Store validator set at a given `height`.
NOTE: If the validator set already exists at that `height` then an
exception will be raised.
"""
return backend.query.store_validator_set(self.connection, {'height': height,
... | def store_validator_set(self, height, validators):
"""Store validator set at a given `height`.
NOTE: If the validator set already exists at that `height` then an
exception will be raised.
"""
return backend.query.store_validator_set(self.connection, {'height': height,
... | [
"Store",
"validator",
"set",
"at",
"a",
"given",
"height",
".",
"NOTE",
":",
"If",
"the",
"validator",
"set",
"already",
"exists",
"at",
"that",
"height",
"then",
"an",
"exception",
"will",
"be",
"raised",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L453-L459 | [
"def",
"store_validator_set",
"(",
"self",
",",
"height",
",",
"validators",
")",
":",
"return",
"backend",
".",
"query",
".",
"store_validator_set",
"(",
"self",
".",
"connection",
",",
"{",
"'height'",
":",
"height",
",",
"'validators'",
":",
"validators",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | BigchainDB.migrate_abci_chain | Generate and record a new ABCI chain ID. New blocks are not
accepted until we receive an InitChain ABCI request with
the matching chain ID and validator set.
Chain ID is generated based on the current chain and height.
`chain-X` => `chain-X-migrated-at-height-5`.
`chain-X-migrat... | bigchaindb/lib.py | def migrate_abci_chain(self):
"""Generate and record a new ABCI chain ID. New blocks are not
accepted until we receive an InitChain ABCI request with
the matching chain ID and validator set.
Chain ID is generated based on the current chain and height.
`chain-X` => `chain-X-migra... | def migrate_abci_chain(self):
"""Generate and record a new ABCI chain ID. New blocks are not
accepted until we receive an InitChain ABCI request with
the matching chain ID and validator set.
Chain ID is generated based on the current chain and height.
`chain-X` => `chain-X-migra... | [
"Generate",
"and",
"record",
"a",
"new",
"ABCI",
"chain",
"ID",
".",
"New",
"blocks",
"are",
"not",
"accepted",
"until",
"we",
"receive",
"an",
"InitChain",
"ABCI",
"request",
"with",
"the",
"matching",
"chain",
"ID",
"and",
"validator",
"set",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/lib.py#L474-L496 | [
"def",
"migrate_abci_chain",
"(",
"self",
")",
":",
"latest_chain",
"=",
"self",
".",
"get_latest_abci_chain",
"(",
")",
"if",
"latest_chain",
"is",
"None",
":",
"return",
"block",
"=",
"self",
".",
"get_latest_block",
"(",
")",
"suffix",
"=",
"'-migrated-at-h... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | _multiprocessing_to_asyncio | Bridge between a synchronous multiprocessing queue
and an asynchronous asyncio queue.
Args:
in_queue (multiprocessing.Queue): input queue
out_queue (asyncio.Queue): output queue | bigchaindb/web/websocket_server.py | def _multiprocessing_to_asyncio(in_queue, out_queue, loop):
"""Bridge between a synchronous multiprocessing queue
and an asynchronous asyncio queue.
Args:
in_queue (multiprocessing.Queue): input queue
out_queue (asyncio.Queue): output queue
"""
while True:
value = in_queue.... | def _multiprocessing_to_asyncio(in_queue, out_queue, loop):
"""Bridge between a synchronous multiprocessing queue
and an asynchronous asyncio queue.
Args:
in_queue (multiprocessing.Queue): input queue
out_queue (asyncio.Queue): output queue
"""
while True:
value = in_queue.... | [
"Bridge",
"between",
"a",
"synchronous",
"multiprocessing",
"queue",
"and",
"an",
"asynchronous",
"asyncio",
"queue",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/websocket_server.py#L37-L48 | [
"def",
"_multiprocessing_to_asyncio",
"(",
"in_queue",
",",
"out_queue",
",",
"loop",
")",
":",
"while",
"True",
":",
"value",
"=",
"in_queue",
".",
"get",
"(",
")",
"loop",
".",
"call_soon_threadsafe",
"(",
"out_queue",
".",
"put_nowait",
",",
"value",
")"
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | websocket_handler | Handle a new socket connection. | bigchaindb/web/websocket_server.py | def websocket_handler(request):
"""Handle a new socket connection."""
logger.debug('New websocket connection.')
websocket = web.WebSocketResponse()
yield from websocket.prepare(request)
uuid = uuid4()
request.app['dispatcher'].subscribe(uuid, websocket)
while True:
# Consume input ... | def websocket_handler(request):
"""Handle a new socket connection."""
logger.debug('New websocket connection.')
websocket = web.WebSocketResponse()
yield from websocket.prepare(request)
uuid = uuid4()
request.app['dispatcher'].subscribe(uuid, websocket)
while True:
# Consume input ... | [
"Handle",
"a",
"new",
"socket",
"connection",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/websocket_server.py#L121-L148 | [
"def",
"websocket_handler",
"(",
"request",
")",
":",
"logger",
".",
"debug",
"(",
"'New websocket connection.'",
")",
"websocket",
"=",
"web",
".",
"WebSocketResponse",
"(",
")",
"yield",
"from",
"websocket",
".",
"prepare",
"(",
"request",
")",
"uuid",
"=",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | init_app | Init the application server.
Return:
An aiohttp application. | bigchaindb/web/websocket_server.py | def init_app(event_source, *, loop=None):
"""Init the application server.
Return:
An aiohttp application.
"""
dispatcher = Dispatcher(event_source)
# Schedule the dispatcher
loop.create_task(dispatcher.publish())
app = web.Application(loop=loop)
app['dispatcher'] = dispatcher... | def init_app(event_source, *, loop=None):
"""Init the application server.
Return:
An aiohttp application.
"""
dispatcher = Dispatcher(event_source)
# Schedule the dispatcher
loop.create_task(dispatcher.publish())
app = web.Application(loop=loop)
app['dispatcher'] = dispatcher... | [
"Init",
"the",
"application",
"server",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/websocket_server.py#L151-L166 | [
"def",
"init_app",
"(",
"event_source",
",",
"*",
",",
"loop",
"=",
"None",
")",
":",
"dispatcher",
"=",
"Dispatcher",
"(",
"event_source",
")",
"# Schedule the dispatcher",
"loop",
".",
"create_task",
"(",
"dispatcher",
".",
"publish",
"(",
")",
")",
"app",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | start | Create and start the WebSocket server. | bigchaindb/web/websocket_server.py | def start(sync_event_source, loop=None):
"""Create and start the WebSocket server."""
if not loop:
loop = asyncio.get_event_loop()
event_source = asyncio.Queue(loop=loop)
bridge = threading.Thread(target=_multiprocessing_to_asyncio,
args=(sync_event_source, event... | def start(sync_event_source, loop=None):
"""Create and start the WebSocket server."""
if not loop:
loop = asyncio.get_event_loop()
event_source = asyncio.Queue(loop=loop)
bridge = threading.Thread(target=_multiprocessing_to_asyncio,
args=(sync_event_source, event... | [
"Create",
"and",
"start",
"the",
"WebSocket",
"server",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/websocket_server.py#L169-L185 | [
"def",
"start",
"(",
"sync_event_source",
",",
"loop",
"=",
"None",
")",
":",
"if",
"not",
"loop",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"event_source",
"=",
"asyncio",
".",
"Queue",
"(",
"loop",
"=",
"loop",
")",
"bridge",
"=",... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Dispatcher.publish | Publish new events to the subscribers. | bigchaindb/web/websocket_server.py | def publish(self):
"""Publish new events to the subscribers."""
while True:
event = yield from self.event_source.get()
str_buffer = []
if event == POISON_PILL:
return
if isinstance(event, str):
str_buffer.append(event)
... | def publish(self):
"""Publish new events to the subscribers."""
while True:
event = yield from self.event_source.get()
str_buffer = []
if event == POISON_PILL:
return
if isinstance(event, str):
str_buffer.append(event)
... | [
"Publish",
"new",
"events",
"to",
"the",
"subscribers",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/websocket_server.py#L99-L117 | [
"def",
"publish",
"(",
"self",
")",
":",
"while",
"True",
":",
"event",
"=",
"yield",
"from",
"self",
".",
"event_source",
".",
"get",
"(",
")",
"str_buffer",
"=",
"[",
"]",
"if",
"event",
"==",
"POISON_PILL",
":",
"return",
"if",
"isinstance",
"(",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | merkleroot | Computes the merkle root for a given list.
Args:
hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree.
Returns:
str: Merkle root in hexadecimal form. | bigchaindb/tendermint_utils.py | def merkleroot(hashes):
"""Computes the merkle root for a given list.
Args:
hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree.
Returns:
str: Merkle root in hexadecimal form.
"""
# XXX TEMPORARY -- MUST REVIEW and possibly CHANGE
# The idea here is that the UTXO SET ... | def merkleroot(hashes):
"""Computes the merkle root for a given list.
Args:
hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree.
Returns:
str: Merkle root in hexadecimal form.
"""
# XXX TEMPORARY -- MUST REVIEW and possibly CHANGE
# The idea here is that the UTXO SET ... | [
"Computes",
"the",
"merkle",
"root",
"for",
"a",
"given",
"list",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/tendermint_utils.py#L45-L71 | [
"def",
"merkleroot",
"(",
"hashes",
")",
":",
"# XXX TEMPORARY -- MUST REVIEW and possibly CHANGE",
"# The idea here is that the UTXO SET would be empty and this function",
"# would be invoked to compute the merkle root, and since there is nothing,",
"# i.e. an empty list, then the hash of the emp... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | public_key64_to_address | Note this only compatible with Tendermint 0.19.x | bigchaindb/tendermint_utils.py | def public_key64_to_address(base64_public_key):
"""Note this only compatible with Tendermint 0.19.x"""
ed25519_public_key = public_key_from_base64(base64_public_key)
encoded_public_key = amino_encoded_public_key(ed25519_public_key)
return hashlib.new('ripemd160', encoded_public_key).hexdigest().upper() | def public_key64_to_address(base64_public_key):
"""Note this only compatible with Tendermint 0.19.x"""
ed25519_public_key = public_key_from_base64(base64_public_key)
encoded_public_key = amino_encoded_public_key(ed25519_public_key)
return hashlib.new('ripemd160', encoded_public_key).hexdigest().upper() | [
"Note",
"this",
"only",
"compatible",
"with",
"Tendermint",
"0",
".",
"19",
".",
"x"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/tendermint_utils.py#L74-L78 | [
"def",
"public_key64_to_address",
"(",
"base64_public_key",
")",
":",
"ed25519_public_key",
"=",
"public_key_from_base64",
"(",
"base64_public_key",
")",
"encoded_public_key",
"=",
"amino_encoded_public_key",
"(",
"ed25519_public_key",
")",
"return",
"hashlib",
".",
"new",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | Transaction.validate | Validate transaction spend
Args:
bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object.
Returns:
The transaction (Transaction) if the transaction is valid else it
raises an exception describing the reason why the transaction is
invalid.
... | bigchaindb/models.py | def validate(self, bigchain, current_transactions=[]):
"""Validate transaction spend
Args:
bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object.
Returns:
The transaction (Transaction) if the transaction is valid else it
raises an exception descr... | def validate(self, bigchain, current_transactions=[]):
"""Validate transaction spend
Args:
bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object.
Returns:
The transaction (Transaction) if the transaction is valid else it
raises an exception descr... | [
"Validate",
"transaction",
"spend",
"Args",
":",
"bigchain",
"(",
"BigchainDB",
")",
":",
"an",
"instantiated",
"bigchaindb",
".",
"BigchainDB",
"object",
".",
"Returns",
":",
"The",
"transaction",
"(",
"Transaction",
")",
"if",
"the",
"transaction",
"is",
"va... | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/models.py#L15-L40 | [
"def",
"validate",
"(",
"self",
",",
"bigchain",
",",
"current_transactions",
"=",
"[",
"]",
")",
":",
"input_conditions",
"=",
"[",
"]",
"if",
"self",
".",
"operation",
"==",
"Transaction",
".",
"CREATE",
":",
"duplicates",
"=",
"any",
"(",
"txn",
"for"... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | LocalMongoDBConnection._connect | Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails.
:exc:`~AuthenticationError`: If there is a OperationFailure due to
Authentication failure after connecting to the database.
:exc:`~Config... | bigchaindb/backend/localmongodb/connection.py | def _connect(self):
"""Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails.
:exc:`~AuthenticationError`: If there is a OperationFailure due to
Authentication failure after connecting to the data... | def _connect(self):
"""Try to connect to the database.
Raises:
:exc:`~ConnectionError`: If the connection to the database
fails.
:exc:`~AuthenticationError`: If there is a OperationFailure due to
Authentication failure after connecting to the data... | [
"Try",
"to",
"connect",
"to",
"the",
"database",
"."
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/backend/localmongodb/connection.py#L77-L130 | [
"def",
"_connect",
"(",
"self",
")",
":",
"try",
":",
"# FYI: the connection process might raise a",
"# `ServerSelectionTimeoutError`, that is a subclass of",
"# `ConnectionFailure`.",
"# The presence of ca_cert, certfile, keyfile, crlfile implies the",
"# use of certificates for TLS connect... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | add_routes | Add the routes to an app | bigchaindb/web/routes.py | def add_routes(app):
"""Add the routes to an app"""
for (prefix, routes) in API_SECTIONS:
api = Api(app, prefix=prefix)
for ((pattern, resource, *args), kwargs) in routes:
kwargs.setdefault('strict_slashes', False)
api.add_resource(resource, pattern, *args, **kwargs) | def add_routes(app):
"""Add the routes to an app"""
for (prefix, routes) in API_SECTIONS:
api = Api(app, prefix=prefix)
for ((pattern, resource, *args), kwargs) in routes:
kwargs.setdefault('strict_slashes', False)
api.add_resource(resource, pattern, *args, **kwargs) | [
"Add",
"the",
"routes",
"to",
"an",
"app"
] | bigchaindb/bigchaindb | python | https://github.com/bigchaindb/bigchaindb/blob/835fdfcf598918f76139e3b88ee33dd157acaaa7/bigchaindb/web/routes.py#L18-L24 | [
"def",
"add_routes",
"(",
"app",
")",
":",
"for",
"(",
"prefix",
",",
"routes",
")",
"in",
"API_SECTIONS",
":",
"api",
"=",
"Api",
"(",
"app",
",",
"prefix",
"=",
"prefix",
")",
"for",
"(",
"(",
"pattern",
",",
"resource",
",",
"*",
"args",
")",
... | 835fdfcf598918f76139e3b88ee33dd157acaaa7 |
train | EFBChat.self | Set the chat as yourself.
In this context, "yourself" means the user behind the master channel.
Every channel should relate this to the corresponding target.
Returns:
EFBChat: This object. | ehforwarderbot/chat.py | def self(self) -> 'EFBChat':
"""
Set the chat as yourself.
In this context, "yourself" means the user behind the master channel.
Every channel should relate this to the corresponding target.
Returns:
EFBChat: This object.
"""
self.chat_name = "You"
... | def self(self) -> 'EFBChat':
"""
Set the chat as yourself.
In this context, "yourself" means the user behind the master channel.
Every channel should relate this to the corresponding target.
Returns:
EFBChat: This object.
"""
self.chat_name = "You"
... | [
"Set",
"the",
"chat",
"as",
"yourself",
".",
"In",
"this",
"context",
"yourself",
"means",
"the",
"user",
"behind",
"the",
"master",
"channel",
".",
"Every",
"channel",
"should",
"relate",
"this",
"to",
"the",
"corresponding",
"target",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/chat.py#L71-L84 | [
"def",
"self",
"(",
"self",
")",
"->",
"'EFBChat'",
":",
"self",
".",
"chat_name",
"=",
"\"You\"",
"self",
".",
"chat_alias",
"=",
"None",
"self",
".",
"chat_uid",
"=",
"EFBChat",
".",
"SELF_ID",
"self",
".",
"chat_type",
"=",
"ChatType",
".",
"User",
... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBChat.system | Set the chat as a system chat.
Only set for channel-level and group-level system chats.
Returns:
EFBChat: This object. | ehforwarderbot/chat.py | def system(self) -> 'EFBChat':
"""
Set the chat as a system chat.
Only set for channel-level and group-level system chats.
Returns:
EFBChat: This object.
"""
self.chat_name = "System"
self.chat_alias = None
self.chat_uid = EFBChat.SYSTEM_ID
... | def system(self) -> 'EFBChat':
"""
Set the chat as a system chat.
Only set for channel-level and group-level system chats.
Returns:
EFBChat: This object.
"""
self.chat_name = "System"
self.chat_alias = None
self.chat_uid = EFBChat.SYSTEM_ID
... | [
"Set",
"the",
"chat",
"as",
"a",
"system",
"chat",
".",
"Only",
"set",
"for",
"channel",
"-",
"level",
"and",
"group",
"-",
"level",
"system",
"chats",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/chat.py#L86-L98 | [
"def",
"system",
"(",
"self",
")",
"->",
"'EFBChat'",
":",
"self",
".",
"chat_name",
"=",
"\"System\"",
"self",
".",
"chat_alias",
"=",
"None",
"self",
".",
"chat_uid",
"=",
"EFBChat",
".",
"SYSTEM_ID",
"self",
".",
"chat_type",
"=",
"ChatType",
".",
"Sy... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBChat.long_name | Shortcut property, if alias exists, this will provide the alias with name
in parenthesis. Otherwise, this will return the name | ehforwarderbot/chat.py | def long_name(self) -> str:
"""
Shortcut property, if alias exists, this will provide the alias with name
in parenthesis. Otherwise, this will return the name
"""
if self.chat_alias:
return "{0} ({1})".format(self.chat_alias, self.chat_name)
else:
... | def long_name(self) -> str:
"""
Shortcut property, if alias exists, this will provide the alias with name
in parenthesis. Otherwise, this will return the name
"""
if self.chat_alias:
return "{0} ({1})".format(self.chat_alias, self.chat_name)
else:
... | [
"Shortcut",
"property",
"if",
"alias",
"exists",
"this",
"will",
"provide",
"the",
"alias",
"with",
"name",
"in",
"parenthesis",
".",
"Otherwise",
"this",
"will",
"return",
"the",
"name"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/chat.py#L106-L114 | [
"def",
"long_name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"chat_alias",
":",
"return",
"\"{0} ({1})\"",
".",
"format",
"(",
"self",
".",
"chat_alias",
",",
"self",
".",
"chat_name",
")",
"else",
":",
"return",
"self",
".",
"chat_name"
] | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBChat.verify | Verify the completeness of the data.
Raises:
ValueError: When this chat is invalid. | ehforwarderbot/chat.py | def verify(self):
"""
Verify the completeness of the data.
Raises:
ValueError: When this chat is invalid.
"""
if any(not i for i in (self.chat_uid, self.module_id)):
raise ValueError("Chat data is incomplete.")
if not isinstance(self.chat_type, Ch... | def verify(self):
"""
Verify the completeness of the data.
Raises:
ValueError: When this chat is invalid.
"""
if any(not i for i in (self.chat_uid, self.module_id)):
raise ValueError("Chat data is incomplete.")
if not isinstance(self.chat_type, Ch... | [
"Verify",
"the",
"completeness",
"of",
"the",
"data",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/chat.py#L151-L167 | [
"def",
"verify",
"(",
"self",
")",
":",
"if",
"any",
"(",
"not",
"i",
"for",
"i",
"in",
"(",
"self",
".",
"chat_uid",
",",
"self",
".",
"module_id",
")",
")",
":",
"raise",
"ValueError",
"(",
"\"Chat data is incomplete.\"",
")",
"if",
"not",
"isinstanc... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBMiddleware.get_extra_functions | Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``. | ehforwarderbot/middleware.py | def get_extra_functions(self) -> Dict[str, Callable]:
"""Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``.
"""
methods = {}
... | def get_extra_functions(self) -> Dict[str, Callable]:
"""Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``.
"""
methods = {}
... | [
"Get",
"a",
"list",
"of",
"additional",
"features"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/middleware.py#L44-L56 | [
"def",
"get_extra_functions",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Callable",
"]",
":",
"methods",
"=",
"{",
"}",
"for",
"mName",
"in",
"dir",
"(",
"self",
")",
":",
"m",
"=",
"getattr",
"(",
"self",
",",
"mName",
")",
"if",
"callable"... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | prerequisite_check | Check prerequisites of the framework, including Python version, installation of
modules, etc.
Returns:
Optional[str]: If the check is not passed, return error message regarding
failed test case. None is returned otherwise. | ehforwarderbot/wizard.py | def prerequisite_check():
"""
Check prerequisites of the framework, including Python version, installation of
modules, etc.
Returns:
Optional[str]: If the check is not passed, return error message regarding
failed test case. None is returned otherwise.
"""
# Check Python v... | def prerequisite_check():
"""
Check prerequisites of the framework, including Python version, installation of
modules, etc.
Returns:
Optional[str]: If the check is not passed, return error message regarding
failed test case. None is returned otherwise.
"""
# Check Python v... | [
"Check",
"prerequisites",
"of",
"the",
"framework",
"including",
"Python",
"version",
"installation",
"of",
"modules",
"etc",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/wizard.py#L700-L738 | [
"def",
"prerequisite_check",
"(",
")",
":",
"# Check Python version",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"6",
")",
":",
"version_str",
"=",
"\"%s.%s.%s\"",
"%",
"sys",
".",
"version_info",
"[",
":",
"3",
"]",
"# TRANSLATORS: This word is use... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBChannel.get_extra_functions | Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``. | ehforwarderbot/channel.py | def get_extra_functions(self) -> Dict[str, Callable]:
"""Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``.
"""
if self.channel_type... | def get_extra_functions(self) -> Dict[str, Callable]:
"""Get a list of additional features
Returns:
Dict[str, Callable]: A dict of methods marked as additional features.
Method can be called with ``get_extra_functions()["methodName"]()``.
"""
if self.channel_type... | [
"Get",
"a",
"list",
"of",
"additional",
"features"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/channel.py#L58-L72 | [
"def",
"get_extra_functions",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Callable",
"]",
":",
"if",
"self",
".",
"channel_type",
"==",
"ChannelType",
".",
"Master",
":",
"raise",
"NameError",
"(",
"\"get_extra_function is not available on master channels.\"",... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | EFBMsg.verify | Verify the validity of message. | ehforwarderbot/message.py | def verify(self):
"""
Verify the validity of message.
"""
if self.author is None or not isinstance(self.author, EFBChat):
raise ValueError("Author is not valid.")
else:
self.author.verify()
if self.chat is None or not isinstance(self.chat, EFBChat)... | def verify(self):
"""
Verify the validity of message.
"""
if self.author is None or not isinstance(self.author, EFBChat):
raise ValueError("Author is not valid.")
else:
self.author.verify()
if self.chat is None or not isinstance(self.chat, EFBChat)... | [
"Verify",
"the",
"validity",
"of",
"message",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/message.py#L133-L174 | [
"def",
"verify",
"(",
"self",
")",
":",
"if",
"self",
".",
"author",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"self",
".",
"author",
",",
"EFBChat",
")",
":",
"raise",
"ValueError",
"(",
"\"Author is not valid.\"",
")",
"else",
":",
"self",
".",
"... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | bump_version | Version bump logic | bump.py | def bump_version(v: version.Version, level: str) -> str:
"""Version bump logic"""
release: List[int] = list(v.release)
stage: Optional[str]
pre: Optional[int]
stage, pre = v.pre if v.pre else (None, None)
dev: Optional[int] = v.dev
post: Optional[int] = v.post
if level in ("major", "min... | def bump_version(v: version.Version, level: str) -> str:
"""Version bump logic"""
release: List[int] = list(v.release)
stage: Optional[str]
pre: Optional[int]
stage, pre = v.pre if v.pre else (None, None)
dev: Optional[int] = v.dev
post: Optional[int] = v.post
if level in ("major", "min... | [
"Version",
"bump",
"logic"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/bump.py#L26-L104 | [
"def",
"bump_version",
"(",
"v",
":",
"version",
".",
"Version",
",",
"level",
":",
"str",
")",
"->",
"str",
":",
"release",
":",
"List",
"[",
"int",
"]",
"=",
"list",
"(",
"v",
".",
"release",
")",
"stage",
":",
"Optional",
"[",
"str",
"]",
"pre... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | extra | Decorator for slave channel's "additional features" interface.
Args:
name (str): A human readable name for the function.
desc (str): A short description and usage of it. Use
``{function_name}`` in place of the function name
in the description.
Returns:
The decor... | ehforwarderbot/utils.py | def extra(name: str, desc: str) -> Callable:
"""
Decorator for slave channel's "additional features" interface.
Args:
name (str): A human readable name for the function.
desc (str): A short description and usage of it. Use
``{function_name}`` in place of the function name
... | def extra(name: str, desc: str) -> Callable:
"""
Decorator for slave channel's "additional features" interface.
Args:
name (str): A human readable name for the function.
desc (str): A short description and usage of it. Use
``{function_name}`` in place of the function name
... | [
"Decorator",
"for",
"slave",
"channel",
"s",
"additional",
"features",
"interface",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L14-L34 | [
"def",
"extra",
"(",
"name",
":",
"str",
",",
"desc",
":",
"str",
")",
"->",
"Callable",
":",
"def",
"attr_dec",
"(",
"f",
")",
":",
"f",
".",
"__setattr__",
"(",
"\"extra_fn\"",
",",
"True",
")",
"f",
".",
"__setattr__",
"(",
"\"name\"",
",",
"nam... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | get_base_path | Get the base data path for EFB. This can be defined by the
environment variable ``EFB_DATA_PATH``.
If ``EFB_DATA_PATH`` is not defined, this gives
``~/.ehforwarderbot``.
This method creates the queried path if not existing.
Returns:
The base path. | ehforwarderbot/utils.py | def get_base_path() -> Path:
"""
Get the base data path for EFB. This can be defined by the
environment variable ``EFB_DATA_PATH``.
If ``EFB_DATA_PATH`` is not defined, this gives
``~/.ehforwarderbot``.
This method creates the queried path if not existing.
Returns:
The... | def get_base_path() -> Path:
"""
Get the base data path for EFB. This can be defined by the
environment variable ``EFB_DATA_PATH``.
If ``EFB_DATA_PATH`` is not defined, this gives
``~/.ehforwarderbot``.
This method creates the queried path if not existing.
Returns:
The... | [
"Get",
"the",
"base",
"data",
"path",
"for",
"EFB",
".",
"This",
"can",
"be",
"defined",
"by",
"the",
"environment",
"variable",
"EFB_DATA_PATH",
".",
"If",
"EFB_DATA_PATH",
"is",
"not",
"defined",
"this",
"gives",
"~",
"/",
".",
"ehforwarderbot",
".",
"Th... | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L37-L57 | [
"def",
"get_base_path",
"(",
")",
"->",
"Path",
":",
"env_data_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"EFB_DATA_PATH\"",
",",
"None",
")",
"if",
"env_data_path",
":",
"base_path",
"=",
"Path",
"(",
"env_data_path",
")",
".",
"resolve",
"(",
... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | get_data_path | Get the path for persistent storage of a module.
This method creates the queried path if not existing.
Args:
module_id (str): Module ID
Returns:
The data path of indicated module. | ehforwarderbot/utils.py | def get_data_path(module_id: str) -> Path:
"""
Get the path for persistent storage of a module.
This method creates the queried path if not existing.
Args:
module_id (str): Module ID
Returns:
The data path of indicated module.
"""
profile = coordinator.profile
... | def get_data_path(module_id: str) -> Path:
"""
Get the path for persistent storage of a module.
This method creates the queried path if not existing.
Args:
module_id (str): Module ID
Returns:
The data path of indicated module.
"""
profile = coordinator.profile
... | [
"Get",
"the",
"path",
"for",
"persistent",
"storage",
"of",
"a",
"module",
".",
"This",
"method",
"creates",
"the",
"queried",
"path",
"if",
"not",
"existing",
".",
"Args",
":",
"module_id",
"(",
"str",
")",
":",
"Module",
"ID"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L60-L76 | [
"def",
"get_data_path",
"(",
"module_id",
":",
"str",
")",
"->",
"Path",
":",
"profile",
"=",
"coordinator",
".",
"profile",
"data_path",
"=",
"get_base_path",
"(",
")",
"/",
"'profiles'",
"/",
"profile",
"/",
"module_id",
"if",
"not",
"data_path",
".",
"e... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | get_config_path | Get path for configuration file. Defaulted to
``~/.ehforwarderbot/profiles/profile_name/channel_id/config.yaml``.
This method creates the queried path if not existing. The config file will
not be created, however.
Args:
module_id (str): Module ID.
ext (Optional[Str]): Extension... | ehforwarderbot/utils.py | def get_config_path(module_id: str = None, ext: str = 'yaml') -> Path:
"""
Get path for configuration file. Defaulted to
``~/.ehforwarderbot/profiles/profile_name/channel_id/config.yaml``.
This method creates the queried path if not existing. The config file will
not be created, however.
... | def get_config_path(module_id: str = None, ext: str = 'yaml') -> Path:
"""
Get path for configuration file. Defaulted to
``~/.ehforwarderbot/profiles/profile_name/channel_id/config.yaml``.
This method creates the queried path if not existing. The config file will
not be created, however.
... | [
"Get",
"path",
"for",
"configuration",
"file",
".",
"Defaulted",
"to",
"~",
"/",
".",
"ehforwarderbot",
"/",
"profiles",
"/",
"profile_name",
"/",
"channel_id",
"/",
"config",
".",
"yaml",
".",
"This",
"method",
"creates",
"the",
"queried",
"path",
"if",
"... | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L79-L102 | [
"def",
"get_config_path",
"(",
"module_id",
":",
"str",
"=",
"None",
",",
"ext",
":",
"str",
"=",
"'yaml'",
")",
"->",
"Path",
":",
"if",
"module_id",
":",
"config_path",
"=",
"get_data_path",
"(",
"module_id",
")",
"else",
":",
"profile",
"=",
"coordina... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | get_custom_modules_path | Get the path to custom channels
Returns:
The path for custom channels. | ehforwarderbot/utils.py | def get_custom_modules_path() -> Path:
"""
Get the path to custom channels
Returns:
The path for custom channels.
"""
channel_path = get_base_path() / "modules"
if not channel_path.exists():
channel_path.mkdir(parents=True)
return channel_path | def get_custom_modules_path() -> Path:
"""
Get the path to custom channels
Returns:
The path for custom channels.
"""
channel_path = get_base_path() / "modules"
if not channel_path.exists():
channel_path.mkdir(parents=True)
return channel_path | [
"Get",
"the",
"path",
"to",
"custom",
"channels"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L105-L115 | [
"def",
"get_custom_modules_path",
"(",
")",
"->",
"Path",
":",
"channel_path",
"=",
"get_base_path",
"(",
")",
"/",
"\"modules\"",
"if",
"not",
"channel_path",
".",
"exists",
"(",
")",
":",
"channel_path",
".",
"mkdir",
"(",
"parents",
"=",
"True",
")",
"r... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | locate_module | Locate module by module ID
Args:
module_id: Module ID
module_type: Type of module, one of ``'master'``, ``'slave'`` and ``'middleware'`` | ehforwarderbot/utils.py | def locate_module(module_id: str, module_type: str = None):
"""
Locate module by module ID
Args:
module_id: Module ID
module_type: Type of module, one of ``'master'``, ``'slave'`` and ``'middleware'``
"""
entry_point = None
if module_type:
entry_point = 'ehforwarderbot... | def locate_module(module_id: str, module_type: str = None):
"""
Locate module by module ID
Args:
module_id: Module ID
module_type: Type of module, one of ``'master'``, ``'slave'`` and ``'middleware'``
"""
entry_point = None
if module_type:
entry_point = 'ehforwarderbot... | [
"Locate",
"module",
"by",
"module",
"ID"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/utils.py#L118-L139 | [
"def",
"locate_module",
"(",
"module_id",
":",
"str",
",",
"module_type",
":",
"str",
"=",
"None",
")",
":",
"entry_point",
"=",
"None",
"if",
"module_type",
":",
"entry_point",
"=",
"'ehforwarderbot.%s'",
"%",
"module_type",
"module_id",
"=",
"module_id",
"."... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | add_channel | Register the channel with the coordinator.
Args:
channel (EFBChannel): Channel to register | ehforwarderbot/coordinator.py | def add_channel(channel: EFBChannel):
"""
Register the channel with the coordinator.
Args:
channel (EFBChannel): Channel to register
"""
global master, slaves
if isinstance(channel, EFBChannel):
if channel.channel_type == ChannelType.Slave:
slaves[channel.channel_id]... | def add_channel(channel: EFBChannel):
"""
Register the channel with the coordinator.
Args:
channel (EFBChannel): Channel to register
"""
global master, slaves
if isinstance(channel, EFBChannel):
if channel.channel_type == ChannelType.Slave:
slaves[channel.channel_id]... | [
"Register",
"the",
"channel",
"with",
"the",
"coordinator",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/coordinator.py#L53-L67 | [
"def",
"add_channel",
"(",
"channel",
":",
"EFBChannel",
")",
":",
"global",
"master",
",",
"slaves",
"if",
"isinstance",
"(",
"channel",
",",
"EFBChannel",
")",
":",
"if",
"channel",
".",
"channel_type",
"==",
"ChannelType",
".",
"Slave",
":",
"slaves",
"... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | add_middleware | Register a middleware with the coordinator.
Args:
middleware (EFBMiddleware): Middleware to register | ehforwarderbot/coordinator.py | def add_middleware(middleware: EFBMiddleware):
"""
Register a middleware with the coordinator.
Args:
middleware (EFBMiddleware): Middleware to register
"""
global middlewares
if isinstance(middleware, EFBMiddleware):
middlewares.append(middleware)
else:
raise TypeErr... | def add_middleware(middleware: EFBMiddleware):
"""
Register a middleware with the coordinator.
Args:
middleware (EFBMiddleware): Middleware to register
"""
global middlewares
if isinstance(middleware, EFBMiddleware):
middlewares.append(middleware)
else:
raise TypeErr... | [
"Register",
"a",
"middleware",
"with",
"the",
"coordinator",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/coordinator.py#L70-L81 | [
"def",
"add_middleware",
"(",
"middleware",
":",
"EFBMiddleware",
")",
":",
"global",
"middlewares",
"if",
"isinstance",
"(",
"middleware",
",",
"EFBMiddleware",
")",
":",
"middlewares",
".",
"append",
"(",
"middleware",
")",
"else",
":",
"raise",
"TypeError",
... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | send_message | Deliver a message to the destination channel.
Args:
msg (EFBMsg): The message
Returns:
The message sent by the destination channel,
includes the updated message ID from there.
Returns ``None`` if the message is not sent. | ehforwarderbot/coordinator.py | def send_message(msg: 'EFBMsg') -> Optional['EFBMsg']:
"""
Deliver a message to the destination channel.
Args:
msg (EFBMsg): The message
Returns:
The message sent by the destination channel,
includes the updated message ID from there.
Returns ``None`` if the message is ... | def send_message(msg: 'EFBMsg') -> Optional['EFBMsg']:
"""
Deliver a message to the destination channel.
Args:
msg (EFBMsg): The message
Returns:
The message sent by the destination channel,
includes the updated message ID from there.
Returns ``None`` if the message is ... | [
"Deliver",
"a",
"message",
"to",
"the",
"destination",
"channel",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/coordinator.py#L84-L117 | [
"def",
"send_message",
"(",
"msg",
":",
"'EFBMsg'",
")",
"->",
"Optional",
"[",
"'EFBMsg'",
"]",
":",
"global",
"middlewares",
",",
"master",
",",
"slaves",
"if",
"msg",
"is",
"None",
":",
"return",
"# Go through middlewares",
"for",
"i",
"in",
"middlewares"... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | send_status | Deliver a message to the destination channel.
Args:
status (EFBStatus): The status | ehforwarderbot/coordinator.py | def send_status(status: 'EFBStatus'):
"""
Deliver a message to the destination channel.
Args:
status (EFBStatus): The status
"""
global middlewares, master
if status is None:
return
s: 'Optional[EFBStatus]' = status
# Go through middlewares
for i in middlewares:
... | def send_status(status: 'EFBStatus'):
"""
Deliver a message to the destination channel.
Args:
status (EFBStatus): The status
"""
global middlewares, master
if status is None:
return
s: 'Optional[EFBStatus]' = status
# Go through middlewares
for i in middlewares:
... | [
"Deliver",
"a",
"message",
"to",
"the",
"destination",
"channel",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/coordinator.py#L120-L143 | [
"def",
"send_status",
"(",
"status",
":",
"'EFBStatus'",
")",
":",
"global",
"middlewares",
",",
"master",
"if",
"status",
"is",
"None",
":",
"return",
"s",
":",
"'Optional[EFBStatus]'",
"=",
"status",
"# Go through middlewares",
"for",
"i",
"in",
"middlewares",... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | get_module_by_id | Return the module instance of a provided module ID
Args:
module_id: Module ID, with instance ID if available.
Returns:
Module instance requested.
Raises:
NameError: When the module is not found. | ehforwarderbot/coordinator.py | def get_module_by_id(module_id: str) -> Union[EFBChannel, EFBMiddleware]:
"""
Return the module instance of a provided module ID
Args:
module_id: Module ID, with instance ID if available.
Returns:
Module instance requested.
Raises:
NameError: When the module is not found.
... | def get_module_by_id(module_id: str) -> Union[EFBChannel, EFBMiddleware]:
"""
Return the module instance of a provided module ID
Args:
module_id: Module ID, with instance ID if available.
Returns:
Module instance requested.
Raises:
NameError: When the module is not found.
... | [
"Return",
"the",
"module",
"instance",
"of",
"a",
"provided",
"module",
"ID",
"Args",
":",
"module_id",
":",
"Module",
"ID",
"with",
"instance",
"ID",
"if",
"available",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/coordinator.py#L146-L168 | [
"def",
"get_module_by_id",
"(",
"module_id",
":",
"str",
")",
"->",
"Union",
"[",
"EFBChannel",
",",
"EFBMiddleware",
"]",
":",
"try",
":",
"if",
"master",
".",
"channel_id",
"==",
"module_id",
":",
"return",
"master",
"except",
"NameError",
":",
"pass",
"... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | init | Initialize all channels. | ehforwarderbot/__main__.py | def init(conf):
"""
Initialize all channels.
"""
logger = logging.getLogger(__name__)
# Initialize mimetypes library
mimetypes.init([pkg_resources.resource_filename('ehforwarderbot', 'mimetypes')])
# Initialize all channels
# (Load libraries and modules and init them)
for i in co... | def init(conf):
"""
Initialize all channels.
"""
logger = logging.getLogger(__name__)
# Initialize mimetypes library
mimetypes.init([pkg_resources.resource_filename('ehforwarderbot', 'mimetypes')])
# Initialize all channels
# (Load libraries and modules and init them)
for i in co... | [
"Initialize",
"all",
"channels",
"."
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/__main__.py#L71-L129 | [
"def",
"init",
"(",
"conf",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# Initialize mimetypes library",
"mimetypes",
".",
"init",
"(",
"[",
"pkg_resources",
".",
"resource_filename",
"(",
"'ehforwarderbot'",
",",
"'mimetypes'",
... | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
train | poll | Start threads for polling | ehforwarderbot/__main__.py | def poll():
"""
Start threads for polling
"""
coordinator.master_thread.start()
for i in coordinator.slave_threads:
coordinator.slave_threads[i].start() | def poll():
"""
Start threads for polling
"""
coordinator.master_thread.start()
for i in coordinator.slave_threads:
coordinator.slave_threads[i].start() | [
"Start",
"threads",
"for",
"polling"
] | blueset/ehForwarderBot | python | https://github.com/blueset/ehForwarderBot/blob/62e8fcfe77b2993aba91623f538f404a90f59f1d/ehforwarderbot/__main__.py#L132-L138 | [
"def",
"poll",
"(",
")",
":",
"coordinator",
".",
"master_thread",
".",
"start",
"(",
")",
"for",
"i",
"in",
"coordinator",
".",
"slave_threads",
":",
"coordinator",
".",
"slave_threads",
"[",
"i",
"]",
".",
"start",
"(",
")"
] | 62e8fcfe77b2993aba91623f538f404a90f59f1d |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.