_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q2800 | Color.TriadicScheme | train | def TriadicScheme(self, angle=120, mode='ryb'):
'''Return two colors forming a triad or a split complementary with this one.
Parameters:
:angle:
The angle between the hues of the created colors.
The default value makes a triad.
:mode:
Select which color wheel to use for the ... | python | {
"resource": ""
} |
q2801 | Color.from_html | train | def from_html(cls, html_string):
"""
Create sRGB color from a web-color name or hexcode.
:param str html_string: Web-color name or hexcode.
:rtype: Color
:returns: A spectra.Color in the sRGB color space.
"""
rgb = GC.NewFromHtml(html_string).rgb
return ... | python | {
"resource": ""
} |
q2802 | Color.to | train | def to(self, space):
"""
Convert color to a different color space.
:param str space: Name of the color space.
:rtype: Color
:returns: A new spectra.Color in the given color space.
"""
if space == self.space: return self
new_color = convert_color(self.col... | python | {
"resource": ""
} |
q2803 | Color.blend | train | def blend(self, other, ratio=0.5):
"""
Blend this color with another color in the same color space.
By default, blends the colors half-and-half (ratio: 0.5).
:param Color other: The color to blend.
:param float ratio: How much to blend (0 -> 1).
:rtype: Color
:... | python | {
"resource": ""
} |
q2804 | Color.brighten | train | def brighten(self, amount=10):
"""
Brighten this color by `amount` luminance.
Converts this color to the LCH color space, and then
increases the `L` parameter by `amount`.
:param float amount: Amount to increase the luminance.
:rtype: Color
:returns: A new spec... | python | {
"resource": ""
} |
q2805 | Scale.colorspace | train | def colorspace(self, space):
"""
Create a new scale in the given color space.
:param str space: The new color space.
:rtype: Scale
:returns: A new color.Scale object.
"""
new_colors = [ c.to(space) for c in self.colors ]
return self.__class__(new_colors,... | python | {
"resource": ""
} |
q2806 | Scale.range | train | def range(self, count):
"""
Create a list of colors evenly spaced along this scale's domain.
:param int count: The number of colors to return.
:rtype: list
:returns: A list of spectra.Color objects.
"""
if count <= 1:
raise ValueError("Range size mus... | python | {
"resource": ""
} |
q2807 | sort_response | train | def sort_response(response: Dict[str, Any]) -> OrderedDict:
"""
Sort the keys in a JSON-RPC response object.
This has no effect other than making it nicer to read. Useful in Python 3.5 only,
dictionaries are already sorted in newer Python versions.
Example::
>>> json.dumps(sort_response({... | python | {
"resource": ""
} |
q2808 | parse_callable | train | def parse_callable(path: str) -> Iterator:
"""
ConfigParser converter.
Calls the specified object, e.g. Option "id_generators.decimal" returns
`id_generators.decimal()`.
"""
module = path[: path.rindex(".")]
callable_name = path[path.rindex(".") + 1 :]
callable_ = getattr(importlib.impo... | python | {
"resource": ""
} |
q2809 | random | train | def random(length: int = 8, chars: str = digits + ascii_lowercase) -> Iterator[str]:
"""
A random string.
Not unique, but has around 1 in a million chance of collision (with the default 8
character length). e.g. 'fubui5e6'
Args:
length: Length of the random string.
chars: The chara... | python | {
"resource": ""
} |
q2810 | get_response | train | def get_response(response: Dict[str, Any]) -> JSONRPCResponse:
"""
Converts a deserialized response into a JSONRPCResponse object.
The dictionary be either an error or success response, never a notification.
Args:
response: Deserialized response dictionary. We can assume the response is valid
... | python | {
"resource": ""
} |
q2811 | parse | train | def parse(
response_text: str, *, batch: bool, validate_against_schema: bool = True
) -> Union[JSONRPCResponse, List[JSONRPCResponse]]:
"""
Parses response text, returning JSONRPCResponse objects.
Args:
response_text: JSON-RPC response string.
batch: If the response_text is an empty str... | python | {
"resource": ""
} |
q2812 | AsyncClient.send | train | async def send(
self,
request: Union[str, Dict, List],
trim_log_values: bool = False,
validate_against_schema: bool = True,
**kwargs: Any
) -> Response:
"""
Async version of Client.send.
"""
# We need both the serialized and deserialized versio... | python | {
"resource": ""
} |
q2813 | main | train | def main(
context: click.core.Context, method: str, request_type: str, id: Any, send: str
) -> None:
"""
Create a JSON-RPC request.
"""
exit_status = 0
# Extract the jsonrpc arguments
positional = [a for a in context.args if "=" not in a]
named = {a.split("=")[0]: a.split("=")[1] for a i... | python | {
"resource": ""
} |
q2814 | sort_request | train | def sort_request(request: Dict[str, Any]) -> OrderedDict:
"""
Sort a JSON-RPC request dict.
This has no effect other than making the request nicer to read.
>>> json.dumps(sort_request(
... {'id': 2, 'params': [2, 3], 'method': 'add', 'jsonrpc': '2.0'}))
'{"jsonrpc": "2.0", "met... | python | {
"resource": ""
} |
q2815 | Client.basic_logging | train | def basic_logging(self) -> None:
"""
Call this on the client object to create log handlers to output request and
response messages.
"""
# Request handler
if len(request_log.handlers) == 0:
request_handler = logging.StreamHandler()
request_handler.s... | python | {
"resource": ""
} |
q2816 | Client.log_response | train | def log_response(
self, response: Response, trim_log_values: bool = False, **kwargs: Any
) -> None:
"""
Log a response.
Note this is different to log_request, in that it takes a Response object, not a
string.
Args:
response: The Response object to log. N... | python | {
"resource": ""
} |
q2817 | Client.notify | train | def notify(
self,
method_name: str,
*args: Any,
trim_log_values: Optional[bool] = None,
validate_against_schema: Optional[bool] = None,
**kwargs: Any
) -> Response:
"""
Send a JSON-RPC request, without expecting a response.
Args:
m... | python | {
"resource": ""
} |
q2818 | Client.request | train | def request(
self,
method_name: str,
*args: Any,
trim_log_values: bool = False,
validate_against_schema: bool = True,
id_generator: Optional[Iterator] = None,
**kwargs: Any
) -> Response:
"""
Send a request by passing the method and arguments.
... | python | {
"resource": ""
} |
q2819 | Oep4.init | train | def init(self, acct: Account, payer_acct: Account, gas_limit: int, gas_price: int) -> str:
"""
This interface is used to call the TotalSupply method in ope4
that initialize smart contract parameter.
:param acct: an Account class that used to sign the transaction.
:param payer_ac... | python | {
"resource": ""
} |
q2820 | Oep4.get_total_supply | train | def get_total_supply(self) -> int:
"""
This interface is used to call the TotalSupply method in ope4
that return the total supply of the oep4 token.
:return: the total supply of the oep4 token.
"""
func = InvokeFunction('totalSupply')
response = self.__sdk.get_ne... | python | {
"resource": ""
} |
q2821 | Oep4.balance_of | train | def balance_of(self, b58_address: str) -> int:
"""
This interface is used to call the BalanceOf method in ope4
that query the ope4 token balance of the given base58 encode address.
:param b58_address: the base58 encode address.
:return: the oep4 token balance of the base58 encod... | python | {
"resource": ""
} |
q2822 | Oep4.transfer | train | def transfer(self, from_acct: Account, b58_to_address: str, value: int, payer_acct: Account, gas_limit: int,
gas_price: int) -> str:
"""
This interface is used to call the Transfer method in ope4
that transfer an amount of tokens from one account to another account.
:pa... | python | {
"resource": ""
} |
q2823 | Oep4.transfer_multi | train | def transfer_multi(self, transfer_list: list, payer_acct: Account, signers: list, gas_limit: int, gas_price: int):
"""
This interface is used to call the TransferMulti method in ope4
that allow transfer amount of token from multiple from-account to multiple to-account multiple times.
:p... | python | {
"resource": ""
} |
q2824 | Oep4.approve | train | def approve(self, owner_acct: Account, b58_spender_address: str, amount: int, payer_acct: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to call the Approve method in ope4
that allows spender to withdraw a certain amount of oep4 token from owner account mult... | python | {
"resource": ""
} |
q2825 | Oep4.allowance | train | def allowance(self, b58_owner_address: str, b58_spender_address: str):
"""
This interface is used to call the Allowance method in ope4
that query the amount of spender still allowed to withdraw from owner account.
:param b58_owner_address: a base58 encode address that represent owner's ... | python | {
"resource": ""
} |
q2826 | Oep4.transfer_from | train | def transfer_from(self, spender_acct: Account, b58_from_address: str, b58_to_address: str, value: int,
payer_acct: Account, gas_limit: int, gas_price: int):
"""
This interface is used to call the Allowance method in ope4
that allow spender to withdraw amount of oep4 token f... | python | {
"resource": ""
} |
q2827 | WalletManager.import_identity | train | def import_identity(self, label: str, encrypted_pri_key: str, pwd: str, salt: str, b58_address: str) -> Identity:
"""
This interface is used to import identity by providing encrypted private key, password, salt and
base58 encode address which should be correspond to the encrypted private key pro... | python | {
"resource": ""
} |
q2828 | WalletManager.create_identity_from_private_key | train | def create_identity_from_private_key(self, label: str, pwd: str, private_key: str) -> Identity:
"""
This interface is used to create identity based on given label, password and private key.
:param label: a label for identity.
:param pwd: a password which will be used to encrypt and decr... | python | {
"resource": ""
} |
q2829 | WalletManager.create_account | train | def create_account(self, pwd: str, label: str = '') -> Account:
"""
This interface is used to create account based on given password and label.
:param label: a label for account.
:param pwd: a password which will be used to encrypt and decrypt the private key
:return: if succeed... | python | {
"resource": ""
} |
q2830 | WalletManager.import_account | train | def import_account(self, label: str, encrypted_pri_key: str, pwd: str, b58_address: str,
b64_salt: str, n: int = 16384) -> AccountData:
"""
This interface is used to import account by providing account data.
:param label: str, wallet label
:param encrypted_pri_key... | python | {
"resource": ""
} |
q2831 | WalletManager.create_account_from_private_key | train | def create_account_from_private_key(self, password: str, private_key: str, label: str = '') -> AccountData:
"""
This interface is used to create account by providing an encrypted private key and it's decrypt password.
:param label: a label for account.
:param password: a password which ... | python | {
"resource": ""
} |
q2832 | WalletManager.get_default_account_data | train | def get_default_account_data(self) -> AccountData:
"""
This interface is used to get the default account in WalletManager.
:return: an AccountData object that contain all the information of a default account.
"""
for acct in self.wallet_in_mem.accounts:
if not isinst... | python | {
"resource": ""
} |
q2833 | AbiInfo.get_function | train | def get_function(self, name: str) -> AbiFunction or None:
"""
This interface is used to get an AbiFunction object from AbiInfo object by given function name.
:param name: the function name in abi file
:return: if succeed, an AbiFunction will constructed based on given function name
... | python | {
"resource": ""
} |
q2834 | RpcClient.get_version | train | def get_version(self, is_full: bool = False) -> dict or str:
"""
This interface is used to get the version information of the connected node in current network.
Return:
the version information of the connected node.
"""
payload = self.generate_json_rpc_payload(RpcMet... | python | {
"resource": ""
} |
q2835 | RpcClient.get_connection_count | train | def get_connection_count(self, is_full: bool = False) -> int:
"""
This interface is used to get the current number of connections for the node in current network.
Return:
the number of connections.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_NODE_COUNT... | python | {
"resource": ""
} |
q2836 | RpcClient.get_gas_price | train | def get_gas_price(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the gas price in current network.
Return:
the value of gas price.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_GAS_PRICE)
response = self.__post(sel... | python | {
"resource": ""
} |
q2837 | RpcClient.get_network_id | train | def get_network_id(self, is_full: bool = False) -> int:
"""
This interface is used to get the network id of current network.
Return:
the network id of current network.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_NETWORK_ID)
response = self.__p... | python | {
"resource": ""
} |
q2838 | RpcClient.get_block_by_height | train | def get_block_by_height(self, height: int, is_full: bool = False) -> dict:
"""
This interface is used to get the block information by block height in current network.
Return:
the decimal total number of blocks in current network.
"""
payload = self.generate_json_rpc_... | python | {
"resource": ""
} |
q2839 | RpcClient.get_block_count | train | def get_block_count(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the decimal block number in current network.
Return:
the decimal total number of blocks in current network.
"""
payload = self.generate_json_rpc_payload(RpcMethod.GET_B... | python | {
"resource": ""
} |
q2840 | RpcClient.get_block_height | train | def get_block_height(self, is_full: bool = False) -> int or dict:
"""
This interface is used to get the decimal block height in current network.
Return:
the decimal total height of blocks in current network.
"""
response = self.get_block_count(is_full=True)
r... | python | {
"resource": ""
} |
q2841 | RpcClient.get_current_block_hash | train | def get_current_block_hash(self, is_full: bool = False) -> str:
"""
This interface is used to get the hexadecimal hash value of the highest block in current network.
Return:
the hexadecimal hash value of the highest block in current network.
"""
payload = self.genera... | python | {
"resource": ""
} |
q2842 | RpcClient.get_balance | train | def get_balance(self, b58_address: str, is_full: bool = False) -> dict:
"""
This interface is used to get the account balance of specified base58 encoded address in current network.
:param b58_address: a base58 encoded account address.
:param is_full:
:return: the value of accou... | python | {
"resource": ""
} |
q2843 | RpcClient.get_allowance | train | def get_allowance(self, asset_name: str, from_address: str, to_address: str, is_full: bool = False) -> str:
"""
This interface is used to get the the allowance
from transfer-from account to transfer-to account in current network.
:param asset_name:
:param from_address: a base58 ... | python | {
"resource": ""
} |
q2844 | RpcClient.get_storage | train | def get_storage(self, hex_contract_address: str, hex_key: str, is_full: bool = False) -> str:
"""
This interface is used to get the corresponding stored value
based on hexadecimal contract address and stored key.
:param hex_contract_address: hexadecimal contract address.
:param ... | python | {
"resource": ""
} |
q2845 | RpcClient.get_transaction_by_tx_hash | train | def get_transaction_by_tx_hash(self, tx_hash: str, is_full: bool = False) -> dict:
"""
This interface is used to get the corresponding transaction information based on the specified hash value.
:param tx_hash: str, a hexadecimal hash value.
:param is_full:
:return: dict
... | python | {
"resource": ""
} |
q2846 | RpcClient.get_smart_contract | train | def get_smart_contract(self, hex_contract_address: str, is_full: bool = False) -> dict:
"""
This interface is used to get the information of smart contract based on the specified hexadecimal hash value.
:param hex_contract_address: str, a hexadecimal hash value.
:param is_full:
... | python | {
"resource": ""
} |
q2847 | RpcClient.get_merkle_proof | train | def get_merkle_proof(self, tx_hash: str, is_full: bool = False) -> dict:
"""
This interface is used to get the corresponding merkle proof based on the specified hexadecimal hash value.
:param tx_hash: an hexadecimal transaction hash value.
:param is_full:
:return: the merkle pro... | python | {
"resource": ""
} |
q2848 | OntId.parse_ddo | train | def parse_ddo(ont_id: str, serialized_ddo: str or bytes) -> dict:
"""
This interface is used to deserialize a hexadecimal string into a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:param serialized_ddo: an serialized description object of ONT ID in form of... | python | {
"resource": ""
} |
q2849 | OntId.get_ddo | train | def get_ddo(self, ont_id: str) -> dict:
"""
This interface is used to get a DDO object in the from of dict.
:param ont_id: the unique ID for identity.
:return: a description object of ONT ID in the from of dict.
"""
args = dict(ontid=ont_id.encode('utf-8'))
invok... | python | {
"resource": ""
} |
q2850 | OntId.registry_ont_id | train | def registry_ont_id(self, ont_id: str, ctrl_acct: Account, payer: Account, gas_limit: int, gas_price: int):
"""
This interface is used to send a Transaction object which is used to registry ontid.
:param ont_id: OntId.
:param ctrl_acct: an Account object which indicate who will sign for... | python | {
"resource": ""
} |
q2851 | OntId.add_attribute | train | def add_attribute(self, ont_id: str, ctrl_acct: Account, attributes: Attribute, payer: Account, gas_limit: int,
gas_price: int) -> str:
"""
This interface is used to send a Transaction object which is used to add attribute.
:param ont_id: OntId.
:param ctrl_acct: a... | python | {
"resource": ""
} |
q2852 | OntId.remove_attribute | train | def remove_attribute(self, ont_id: str, operator: Account, attrib_key: str, payer: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to send a Transaction object which is used to remove attribute.
:param ont_id: OntId.
:param operator: an Acco... | python | {
"resource": ""
} |
q2853 | OntId.add_recovery | train | def add_recovery(self, ont_id: str, ctrl_acct: Account, b58_recovery_address: str, payer: Account, gas_limit: int,
gas_price: int):
"""
This interface is used to send a Transaction object which is used to add the recovery.
:param ont_id: OntId.
:param ctrl_acct: an ... | python | {
"resource": ""
} |
q2854 | OntId.new_registry_ont_id_transaction | train | def new_registry_ont_id_transaction(self, ont_id: str, pub_key: str or bytes, b58_payer_address: str,
gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object which is used to register ONT ID.
:param ont_... | python | {
"resource": ""
} |
q2855 | OntId.new_revoke_public_key_transaction | train | def new_revoke_public_key_transaction(self, ont_id: str, bytes_operator: bytes, revoked_pub_key: str or bytes,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to remove public key... | python | {
"resource": ""
} |
q2856 | OntId.new_add_attribute_transaction | train | def new_add_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attributes: Attribute,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to add attribute.
:param on... | python | {
"resource": ""
} |
q2857 | OntId.new_remove_attribute_transaction | train | def new_remove_attribute_transaction(self, ont_id: str, pub_key: str or bytes, attrib_key: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to remove attribute.
:param... | python | {
"resource": ""
} |
q2858 | OntId.new_add_recovery_transaction | train | def new_add_recovery_transaction(self, ont_id: str, pub_key: str or bytes, b58_recovery_address: str,
b58_payer_address: str, gas_limit: int, gas_price: int):
"""
This interface is used to generate a Transaction object which is used to add the recovery.
:par... | python | {
"resource": ""
} |
q2859 | Transaction.sign_transaction | train | def sign_transaction(self, signer: Account):
"""
This interface is used to sign the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed.
"""
tx_hash = self.hash256()
sig_data = signer.... | python | {
"resource": ""
} |
q2860 | Transaction.add_sign_transaction | train | def add_sign_transaction(self, signer: Account):
"""
This interface is used to add signature into the transaction.
:param signer: an Account object which will sign the transaction.
:return: a Transaction object which has been signed.
"""
if self.sig_list is None or len(s... | python | {
"resource": ""
} |
q2861 | Transaction.add_multi_sign_transaction | train | def add_multi_sign_transaction(self, m: int, pub_keys: List[bytes] or List[str], signer: Account):
"""
This interface is used to generate an Transaction object which has multi signature.
:param tx: a Transaction object which will be signed.
:param m: the amount of signer.
:param... | python | {
"resource": ""
} |
q2862 | Account.export_gcm_encrypted_private_key | train | def export_gcm_encrypted_private_key(self, password: str, salt: str, n: int = 16384) -> str:
"""
This interface is used to export an AES algorithm encrypted private key with the mode of GCM.
:param password: the secret pass phrase to generate the keys from.
:param salt: A string to use ... | python | {
"resource": ""
} |
q2863 | Account.get_gcm_decoded_private_key | train | def get_gcm_decoded_private_key(encrypted_key_str: str, password: str, b58_address: str, salt: str, n: int,
scheme: SignatureScheme) -> str:
"""
This interface is used to decrypt an private key which has been encrypted.
:param encrypted_key_str: an gcm encryp... | python | {
"resource": ""
} |
q2864 | Account.export_wif | train | def export_wif(self) -> str:
"""
This interface is used to get export ECDSA private key in the form of WIF which
is a way to encoding an ECDSA private key and make it easier to copy.
:return: a WIF encode private key.
"""
data = b''.join([b'\x80', self.__private_key, b'\... | python | {
"resource": ""
} |
q2865 | Account.get_private_key_from_wif | train | def get_private_key_from_wif(wif: str) -> bytes:
"""
This interface is used to decode a WIF encode ECDSA private key.
:param wif: a WIF encode private key.
:return: a ECDSA private key in the form of bytes.
"""
if wif is None or wif is "":
raise Exception("no... | python | {
"resource": ""
} |
q2866 | pbkdf2 | train | def pbkdf2(seed: str or bytes, dk_len: int) -> bytes:
"""
Derive one key from a seed.
:param seed: the secret pass phrase to generate the keys from.
:param dk_len: the length in bytes of every derived key.
:return:
"""
key = b''
index = 1
bytes_seed = str_to_bytes(seed)
while le... | python | {
"resource": ""
} |
q2867 | AbiFunction.set_params_value | train | def set_params_value(self, *params):
"""
This interface is used to set parameter value for an function in abi file.
"""
if len(params) != len(self.parameters):
raise Exception("parameter error")
temp = self.parameters
self.parameters = []
for i in rang... | python | {
"resource": ""
} |
q2868 | AbiFunction.get_parameter | train | def get_parameter(self, param_name: str) -> Parameter:
"""
This interface is used to get a Parameter object from an AbiFunction object
which contain given function parameter's name, type and value.
:param param_name: a string used to indicate which parameter we want to get from AbiFunct... | python | {
"resource": ""
} |
q2869 | BinaryReader.read_bytes | train | def read_bytes(self, length) -> bytes:
"""
Read the specified number of bytes from the stream.
Args:
length (int): number of bytes to read.
Returns:
bytes: `length` number of bytes.
"""
value = self.stream.read(length)
return value | python | {
"resource": ""
} |
q2870 | BinaryReader.read_float | train | def read_float(self, little_endian=True):
"""
Read 4 bytes as a float value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float:
"""
if little_endian:
endian = "<"
else:... | python | {
"resource": ""
} |
q2871 | BinaryReader.read_double | train | def read_double(self, little_endian=True):
"""
Read 8 bytes as a double value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
float:
"""
if little_endian:
endian = "<"
els... | python | {
"resource": ""
} |
q2872 | BinaryReader.read_int8 | train | def read_int8(self, little_endian=True):
"""
Read 1 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2873 | BinaryReader.read_uint8 | train | def read_uint8(self, little_endian=True):
"""
Read 1 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2874 | BinaryReader.read_int16 | train | def read_int16(self, little_endian=True):
"""
Read 2 byte as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2875 | BinaryReader.read_uint16 | train | def read_uint16(self, little_endian=True):
"""
Read 2 byte as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2876 | BinaryReader.read_int32 | train | def read_int32(self, little_endian=True):
"""
Read 4 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2877 | BinaryReader.read_uint32 | train | def read_uint32(self, little_endian=True):
"""
Read 4 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2878 | BinaryReader.read_int64 | train | def read_int64(self, little_endian=True):
"""
Read 8 bytes as a signed integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2879 | BinaryReader.read_uint64 | train | def read_uint64(self, little_endian=True):
"""
Read 8 bytes as an unsigned integer value from the stream.
Args:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int:
"""
if little_endian:
endian = "<"
... | python | {
"resource": ""
} |
q2880 | BinaryReader.read_var_bytes | train | def read_var_bytes(self, max_size=sys.maxsize) -> bytes:
"""
Read a variable length of bytes from the stream.
Args:
max_size (int): (Optional) maximum number of bytes to read.
Returns:
bytes:
"""
length = self.read_var_int(max_size)
retur... | python | {
"resource": ""
} |
q2881 | BinaryWriter.write_byte | train | def write_byte(self, value):
"""
Write a single byte to the stream.
Args:
value (bytes, str or int): value to write to the stream.
"""
if isinstance(value, bytes):
self.stream.write(value)
elif isinstance(value, str):
self.stream.write... | python | {
"resource": ""
} |
q2882 | BinaryWriter.write_float | train | def write_float(self, value, little_endian=True):
"""
Pack the value as a float and write 4 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
i... | python | {
"resource": ""
} |
q2883 | BinaryWriter.write_double | train | def write_double(self, value, little_endian=True):
"""
Pack the value as a double and write 8 bytes to the stream.
Args:
value (number): the value to write to the stream.
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
... | python | {
"resource": ""
} |
q2884 | BinaryWriter.write_int8 | train | def write_int8(self, value, little_endian=True):
"""
Pack the value as a signed byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | {
"resource": ""
} |
q2885 | BinaryWriter.write_uint8 | train | def write_uint8(self, value, little_endian=True):
"""
Pack the value as an unsigned byte and write 1 byte to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | {
"resource": ""
} |
q2886 | BinaryWriter.write_int16 | train | def write_int16(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | {
"resource": ""
} |
q2887 | BinaryWriter.write_uint16 | train | def write_uint16(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 2 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | {
"resource": ""
} |
q2888 | BinaryWriter.write_int32 | train | def write_int32(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | {
"resource": ""
} |
q2889 | BinaryWriter.write_uint32 | train | def write_uint32(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 4 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | {
"resource": ""
} |
q2890 | BinaryWriter.write_int64 | train | def write_int64(self, value, little_endian=True):
"""
Pack the value as a signed integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes written.
... | python | {
"resource": ""
} |
q2891 | BinaryWriter.write_uint64 | train | def write_uint64(self, value, little_endian=True):
"""
Pack the value as an unsigned integer and write 8 bytes to the stream.
Args:
value:
little_endian (bool): specify the endianness. (Default) Little endian.
Returns:
int: the number of bytes writte... | python | {
"resource": ""
} |
q2892 | Asset.get_asset_address | train | def get_asset_address(self, asset: str) -> bytes:
"""
This interface is used to get the smart contract address of ONT otr ONG.
:param asset: a string which is used to indicate which asset's contract address we want to get.
:return: the contract address of asset in the form of bytearray.... | python | {
"resource": ""
} |
q2893 | Asset.query_balance | train | def query_balance(self, asset: str, b58_address: str) -> int:
"""
This interface is used to query the account's ONT or ONG balance.
:param asset: a string which is used to indicate which asset we want to check the balance.
:param b58_address: a base58 encode account address.
:re... | python | {
"resource": ""
} |
q2894 | Asset.query_unbound_ong | train | def query_unbound_ong(self, base58_address: str) -> int:
"""
This interface is used to query the amount of account's unbound ong.
:param base58_address: a base58 encode address which indicate which account's unbound ong we want to query.
:return: the amount of unbound ong in the form of... | python | {
"resource": ""
} |
q2895 | Asset.query_symbol | train | def query_symbol(self, asset: str) -> str:
"""
This interface is used to query the asset's symbol of ONT or ONG.
:param asset: a string which is used to indicate which asset's symbol we want to get.
:return: asset's symbol in the form of string.
"""
contract_address = se... | python | {
"resource": ""
} |
q2896 | Asset.query_decimals | train | def query_decimals(self, asset: str) -> int:
"""
This interface is used to query the asset's decimals of ONT or ONG.
:param asset: a string which is used to indicate which asset's decimals we want to get
:return: asset's decimals in the form of int
"""
contract_address =... | python | {
"resource": ""
} |
q2897 | Asset.new_transfer_transaction | train | def new_transfer_transaction(self, asset: str, b58_from_address: str, b58_to_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object for transfer.
:param asset... | python | {
"resource": ""
} |
q2898 | Asset.new_approve_transaction | train | def new_approve_transaction(self, asset: str, b58_send_address: str, b58_recv_address: str, amount: int,
b58_payer_address: str, gas_limit: int, gas_price: int) -> Transaction:
"""
This interface is used to generate a Transaction object for approve.
:param asset:... | python | {
"resource": ""
} |
q2899 | Asset.new_transfer_from_transaction | train | def new_transfer_from_transaction(self, asset: str, b58_send_address: str, b58_from_address: str,
b58_recv_address: str, amount: int, b58_payer_address: str, gas_limit: int,
gas_price: int) -> Transaction:
"""
This interface is ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.