repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
peterdemin/pip-compile-multi | pipcompilemulti/actions.py | merged_packages | def merged_packages(env_packages, names):
"""
Return union set of environment packages with given names
>>> sorted(merged_packages(
... {
... 'a': {'x': 1, 'y': 2},
... 'b': {'y': 2, 'z': 3},
... 'c': {'z': 3, 'w': 4}
... },
... ['a', 'b']
...... | python | def merged_packages(env_packages, names):
"""
Return union set of environment packages with given names
>>> sorted(merged_packages(
... {
... 'a': {'x': 1, 'y': 2},
... 'b': {'y': 2, 'z': 3},
... 'c': {'z': 3, 'w': 4}
... },
... ['a', 'b']
...... | [
"def",
"merged_packages",
"(",
"env_packages",
",",
"names",
")",
":",
"combined_packages",
"=",
"sorted",
"(",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"env_packages",
"[",
"name",
"]",
".",
"items",
"(",
")",
"for",
"name",
"in",
"names",
")... | Return union set of environment packages with given names
>>> sorted(merged_packages(
... {
... 'a': {'x': 1, 'y': 2},
... 'b': {'y': 2, 'z': 3},
... 'c': {'z': 3, 'w': 4}
... },
... ['a', 'b']
... ).items())
[('x', 1), ('y', 2), ('z', 3)] | [
"Return",
"union",
"set",
"of",
"environment",
"packages",
"with",
"given",
"names"
] | 7bd1968c424dd7ce3236885b4b3e4e28523e6915 | https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/actions.py#L65-L101 | train |
peterdemin/pip-compile-multi | pipcompilemulti/actions.py | recursive_refs | def recursive_refs(envs, name):
"""
Return set of recursive refs for given env name
>>> local_refs = sorted(recursive_refs([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'local'))
>>> local_refs == ... | python | def recursive_refs(envs, name):
"""
Return set of recursive refs for given env name
>>> local_refs = sorted(recursive_refs([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'local'))
>>> local_refs == ... | [
"def",
"recursive_refs",
"(",
"envs",
",",
"name",
")",
":",
"refs_by_name",
"=",
"{",
"env",
"[",
"'name'",
"]",
":",
"set",
"(",
"env",
"[",
"'refs'",
"]",
")",
"for",
"env",
"in",
"envs",
"}",
"refs",
"=",
"refs_by_name",
"[",
"name",
"]",
"if",... | Return set of recursive refs for given env name
>>> local_refs = sorted(recursive_refs([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'local'))
>>> local_refs == ['base', 'test']
True | [
"Return",
"set",
"of",
"recursive",
"refs",
"for",
"given",
"env",
"name"
] | 7bd1968c424dd7ce3236885b4b3e4e28523e6915 | https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/actions.py#L104-L128 | train |
peterdemin/pip-compile-multi | pipcompilemulti/actions.py | reference_cluster | def reference_cluster(envs, name):
"""
Return set of all env names referencing or
referenced by given name.
>>> cluster = sorted(reference_cluster([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'tes... | python | def reference_cluster(envs, name):
"""
Return set of all env names referencing or
referenced by given name.
>>> cluster = sorted(reference_cluster([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'tes... | [
"def",
"reference_cluster",
"(",
"envs",
",",
"name",
")",
":",
"edges",
"=",
"[",
"set",
"(",
"[",
"env",
"[",
"'name'",
"]",
",",
"ref",
"]",
")",
"for",
"env",
"in",
"envs",
"for",
"ref",
"in",
"env",
"[",
"'refs'",
"]",
"]",
"prev",
",",
"c... | Return set of all env names referencing or
referenced by given name.
>>> cluster = sorted(reference_cluster([
... {'name': 'base', 'refs': []},
... {'name': 'test', 'refs': ['base']},
... {'name': 'local', 'refs': ['test']},
... ], 'test'))
>>> cluster == ['base', 'local', 'test... | [
"Return",
"set",
"of",
"all",
"env",
"names",
"referencing",
"or",
"referenced",
"by",
"given",
"name",
"."
] | 7bd1968c424dd7ce3236885b4b3e4e28523e6915 | https://github.com/peterdemin/pip-compile-multi/blob/7bd1968c424dd7ce3236885b4b3e4e28523e6915/pipcompilemulti/actions.py#L131-L163 | train |
oceanprotocol/squid-py | squid_py/http_requests/requests_session.py | get_requests_session | def get_requests_session():
"""
Set connection pool maxsize and block value to avoid `connection pool full` warnings.
:return: requests session
"""
session = requests.sessions.Session()
session.mount('http://', HTTPAdapter(pool_connections=25, pool_maxsize=25, pool_block=True))
session.moun... | python | def get_requests_session():
"""
Set connection pool maxsize and block value to avoid `connection pool full` warnings.
:return: requests session
"""
session = requests.sessions.Session()
session.mount('http://', HTTPAdapter(pool_connections=25, pool_maxsize=25, pool_block=True))
session.moun... | [
"def",
"get_requests_session",
"(",
")",
":",
"session",
"=",
"requests",
".",
"sessions",
".",
"Session",
"(",
")",
"session",
".",
"mount",
"(",
"'http://'",
",",
"HTTPAdapter",
"(",
"pool_connections",
"=",
"25",
",",
"pool_maxsize",
"=",
"25",
",",
"po... | Set connection pool maxsize and block value to avoid `connection pool full` warnings.
:return: requests session | [
"Set",
"connection",
"pool",
"maxsize",
"and",
"block",
"value",
"to",
"avoid",
"connection",
"pool",
"full",
"warnings",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/http_requests/requests_session.py#L5-L14 | train |
oceanprotocol/squid-py | squid_py/keeper/dispenser.py | Dispenser.request_tokens | def request_tokens(self, amount, account):
"""
Request an amount of tokens for a particular address.
This transaction has gas cost
:param amount: Amount of tokens, int
:param account: Account instance
:raise OceanInvalidTransaction: Transaction failed
:return: bo... | python | def request_tokens(self, amount, account):
"""
Request an amount of tokens for a particular address.
This transaction has gas cost
:param amount: Amount of tokens, int
:param account: Account instance
:raise OceanInvalidTransaction: Transaction failed
:return: bo... | [
"def",
"request_tokens",
"(",
"self",
",",
"amount",
",",
"account",
")",
":",
"address",
"=",
"account",
".",
"address",
"try",
":",
"tx_hash",
"=",
"self",
".",
"send_transaction",
"(",
"'requestTokens'",
",",
"(",
"amount",
",",
")",
",",
"transact",
... | Request an amount of tokens for a particular address.
This transaction has gas cost
:param amount: Amount of tokens, int
:param account: Account instance
:raise OceanInvalidTransaction: Transaction failed
:return: bool | [
"Request",
"an",
"amount",
"of",
"tokens",
"for",
"a",
"particular",
"address",
".",
"This",
"transaction",
"has",
"gas",
"cost"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/dispenser.py#L20-L87 | train |
oceanprotocol/squid-py | squid_py/keeper/keeper.py | Keeper.get_network_name | def get_network_name(network_id):
"""
Return the keeper network name based on the current ethereum network id.
Return `development` for every network id that is not mapped.
:param network_id: Network id, int
:return: Network name, str
"""
if os.environ.get('KEEPE... | python | def get_network_name(network_id):
"""
Return the keeper network name based on the current ethereum network id.
Return `development` for every network id that is not mapped.
:param network_id: Network id, int
:return: Network name, str
"""
if os.environ.get('KEEPE... | [
"def",
"get_network_name",
"(",
"network_id",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'KEEPER_NETWORK_NAME'",
")",
":",
"logging",
".",
"debug",
"(",
"'keeper network name overridden by an environment variable: {}'",
".",
"format",
"(",
"os",
".",
... | Return the keeper network name based on the current ethereum network id.
Return `development` for every network id that is not mapped.
:param network_id: Network id, int
:return: Network name, str | [
"Return",
"the",
"keeper",
"network",
"name",
"based",
"on",
"the",
"current",
"ethereum",
"network",
"id",
".",
"Return",
"development",
"for",
"every",
"network",
"id",
"that",
"is",
"not",
"mapped",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/keeper.py#L68-L81 | train |
oceanprotocol/squid-py | squid_py/keeper/keeper.py | Keeper.unlock_account | def unlock_account(account):
"""
Unlock the account.
:param account: Account
:return:
"""
return Web3Provider.get_web3().personal.unlockAccount(account.address, account.password) | python | def unlock_account(account):
"""
Unlock the account.
:param account: Account
:return:
"""
return Web3Provider.get_web3().personal.unlockAccount(account.address, account.password) | [
"def",
"unlock_account",
"(",
"account",
")",
":",
"return",
"Web3Provider",
".",
"get_web3",
"(",
")",
".",
"personal",
".",
"unlockAccount",
"(",
"account",
".",
"address",
",",
"account",
".",
"password",
")"
] | Unlock the account.
:param account: Account
:return: | [
"Unlock",
"the",
"account",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/keeper.py#L114-L121 | train |
oceanprotocol/squid-py | squid_py/keeper/keeper.py | Keeper.get_condition_name_by_address | def get_condition_name_by_address(self, address):
"""Return the condition name for a given address."""
if self.lock_reward_condition.address == address:
return 'lockReward'
elif self.access_secret_store_condition.address == address:
return 'accessSecretStore'
elif... | python | def get_condition_name_by_address(self, address):
"""Return the condition name for a given address."""
if self.lock_reward_condition.address == address:
return 'lockReward'
elif self.access_secret_store_condition.address == address:
return 'accessSecretStore'
elif... | [
"def",
"get_condition_name_by_address",
"(",
"self",
",",
"address",
")",
":",
"if",
"self",
".",
"lock_reward_condition",
".",
"address",
"==",
"address",
":",
"return",
"'lockReward'",
"elif",
"self",
".",
"access_secret_store_condition",
".",
"address",
"==",
"... | Return the condition name for a given address. | [
"Return",
"the",
"condition",
"name",
"for",
"a",
"given",
"address",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/keeper.py#L133-L142 | train |
oceanprotocol/squid-py | squid_py/brizo/brizo.py | Brizo.consume_service | def consume_service(service_agreement_id, service_endpoint, account, files,
destination_folder, index=None):
"""
Call the brizo endpoint to get access to the different files that form the asset.
:param service_agreement_id: Service Agreement Id, str
:param servic... | python | def consume_service(service_agreement_id, service_endpoint, account, files,
destination_folder, index=None):
"""
Call the brizo endpoint to get access to the different files that form the asset.
:param service_agreement_id: Service Agreement Id, str
:param servic... | [
"def",
"consume_service",
"(",
"service_agreement_id",
",",
"service_endpoint",
",",
"account",
",",
"files",
",",
"destination_folder",
",",
"index",
"=",
"None",
")",
":",
"signature",
"=",
"Keeper",
".",
"get_instance",
"(",
")",
".",
"sign_hash",
"(",
"ser... | Call the brizo endpoint to get access to the different files that form the asset.
:param service_agreement_id: Service Agreement Id, str
:param service_endpoint: Url to consume, str
:param account: Account instance of the consumer signing this agreement, hex-str
:param files: List conta... | [
"Call",
"the",
"brizo",
"endpoint",
"to",
"get",
"access",
"to",
"the",
"different",
"files",
"that",
"form",
"the",
"asset",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/brizo/brizo.py#L99-L132 | train |
oceanprotocol/squid-py | squid_py/brizo/brizo.py | Brizo._prepare_consume_payload | def _prepare_consume_payload(did, service_agreement_id, service_definition_id, signature,
consumer_address):
"""Prepare a payload to send to `Brizo`.
:param did: DID, str
:param service_agreement_id: Service Agreement Id, str
:param service_definition_i... | python | def _prepare_consume_payload(did, service_agreement_id, service_definition_id, signature,
consumer_address):
"""Prepare a payload to send to `Brizo`.
:param did: DID, str
:param service_agreement_id: Service Agreement Id, str
:param service_definition_i... | [
"def",
"_prepare_consume_payload",
"(",
"did",
",",
"service_agreement_id",
",",
"service_definition_id",
",",
"signature",
",",
"consumer_address",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"{",
"'did'",
":",
"did",
",",
"'serviceAgreementId'",
":",
"service... | Prepare a payload to send to `Brizo`.
:param did: DID, str
:param service_agreement_id: Service Agreement Id, str
:param service_definition_id: identifier of the service inside the asset DDO, str
service in the DDO (DID document)
:param signature: the signed agreement message ha... | [
"Prepare",
"a",
"payload",
"to",
"send",
"to",
"Brizo",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/brizo/brizo.py#L135-L154 | train |
oceanprotocol/squid-py | squid_py/brizo/brizo.py | Brizo.get_brizo_url | def get_brizo_url(config):
"""
Return the Brizo component url.
:param config: Config
:return: Url, str
"""
brizo_url = 'http://localhost:8030'
if config.has_option('resources', 'brizo.url'):
brizo_url = config.get('resources', 'brizo.url') or brizo_ur... | python | def get_brizo_url(config):
"""
Return the Brizo component url.
:param config: Config
:return: Url, str
"""
brizo_url = 'http://localhost:8030'
if config.has_option('resources', 'brizo.url'):
brizo_url = config.get('resources', 'brizo.url') or brizo_ur... | [
"def",
"get_brizo_url",
"(",
"config",
")",
":",
"brizo_url",
"=",
"'http://localhost:8030'",
"if",
"config",
".",
"has_option",
"(",
"'resources'",
",",
"'brizo.url'",
")",
":",
"brizo_url",
"=",
"config",
".",
"get",
"(",
"'resources'",
",",
"'brizo.url'",
"... | Return the Brizo component url.
:param config: Config
:return: Url, str | [
"Return",
"the",
"Brizo",
"component",
"url",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/brizo/brizo.py#L157-L169 | train |
oceanprotocol/squid-py | squid_py/ddo/metadata.py | Metadata.validate | def validate(metadata):
"""Validator of the metadata composition
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: bool
"""
# validate required sections and their sub items
for section_key in Metadata.REQUIRED_SECTIONS:
if ... | python | def validate(metadata):
"""Validator of the metadata composition
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: bool
"""
# validate required sections and their sub items
for section_key in Metadata.REQUIRED_SECTIONS:
if ... | [
"def",
"validate",
"(",
"metadata",
")",
":",
"for",
"section_key",
"in",
"Metadata",
".",
"REQUIRED_SECTIONS",
":",
"if",
"section_key",
"not",
"in",
"metadata",
"or",
"not",
"metadata",
"[",
"section_key",
"]",
"or",
"not",
"isinstance",
"(",
"metadata",
"... | Validator of the metadata composition
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: bool | [
"Validator",
"of",
"the",
"metadata",
"composition"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/metadata.py#L127-L145 | train |
oceanprotocol/squid-py | squid_py/ddo/metadata.py | Metadata.get_example | def get_example():
"""Retrieve an example of the metadata"""
example = dict()
for section_key, section in Metadata.MAIN_SECTIONS.items():
example[section_key] = section.EXAMPLE.copy()
return example | python | def get_example():
"""Retrieve an example of the metadata"""
example = dict()
for section_key, section in Metadata.MAIN_SECTIONS.items():
example[section_key] = section.EXAMPLE.copy()
return example | [
"def",
"get_example",
"(",
")",
":",
"example",
"=",
"dict",
"(",
")",
"for",
"section_key",
",",
"section",
"in",
"Metadata",
".",
"MAIN_SECTIONS",
".",
"items",
"(",
")",
":",
"example",
"[",
"section_key",
"]",
"=",
"section",
".",
"EXAMPLE",
".",
"... | Retrieve an example of the metadata | [
"Retrieve",
"an",
"example",
"of",
"the",
"metadata"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/metadata.py#L148-L154 | train |
oceanprotocol/squid-py | squid_py/secret_store/secret_store.py | SecretStore.encrypt_document | def encrypt_document(self, document_id, content, threshold=0):
"""
encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document... | python | def encrypt_document(self, document_id, content, threshold=0):
"""
encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document... | [
"def",
"encrypt_document",
"(",
"self",
",",
"document_id",
",",
"content",
",",
"threshold",
"=",
"0",
")",
":",
"return",
"self",
".",
"_secret_store_client",
"(",
"self",
".",
"_account",
")",
".",
"publish_document",
"(",
"remove_0x_prefix",
"(",
"document... | encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document to use for encryption session
:param content: str to be encrypted
... | [
"encrypt",
"string",
"data",
"using",
"the",
"DID",
"as",
"an",
"secret",
"store",
"id",
"if",
"secret",
"store",
"is",
"enabled",
"then",
"return",
"the",
"result",
"from",
"secret",
"store",
"encryption"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/secret_store/secret_store.py#L50-L66 | train |
oceanprotocol/squid-py | squid_py/assets/asset_consumer.py | AssetConsumer.download | def download(service_agreement_id, service_definition_id, ddo, consumer_account, destination,
brizo, secret_store, index=None):
"""
Download asset data files or result files from a compute job.
:param service_agreement_id: Service agreement id, str
:param service_defini... | python | def download(service_agreement_id, service_definition_id, ddo, consumer_account, destination,
brizo, secret_store, index=None):
"""
Download asset data files or result files from a compute job.
:param service_agreement_id: Service agreement id, str
:param service_defini... | [
"def",
"download",
"(",
"service_agreement_id",
",",
"service_definition_id",
",",
"ddo",
",",
"consumer_account",
",",
"destination",
",",
"brizo",
",",
"secret_store",
",",
"index",
"=",
"None",
")",
":",
"did",
"=",
"ddo",
".",
"did",
"encrypted_files",
"="... | Download asset data files or result files from a compute job.
:param service_agreement_id: Service agreement id, str
:param service_definition_id: identifier of the service inside the asset DDO, str
:param ddo: DDO
:param consumer_account: Account instance of the consumer
:param... | [
"Download",
"asset",
"data",
"files",
"or",
"result",
"files",
"from",
"a",
"compute",
"job",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/assets/asset_consumer.py#L20-L85 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_base.py | PublicKeyBase.set_key_value | def set_key_value(self, value, store_type=PUBLIC_KEY_STORE_TYPE_BASE64):
"""Set the key value based on it's storage type."""
if isinstance(value, dict):
if PUBLIC_KEY_STORE_TYPE_HEX in value:
self.set_key_value(value[PUBLIC_KEY_STORE_TYPE_HEX], PUBLIC_KEY_STORE_TYPE_HEX)
... | python | def set_key_value(self, value, store_type=PUBLIC_KEY_STORE_TYPE_BASE64):
"""Set the key value based on it's storage type."""
if isinstance(value, dict):
if PUBLIC_KEY_STORE_TYPE_HEX in value:
self.set_key_value(value[PUBLIC_KEY_STORE_TYPE_HEX], PUBLIC_KEY_STORE_TYPE_HEX)
... | [
"def",
"set_key_value",
"(",
"self",
",",
"value",
",",
"store_type",
"=",
"PUBLIC_KEY_STORE_TYPE_BASE64",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"if",
"PUBLIC_KEY_STORE_TYPE_HEX",
"in",
"value",
":",
"self",
".",
"set_key_value",
"... | Set the key value based on it's storage type. | [
"Set",
"the",
"key",
"value",
"based",
"on",
"it",
"s",
"storage",
"type",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_base.py#L61-L78 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_base.py | PublicKeyBase.set_encode_key_value | def set_encode_key_value(self, value, store_type):
"""Save the key value base on it's storage type."""
self._store_type = store_type
if store_type == PUBLIC_KEY_STORE_TYPE_HEX:
self._value = value.hex()
elif store_type == PUBLIC_KEY_STORE_TYPE_BASE64:
self._value ... | python | def set_encode_key_value(self, value, store_type):
"""Save the key value base on it's storage type."""
self._store_type = store_type
if store_type == PUBLIC_KEY_STORE_TYPE_HEX:
self._value = value.hex()
elif store_type == PUBLIC_KEY_STORE_TYPE_BASE64:
self._value ... | [
"def",
"set_encode_key_value",
"(",
"self",
",",
"value",
",",
"store_type",
")",
":",
"self",
".",
"_store_type",
"=",
"store_type",
"if",
"store_type",
"==",
"PUBLIC_KEY_STORE_TYPE_HEX",
":",
"self",
".",
"_value",
"=",
"value",
".",
"hex",
"(",
")",
"elif... | Save the key value base on it's storage type. | [
"Save",
"the",
"key",
"value",
"base",
"on",
"it",
"s",
"storage",
"type",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_base.py#L80-L94 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_base.py | PublicKeyBase.get_decode_value | def get_decode_value(self):
"""Return the key value based on it's storage type."""
if self._store_type == PUBLIC_KEY_STORE_TYPE_HEX:
value = bytes.fromhex(self._value)
elif self._store_type == PUBLIC_KEY_STORE_TYPE_BASE64:
value = b64decode(self._value)
elif self.... | python | def get_decode_value(self):
"""Return the key value based on it's storage type."""
if self._store_type == PUBLIC_KEY_STORE_TYPE_HEX:
value = bytes.fromhex(self._value)
elif self._store_type == PUBLIC_KEY_STORE_TYPE_BASE64:
value = b64decode(self._value)
elif self.... | [
"def",
"get_decode_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_store_type",
"==",
"PUBLIC_KEY_STORE_TYPE_HEX",
":",
"value",
"=",
"bytes",
".",
"fromhex",
"(",
"self",
".",
"_value",
")",
"elif",
"self",
".",
"_store_type",
"==",
"PUBLIC_KEY_STORE_TYPE... | Return the key value based on it's storage type. | [
"Return",
"the",
"key",
"value",
"based",
"on",
"it",
"s",
"storage",
"type",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_base.py#L96-L109 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_base.py | PublicKeyBase.as_text | def as_text(self, is_pretty=False):
"""Return the key as JSON text."""
values = {'id': self._id, 'type': self._type}
if self._owner:
values['owner'] = self._owner
if is_pretty:
return json.dumps(values, indent=4, separators=(',', ': '))
return json.dumps... | python | def as_text(self, is_pretty=False):
"""Return the key as JSON text."""
values = {'id': self._id, 'type': self._type}
if self._owner:
values['owner'] = self._owner
if is_pretty:
return json.dumps(values, indent=4, separators=(',', ': '))
return json.dumps... | [
"def",
"as_text",
"(",
"self",
",",
"is_pretty",
"=",
"False",
")",
":",
"values",
"=",
"{",
"'id'",
":",
"self",
".",
"_id",
",",
"'type'",
":",
"self",
".",
"_type",
"}",
"if",
"self",
".",
"_owner",
":",
"values",
"[",
"'owner'",
"]",
"=",
"se... | Return the key as JSON text. | [
"Return",
"the",
"key",
"as",
"JSON",
"text",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_base.py#L115-L124 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_base.py | PublicKeyBase.as_dictionary | def as_dictionary(self):
"""Return the key as a python dictionary."""
values = {
'id': self._id,
'type': self._type
}
if self._owner:
values['owner'] = self._owner
return values | python | def as_dictionary(self):
"""Return the key as a python dictionary."""
values = {
'id': self._id,
'type': self._type
}
if self._owner:
values['owner'] = self._owner
return values | [
"def",
"as_dictionary",
"(",
"self",
")",
":",
"values",
"=",
"{",
"'id'",
":",
"self",
".",
"_id",
",",
"'type'",
":",
"self",
".",
"_type",
"}",
"if",
"self",
".",
"_owner",
":",
"values",
"[",
"'owner'",
"]",
"=",
"self",
".",
"_owner",
"return"... | Return the key as a python dictionary. | [
"Return",
"the",
"key",
"as",
"a",
"python",
"dictionary",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_base.py#L126-L135 | train |
oceanprotocol/squid-py | squid_py/keeper/agreements/agreement_manager.py | AgreementStoreManager.get_agreement | def get_agreement(self, agreement_id):
"""
Retrieve the agreement for a agreement_id.
:param agreement_id: id of the agreement, hex str
:return: the agreement attributes.
"""
agreement = self.contract_concise.getAgreement(agreement_id)
if agreement and len(agreem... | python | def get_agreement(self, agreement_id):
"""
Retrieve the agreement for a agreement_id.
:param agreement_id: id of the agreement, hex str
:return: the agreement attributes.
"""
agreement = self.contract_concise.getAgreement(agreement_id)
if agreement and len(agreem... | [
"def",
"get_agreement",
"(",
"self",
",",
"agreement_id",
")",
":",
"agreement",
"=",
"self",
".",
"contract_concise",
".",
"getAgreement",
"(",
"agreement_id",
")",
"if",
"agreement",
"and",
"len",
"(",
"agreement",
")",
"==",
"6",
":",
"agreement",
"=",
... | Retrieve the agreement for a agreement_id.
:param agreement_id: id of the agreement, hex str
:return: the agreement attributes. | [
"Retrieve",
"the",
"agreement",
"for",
"a",
"agreement_id",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/agreements/agreement_manager.py#L48-L70 | train |
oceanprotocol/squid-py | squid_py/keeper/contract_handler.py | ContractHandler._load | def _load(contract_name):
"""Retrieve the contract instance for `contract_name` that represent the smart
contract in the keeper network.
:param contract_name: str name of the solidity keeper contract without the network name.
:return: web3.eth.Contract instance
"""
contr... | python | def _load(contract_name):
"""Retrieve the contract instance for `contract_name` that represent the smart
contract in the keeper network.
:param contract_name: str name of the solidity keeper contract without the network name.
:return: web3.eth.Contract instance
"""
contr... | [
"def",
"_load",
"(",
"contract_name",
")",
":",
"contract_definition",
"=",
"ContractHandler",
".",
"get_contract_dict_by_name",
"(",
"contract_name",
")",
"address",
"=",
"Web3Provider",
".",
"get_web3",
"(",
")",
".",
"toChecksumAddress",
"(",
"contract_definition",... | Retrieve the contract instance for `contract_name` that represent the smart
contract in the keeper network.
:param contract_name: str name of the solidity keeper contract without the network name.
:return: web3.eth.Contract instance | [
"Retrieve",
"the",
"contract",
"instance",
"for",
"contract_name",
"that",
"represent",
"the",
"smart",
"contract",
"in",
"the",
"keeper",
"network",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/contract_handler.py#L70-L82 | train |
oceanprotocol/squid-py | squid_py/keeper/contract_handler.py | ContractHandler.get_contract_dict_by_name | def get_contract_dict_by_name(contract_name):
"""
Retrieve the Contract instance for a given contract name.
:param contract_name: str
:return: the smart contract's definition from the json abi file, dict
"""
network_name = Keeper.get_network_name(Keeper.get_network_id()... | python | def get_contract_dict_by_name(contract_name):
"""
Retrieve the Contract instance for a given contract name.
:param contract_name: str
:return: the smart contract's definition from the json abi file, dict
"""
network_name = Keeper.get_network_name(Keeper.get_network_id()... | [
"def",
"get_contract_dict_by_name",
"(",
"contract_name",
")",
":",
"network_name",
"=",
"Keeper",
".",
"get_network_name",
"(",
"Keeper",
".",
"get_network_id",
"(",
")",
")",
".",
"lower",
"(",
")",
"artifacts_path",
"=",
"ConfigProvider",
".",
"get_config",
"... | Retrieve the Contract instance for a given contract name.
:param contract_name: str
:return: the smart contract's definition from the json abi file, dict | [
"Retrieve",
"the",
"Contract",
"instance",
"for",
"a",
"given",
"contract",
"name",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/contract_handler.py#L94-L126 | train |
oceanprotocol/squid-py | examples/buy_asset.py | buy_asset | def buy_asset():
"""
Requires all ocean services running.
"""
ConfigProvider.set_config(ExampleConfig.get_config())
config = ConfigProvider.get_config()
# make ocean instance
ocn = Ocean()
acc = get_publisher_account(config)
if not acc:
acc = ([acc for acc in ocn.accounts.l... | python | def buy_asset():
"""
Requires all ocean services running.
"""
ConfigProvider.set_config(ExampleConfig.get_config())
config = ConfigProvider.get_config()
# make ocean instance
ocn = Ocean()
acc = get_publisher_account(config)
if not acc:
acc = ([acc for acc in ocn.accounts.l... | [
"def",
"buy_asset",
"(",
")",
":",
"ConfigProvider",
".",
"set_config",
"(",
"ExampleConfig",
".",
"get_config",
"(",
")",
")",
"config",
"=",
"ConfigProvider",
".",
"get_config",
"(",
")",
"ocn",
"=",
"Ocean",
"(",
")",
"acc",
"=",
"get_publisher_account",
... | Requires all ocean services running. | [
"Requires",
"all",
"ocean",
"services",
"running",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/examples/buy_asset.py#L29-L83 | train |
oceanprotocol/squid-py | squid_py/keeper/token.py | Token.token_approve | def token_approve(self, spender_address, price, from_account):
"""
Approve the passed address to spend the specified amount of tokens.
:param spender_address: Account address, str
:param price: Asset price, int
:param from_account: Account address, str
:return: bool
... | python | def token_approve(self, spender_address, price, from_account):
"""
Approve the passed address to spend the specified amount of tokens.
:param spender_address: Account address, str
:param price: Asset price, int
:param from_account: Account address, str
:return: bool
... | [
"def",
"token_approve",
"(",
"self",
",",
"spender_address",
",",
"price",
",",
"from_account",
")",
":",
"if",
"not",
"Web3Provider",
".",
"get_web3",
"(",
")",
".",
"isChecksumAddress",
"(",
"spender_address",
")",
":",
"spender_address",
"=",
"Web3Provider",
... | Approve the passed address to spend the specified amount of tokens.
:param spender_address: Account address, str
:param price: Asset price, int
:param from_account: Account address, str
:return: bool | [
"Approve",
"the",
"passed",
"address",
"to",
"spend",
"the",
"specified",
"amount",
"of",
"tokens",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/token.py#L31-L50 | train |
oceanprotocol/squid-py | squid_py/keeper/token.py | Token.transfer | def transfer(self, receiver_address, amount, from_account):
"""
Transfer tokens from one account to the receiver address.
:param receiver_address: Address of the transfer receiver, str
:param amount: Amount of tokens, int
:param from_account: Sender account, Account
:ret... | python | def transfer(self, receiver_address, amount, from_account):
"""
Transfer tokens from one account to the receiver address.
:param receiver_address: Address of the transfer receiver, str
:param amount: Amount of tokens, int
:param from_account: Sender account, Account
:ret... | [
"def",
"transfer",
"(",
"self",
",",
"receiver_address",
",",
"amount",
",",
"from_account",
")",
":",
"tx_hash",
"=",
"self",
".",
"send_transaction",
"(",
"'transfer'",
",",
"(",
"receiver_address",
",",
"amount",
")",
",",
"transact",
"=",
"{",
"'from'",
... | Transfer tokens from one account to the receiver address.
:param receiver_address: Address of the transfer receiver, str
:param amount: Amount of tokens, int
:param from_account: Sender account, Account
:return: bool | [
"Transfer",
"tokens",
"from",
"one",
"account",
"to",
"the",
"receiver",
"address",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/token.py#L52-L68 | train |
oceanprotocol/squid-py | squid_py/agreements/events/access_secret_store_condition.py | fulfill_access_secret_store_condition | def fulfill_access_secret_store_condition(event, agreement_id, did, service_agreement,
consumer_address, publisher_account):
"""
Fulfill the access condition.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
... | python | def fulfill_access_secret_store_condition(event, agreement_id, did, service_agreement,
consumer_address, publisher_account):
"""
Fulfill the access condition.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
... | [
"def",
"fulfill_access_secret_store_condition",
"(",
"event",
",",
"agreement_id",
",",
"did",
",",
"service_agreement",
",",
"consumer_address",
",",
"publisher_account",
")",
":",
"logger",
".",
"debug",
"(",
"f\"release reward after event {event}.\"",
")",
"name_to_par... | Fulfill the access condition.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param service_agreement: ServiceAgreement instance
:param consumer_address: ethereum account address of consumer, hex str
:param publisher_accou... | [
"Fulfill",
"the",
"access",
"condition",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/events/access_secret_store_condition.py#L16-L45 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_assets.py | OceanAssets.retire | def retire(self, did):
"""
Retire this did of Aquarius
:param did: DID, str
:return: bool
"""
try:
ddo = self.resolve(did)
metadata_service = ddo.find_service_by_type(ServiceTypes.METADATA)
self._get_aquarius(metadata_service.endpoints... | python | def retire(self, did):
"""
Retire this did of Aquarius
:param did: DID, str
:return: bool
"""
try:
ddo = self.resolve(did)
metadata_service = ddo.find_service_by_type(ServiceTypes.METADATA)
self._get_aquarius(metadata_service.endpoints... | [
"def",
"retire",
"(",
"self",
",",
"did",
")",
":",
"try",
":",
"ddo",
"=",
"self",
".",
"resolve",
"(",
"did",
")",
"metadata_service",
"=",
"ddo",
".",
"find_service_by_type",
"(",
"ServiceTypes",
".",
"METADATA",
")",
"self",
".",
"_get_aquarius",
"("... | Retire this did of Aquarius
:param did: DID, str
:return: bool | [
"Retire",
"this",
"did",
"of",
"Aquarius"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L197-L211 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_assets.py | OceanAssets.search | def search(self, text, sort=None, offset=100, page=1, aquarius_url=None):
"""
Search an asset in oceanDB using aquarius.
:param text: String with the value that you are searching
:param sort: Dictionary to choose order base in some value
:param offset: Number of elements shows b... | python | def search(self, text, sort=None, offset=100, page=1, aquarius_url=None):
"""
Search an asset in oceanDB using aquarius.
:param text: String with the value that you are searching
:param sort: Dictionary to choose order base in some value
:param offset: Number of elements shows b... | [
"def",
"search",
"(",
"self",
",",
"text",
",",
"sort",
"=",
"None",
",",
"offset",
"=",
"100",
",",
"page",
"=",
"1",
",",
"aquarius_url",
"=",
"None",
")",
":",
"assert",
"page",
">=",
"1",
",",
"f'Invalid page value {page}. Required page >= 1.'",
"logge... | Search an asset in oceanDB using aquarius.
:param text: String with the value that you are searching
:param sort: Dictionary to choose order base in some value
:param offset: Number of elements shows by page
:param page: Page number
:param aquarius_url: Url of the aquarius where... | [
"Search",
"an",
"asset",
"in",
"oceanDB",
"using",
"aquarius",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L222-L237 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_assets.py | OceanAssets.query | def query(self, query, sort=None, offset=100, page=1, aquarius_url=None):
"""
Search an asset in oceanDB using search query.
:param query: dict with query parameters
(e.g.) https://github.com/oceanprotocol/aquarius/blob/develop/docs/for_api_users/API.md
:param sort: Dictiona... | python | def query(self, query, sort=None, offset=100, page=1, aquarius_url=None):
"""
Search an asset in oceanDB using search query.
:param query: dict with query parameters
(e.g.) https://github.com/oceanprotocol/aquarius/blob/develop/docs/for_api_users/API.md
:param sort: Dictiona... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"sort",
"=",
"None",
",",
"offset",
"=",
"100",
",",
"page",
"=",
"1",
",",
"aquarius_url",
"=",
"None",
")",
":",
"logger",
".",
"info",
"(",
"f'Searching asset query: {query}'",
")",
"aquarius",
"=",
"s... | Search an asset in oceanDB using search query.
:param query: dict with query parameters
(e.g.) https://github.com/oceanprotocol/aquarius/blob/develop/docs/for_api_users/API.md
:param sort: Dictionary to choose order base in some value
:param offset: Number of elements shows by page
... | [
"Search",
"an",
"asset",
"in",
"oceanDB",
"using",
"search",
"query",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L239-L255 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_assets.py | OceanAssets.order | def order(self, did, service_definition_id, consumer_account, auto_consume=False):
"""
Sign service agreement.
Sign the service agreement defined in the service section identified
by `service_definition_id` in the ddo and send the signed agreement to the purchase endpoint
associ... | python | def order(self, did, service_definition_id, consumer_account, auto_consume=False):
"""
Sign service agreement.
Sign the service agreement defined in the service section identified
by `service_definition_id` in the ddo and send the signed agreement to the purchase endpoint
associ... | [
"def",
"order",
"(",
"self",
",",
"did",
",",
"service_definition_id",
",",
"consumer_account",
",",
"auto_consume",
"=",
"False",
")",
":",
"assert",
"consumer_account",
".",
"address",
"in",
"self",
".",
"_keeper",
".",
"accounts",
",",
"f'Unrecognized consume... | Sign service agreement.
Sign the service agreement defined in the service section identified
by `service_definition_id` in the ddo and send the signed agreement to the purchase endpoint
associated with this service.
:param did: str starting with the prefix `did:op:` and followed by the... | [
"Sign",
"service",
"agreement",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L257-L289 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_assets.py | OceanAssets.consume | def consume(self, service_agreement_id, did, service_definition_id, consumer_account,
destination, index=None):
"""
Consume the asset data.
Using the service endpoint defined in the ddo's service pointed to by service_definition_id.
Consumer's permissions is checked impl... | python | def consume(self, service_agreement_id, did, service_definition_id, consumer_account,
destination, index=None):
"""
Consume the asset data.
Using the service endpoint defined in the ddo's service pointed to by service_definition_id.
Consumer's permissions is checked impl... | [
"def",
"consume",
"(",
"self",
",",
"service_agreement_id",
",",
"did",
",",
"service_definition_id",
",",
"consumer_account",
",",
"destination",
",",
"index",
"=",
"None",
")",
":",
"ddo",
"=",
"self",
".",
"resolve",
"(",
"did",
")",
"if",
"index",
"is"... | Consume the asset data.
Using the service endpoint defined in the ddo's service pointed to by service_definition_id.
Consumer's permissions is checked implicitly by the secret-store during decryption
of the contentUrls.
The service endpoint is expected to also verify the consumer's perm... | [
"Consume",
"the",
"asset",
"data",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L291-L324 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_templates.py | OceanTemplates.propose | def propose(self, template_address, account):
"""
Propose a new template.
:param template_address: Address of the template contract, str
:param account: account proposing the template, Account
:return: bool
"""
try:
proposed = self._keeper.template_ma... | python | def propose(self, template_address, account):
"""
Propose a new template.
:param template_address: Address of the template contract, str
:param account: account proposing the template, Account
:return: bool
"""
try:
proposed = self._keeper.template_ma... | [
"def",
"propose",
"(",
"self",
",",
"template_address",
",",
"account",
")",
":",
"try",
":",
"proposed",
"=",
"self",
".",
"_keeper",
".",
"template_manager",
".",
"propose_template",
"(",
"template_address",
",",
"account",
")",
"return",
"proposed",
"except... | Propose a new template.
:param template_address: Address of the template contract, str
:param account: account proposing the template, Account
:return: bool | [
"Propose",
"a",
"new",
"template",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_templates.py#L18-L40 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_templates.py | OceanTemplates.approve | def approve(self, template_address, account):
"""
Approve a template already proposed. The account needs to be owner of the templateManager
contract to be able of approve the template.
:param template_address: Address of the template contract, str
:param account: account approvi... | python | def approve(self, template_address, account):
"""
Approve a template already proposed. The account needs to be owner of the templateManager
contract to be able of approve the template.
:param template_address: Address of the template contract, str
:param account: account approvi... | [
"def",
"approve",
"(",
"self",
",",
"template_address",
",",
"account",
")",
":",
"try",
":",
"approved",
"=",
"self",
".",
"_keeper",
".",
"template_manager",
".",
"approve_template",
"(",
"template_address",
",",
"account",
")",
"return",
"approved",
"except... | Approve a template already proposed. The account needs to be owner of the templateManager
contract to be able of approve the template.
:param template_address: Address of the template contract, str
:param account: account approving the template, Account
:return: bool | [
"Approve",
"a",
"template",
"already",
"proposed",
".",
"The",
"account",
"needs",
"to",
"be",
"owner",
"of",
"the",
"templateManager",
"contract",
"to",
"be",
"able",
"of",
"approve",
"the",
"template",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_templates.py#L42-L73 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_templates.py | OceanTemplates.revoke | def revoke(self, template_address, account):
"""
Revoke a template already approved. The account needs to be owner of the templateManager
contract to be able of revoke the template.
:param template_address: Address of the template contract, str
:param account: account revoking t... | python | def revoke(self, template_address, account):
"""
Revoke a template already approved. The account needs to be owner of the templateManager
contract to be able of revoke the template.
:param template_address: Address of the template contract, str
:param account: account revoking t... | [
"def",
"revoke",
"(",
"self",
",",
"template_address",
",",
"account",
")",
":",
"try",
":",
"revoked",
"=",
"self",
".",
"_keeper",
".",
"template_manager",
".",
"revoke_template",
"(",
"template_address",
",",
"account",
")",
"return",
"revoked",
"except",
... | Revoke a template already approved. The account needs to be owner of the templateManager
contract to be able of revoke the template.
:param template_address: Address of the template contract, str
:param account: account revoking the template, Account
:return: bool | [
"Revoke",
"a",
"template",
"already",
"approved",
".",
"The",
"account",
"needs",
"to",
"be",
"owner",
"of",
"the",
"templateManager",
"contract",
"to",
"be",
"able",
"of",
"revoke",
"the",
"template",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_templates.py#L75-L94 | train |
oceanprotocol/squid-py | squid_py/agreements/service_agreement.py | ServiceAgreement.get_price | def get_price(self):
"""
Return the price from the conditions parameters.
:return: Int
"""
for cond in self.conditions:
for p in cond.parameters:
if p.name == '_amount':
return p.value | python | def get_price(self):
"""
Return the price from the conditions parameters.
:return: Int
"""
for cond in self.conditions:
for p in cond.parameters:
if p.name == '_amount':
return p.value | [
"def",
"get_price",
"(",
"self",
")",
":",
"for",
"cond",
"in",
"self",
".",
"conditions",
":",
"for",
"p",
"in",
"cond",
".",
"parameters",
":",
"if",
"p",
".",
"name",
"==",
"'_amount'",
":",
"return",
"p",
".",
"value"
] | Return the price from the conditions parameters.
:return: Int | [
"Return",
"the",
"price",
"from",
"the",
"conditions",
"parameters",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement.py#L47-L56 | train |
oceanprotocol/squid-py | squid_py/agreements/service_agreement.py | ServiceAgreement.get_service_agreement_hash | def get_service_agreement_hash(
self, agreement_id, asset_id, consumer_address, publisher_address, keeper):
"""Return the hash of the service agreement values to be signed by a consumer.
:param agreement_id:id of the agreement, hex str
:param asset_id:
:param consumer_addres... | python | def get_service_agreement_hash(
self, agreement_id, asset_id, consumer_address, publisher_address, keeper):
"""Return the hash of the service agreement values to be signed by a consumer.
:param agreement_id:id of the agreement, hex str
:param asset_id:
:param consumer_addres... | [
"def",
"get_service_agreement_hash",
"(",
"self",
",",
"agreement_id",
",",
"asset_id",
",",
"consumer_address",
",",
"publisher_address",
",",
"keeper",
")",
":",
"agreement_hash",
"=",
"ServiceAgreement",
".",
"generate_service_agreement_hash",
"(",
"self",
".",
"te... | Return the hash of the service agreement values to be signed by a consumer.
:param agreement_id:id of the agreement, hex str
:param asset_id:
:param consumer_address: ethereum account address of consumer, hex str
:param publisher_address: ethereum account address of publisher, hex str
... | [
"Return",
"the",
"hash",
"of",
"the",
"service",
"agreement",
"values",
"to",
"be",
"signed",
"by",
"a",
"consumer",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement.py#L226-L245 | train |
oceanprotocol/squid-py | squid_py/config.py | Config.keeper_path | def keeper_path(self):
"""Path where the keeper-contracts artifacts are allocated."""
keeper_path_string = self.get(self._section_name, NAME_KEEPER_PATH)
path = Path(keeper_path_string).expanduser().resolve()
# TODO: Handle the default case and make default empty string
# assert ... | python | def keeper_path(self):
"""Path where the keeper-contracts artifacts are allocated."""
keeper_path_string = self.get(self._section_name, NAME_KEEPER_PATH)
path = Path(keeper_path_string).expanduser().resolve()
# TODO: Handle the default case and make default empty string
# assert ... | [
"def",
"keeper_path",
"(",
"self",
")",
":",
"keeper_path_string",
"=",
"self",
".",
"get",
"(",
"self",
".",
"_section_name",
",",
"NAME_KEEPER_PATH",
")",
"path",
"=",
"Path",
"(",
"keeper_path_string",
")",
".",
"expanduser",
"(",
")",
".",
"resolve",
"... | Path where the keeper-contracts artifacts are allocated. | [
"Path",
"where",
"the",
"keeper",
"-",
"contracts",
"artifacts",
"are",
"allocated",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/config.py#L116-L129 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.add_public_key | def add_public_key(self, did, public_key):
"""
Add a public key object to the list of public keys.
:param public_key: Public key, PublicKeyHex
"""
logger.debug(f'Adding public key {public_key} to the did {did}')
self._public_keys.append(
PublicKeyBase(did, **... | python | def add_public_key(self, did, public_key):
"""
Add a public key object to the list of public keys.
:param public_key: Public key, PublicKeyHex
"""
logger.debug(f'Adding public key {public_key} to the did {did}')
self._public_keys.append(
PublicKeyBase(did, **... | [
"def",
"add_public_key",
"(",
"self",
",",
"did",
",",
"public_key",
")",
":",
"logger",
".",
"debug",
"(",
"f'Adding public key {public_key} to the did {did}'",
")",
"self",
".",
"_public_keys",
".",
"append",
"(",
"PublicKeyBase",
"(",
"did",
",",
"**",
"{",
... | Add a public key object to the list of public keys.
:param public_key: Public key, PublicKeyHex | [
"Add",
"a",
"public",
"key",
"object",
"to",
"the",
"list",
"of",
"public",
"keys",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L79-L87 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.add_authentication | def add_authentication(self, public_key, authentication_type=None):
"""
Add a authentication public key id and type to the list of authentications.
:param key_id: Key id, Authentication
:param authentication_type: Authentication type, str
"""
authentication = {}
... | python | def add_authentication(self, public_key, authentication_type=None):
"""
Add a authentication public key id and type to the list of authentications.
:param key_id: Key id, Authentication
:param authentication_type: Authentication type, str
"""
authentication = {}
... | [
"def",
"add_authentication",
"(",
"self",
",",
"public_key",
",",
"authentication_type",
"=",
"None",
")",
":",
"authentication",
"=",
"{",
"}",
"if",
"public_key",
":",
"authentication",
"=",
"{",
"'type'",
":",
"authentication_type",
",",
"'publicKey'",
":",
... | Add a authentication public key id and type to the list of authentications.
:param key_id: Key id, Authentication
:param authentication_type: Authentication type, str | [
"Add",
"a",
"authentication",
"public",
"key",
"id",
"and",
"type",
"to",
"the",
"list",
"of",
"authentications",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L89-L100 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.add_service | def add_service(self, service_type, service_endpoint=None, values=None):
"""
Add a service to the list of services on the DDO.
:param service_type: Service
:param service_endpoint: Service endpoint, str
:param values: Python dict with serviceDefinitionId, templateId, serviceAgre... | python | def add_service(self, service_type, service_endpoint=None, values=None):
"""
Add a service to the list of services on the DDO.
:param service_type: Service
:param service_endpoint: Service endpoint, str
:param values: Python dict with serviceDefinitionId, templateId, serviceAgre... | [
"def",
"add_service",
"(",
"self",
",",
"service_type",
",",
"service_endpoint",
"=",
"None",
",",
"values",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"service_type",
",",
"Service",
")",
":",
"service",
"=",
"service_type",
"else",
":",
"service",
"... | Add a service to the list of services on the DDO.
:param service_type: Service
:param service_endpoint: Service endpoint, str
:param values: Python dict with serviceDefinitionId, templateId, serviceAgreementContract,
list of conditions and consume endpoint. | [
"Add",
"a",
"service",
"to",
"the",
"list",
"of",
"services",
"on",
"the",
"DDO",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L102-L116 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.as_text | def as_text(self, is_proof=True, is_pretty=False):
"""Return the DDO as a JSON text.
:param if is_proof: if False then do not include the 'proof' element.
:param is_pretty: If True return dictionary in a prettier way, bool
:return: str
"""
data = self.as_dictionary(is_pr... | python | def as_text(self, is_proof=True, is_pretty=False):
"""Return the DDO as a JSON text.
:param if is_proof: if False then do not include the 'proof' element.
:param is_pretty: If True return dictionary in a prettier way, bool
:return: str
"""
data = self.as_dictionary(is_pr... | [
"def",
"as_text",
"(",
"self",
",",
"is_proof",
"=",
"True",
",",
"is_pretty",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"as_dictionary",
"(",
"is_proof",
")",
"if",
"is_pretty",
":",
"return",
"json",
".",
"dumps",
"(",
"data",
",",
"indent",
... | Return the DDO as a JSON text.
:param if is_proof: if False then do not include the 'proof' element.
:param is_pretty: If True return dictionary in a prettier way, bool
:return: str | [
"Return",
"the",
"DDO",
"as",
"a",
"JSON",
"text",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L118-L129 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.as_dictionary | def as_dictionary(self, is_proof=True):
"""
Return the DDO as a JSON dict.
:param if is_proof: if False then do not include the 'proof' element.
:return: dict
"""
if self._created is None:
self._created = DDO._get_timestamp()
data = {
'@c... | python | def as_dictionary(self, is_proof=True):
"""
Return the DDO as a JSON dict.
:param if is_proof: if False then do not include the 'proof' element.
:return: dict
"""
if self._created is None:
self._created = DDO._get_timestamp()
data = {
'@c... | [
"def",
"as_dictionary",
"(",
"self",
",",
"is_proof",
"=",
"True",
")",
":",
"if",
"self",
".",
"_created",
"is",
"None",
":",
"self",
".",
"_created",
"=",
"DDO",
".",
"_get_timestamp",
"(",
")",
"data",
"=",
"{",
"'@context'",
":",
"DID_DDO_CONTEXT_URL... | Return the DDO as a JSON dict.
:param if is_proof: if False then do not include the 'proof' element.
:return: dict | [
"Return",
"the",
"DDO",
"as",
"a",
"JSON",
"dict",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L131-L164 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO._read_dict | def _read_dict(self, dictionary):
"""Import a JSON dict into this DDO."""
values = dictionary
self._did = values['id']
self._created = values.get('created', None)
if 'publicKey' in values:
self._public_keys = []
for value in values['publicKey']:
... | python | def _read_dict(self, dictionary):
"""Import a JSON dict into this DDO."""
values = dictionary
self._did = values['id']
self._created = values.get('created', None)
if 'publicKey' in values:
self._public_keys = []
for value in values['publicKey']:
... | [
"def",
"_read_dict",
"(",
"self",
",",
"dictionary",
")",
":",
"values",
"=",
"dictionary",
"self",
".",
"_did",
"=",
"values",
"[",
"'id'",
"]",
"self",
".",
"_created",
"=",
"values",
".",
"get",
"(",
"'created'",
",",
"None",
")",
"if",
"'publicKey'... | Import a JSON dict into this DDO. | [
"Import",
"a",
"JSON",
"dict",
"into",
"this",
"DDO",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L166-L192 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.get_public_key | def get_public_key(self, key_id, is_search_embedded=False):
"""Key_id can be a string, or int. If int then the index in the list of keys."""
if isinstance(key_id, int):
return self._public_keys[key_id]
for item in self._public_keys:
if item.get_id() == key_id:
... | python | def get_public_key(self, key_id, is_search_embedded=False):
"""Key_id can be a string, or int. If int then the index in the list of keys."""
if isinstance(key_id, int):
return self._public_keys[key_id]
for item in self._public_keys:
if item.get_id() == key_id:
... | [
"def",
"get_public_key",
"(",
"self",
",",
"key_id",
",",
"is_search_embedded",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"key_id",
",",
"int",
")",
":",
"return",
"self",
".",
"_public_keys",
"[",
"key_id",
"]",
"for",
"item",
"in",
"self",
".",
... | Key_id can be a string, or int. If int then the index in the list of keys. | [
"Key_id",
"can",
"be",
"a",
"string",
"or",
"int",
".",
"If",
"int",
"then",
"the",
"index",
"in",
"the",
"list",
"of",
"keys",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L211-L224 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO._get_public_key_count | def _get_public_key_count(self):
"""Return the count of public keys in the list and embedded."""
index = len(self._public_keys)
for authentication in self._authentications:
if authentication.is_public_key():
index += 1
return index | python | def _get_public_key_count(self):
"""Return the count of public keys in the list and embedded."""
index = len(self._public_keys)
for authentication in self._authentications:
if authentication.is_public_key():
index += 1
return index | [
"def",
"_get_public_key_count",
"(",
"self",
")",
":",
"index",
"=",
"len",
"(",
"self",
".",
"_public_keys",
")",
"for",
"authentication",
"in",
"self",
".",
"_authentications",
":",
"if",
"authentication",
".",
"is_public_key",
"(",
")",
":",
"index",
"+="... | Return the count of public keys in the list and embedded. | [
"Return",
"the",
"count",
"of",
"public",
"keys",
"in",
"the",
"list",
"and",
"embedded",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L226-L232 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO._get_authentication_from_public_key_id | def _get_authentication_from_public_key_id(self, key_id):
"""Return the authentication based on it's id."""
for authentication in self._authentications:
if authentication.is_key_id(key_id):
return authentication
return None | python | def _get_authentication_from_public_key_id(self, key_id):
"""Return the authentication based on it's id."""
for authentication in self._authentications:
if authentication.is_key_id(key_id):
return authentication
return None | [
"def",
"_get_authentication_from_public_key_id",
"(",
"self",
",",
"key_id",
")",
":",
"for",
"authentication",
"in",
"self",
".",
"_authentications",
":",
"if",
"authentication",
".",
"is_key_id",
"(",
"key_id",
")",
":",
"return",
"authentication",
"return",
"No... | Return the authentication based on it's id. | [
"Return",
"the",
"authentication",
"based",
"on",
"it",
"s",
"id",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L234-L239 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.get_service | def get_service(self, service_type=None):
"""Return a service using."""
for service in self._services:
if service.type == service_type and service_type:
return service
return None | python | def get_service(self, service_type=None):
"""Return a service using."""
for service in self._services:
if service.type == service_type and service_type:
return service
return None | [
"def",
"get_service",
"(",
"self",
",",
"service_type",
"=",
"None",
")",
":",
"for",
"service",
"in",
"self",
".",
"_services",
":",
"if",
"service",
".",
"type",
"==",
"service_type",
"and",
"service_type",
":",
"return",
"service",
"return",
"None"
] | Return a service using. | [
"Return",
"a",
"service",
"using",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L241-L246 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.find_service_by_id | def find_service_by_id(self, service_id):
"""
Get service for a given service_id.
:param service_id: Service id, str
:return: Service
"""
service_id_key = 'serviceDefinitionId'
service_id = str(service_id)
for service in self._services:
if ser... | python | def find_service_by_id(self, service_id):
"""
Get service for a given service_id.
:param service_id: Service id, str
:return: Service
"""
service_id_key = 'serviceDefinitionId'
service_id = str(service_id)
for service in self._services:
if ser... | [
"def",
"find_service_by_id",
"(",
"self",
",",
"service_id",
")",
":",
"service_id_key",
"=",
"'serviceDefinitionId'",
"service_id",
"=",
"str",
"(",
"service_id",
")",
"for",
"service",
"in",
"self",
".",
"_services",
":",
"if",
"service_id_key",
"in",
"service... | Get service for a given service_id.
:param service_id: Service id, str
:return: Service | [
"Get",
"service",
"for",
"a",
"given",
"service_id",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L248-L270 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.find_service_by_type | def find_service_by_type(self, service_type):
"""
Get service for a given service type.
:param service_type: Service type, ServiceType
:return: Service
"""
for service in self._services:
if service_type == service.type:
return service
... | python | def find_service_by_type(self, service_type):
"""
Get service for a given service type.
:param service_type: Service type, ServiceType
:return: Service
"""
for service in self._services:
if service_type == service.type:
return service
... | [
"def",
"find_service_by_type",
"(",
"self",
",",
"service_type",
")",
":",
"for",
"service",
"in",
"self",
".",
"_services",
":",
"if",
"service_type",
"==",
"service",
".",
"type",
":",
"return",
"service",
"return",
"None"
] | Get service for a given service type.
:param service_type: Service type, ServiceType
:return: Service | [
"Get",
"service",
"for",
"a",
"given",
"service",
"type",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L272-L282 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.create_public_key_from_json | def create_public_key_from_json(values):
"""Create a public key object based on the values from the JSON record."""
# currently we only support RSA public keys
_id = values.get('id')
if not _id:
# Make it more forgiving for now.
_id = ''
# raise ValueE... | python | def create_public_key_from_json(values):
"""Create a public key object based on the values from the JSON record."""
# currently we only support RSA public keys
_id = values.get('id')
if not _id:
# Make it more forgiving for now.
_id = ''
# raise ValueE... | [
"def",
"create_public_key_from_json",
"(",
"values",
")",
":",
"_id",
"=",
"values",
".",
"get",
"(",
"'id'",
")",
"if",
"not",
"_id",
":",
"_id",
"=",
"''",
"if",
"values",
".",
"get",
"(",
"'type'",
")",
"==",
"PUBLIC_KEY_TYPE_RSA",
":",
"public_key",
... | Create a public key object based on the values from the JSON record. | [
"Create",
"a",
"public",
"key",
"object",
"based",
"on",
"the",
"values",
"from",
"the",
"JSON",
"record",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L295-L310 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.create_authentication_from_json | def create_authentication_from_json(values):
"""Create authentitaciton object from a JSON string."""
key_id = values.get('publicKey')
authentication_type = values.get('type')
if not key_id:
raise ValueError(
f'Invalid authentication definition, "publicKey" is ... | python | def create_authentication_from_json(values):
"""Create authentitaciton object from a JSON string."""
key_id = values.get('publicKey')
authentication_type = values.get('type')
if not key_id:
raise ValueError(
f'Invalid authentication definition, "publicKey" is ... | [
"def",
"create_authentication_from_json",
"(",
"values",
")",
":",
"key_id",
"=",
"values",
".",
"get",
"(",
"'publicKey'",
")",
"authentication_type",
"=",
"values",
".",
"get",
"(",
"'type'",
")",
"if",
"not",
"key_id",
":",
"raise",
"ValueError",
"(",
"f'... | Create authentitaciton object from a JSON string. | [
"Create",
"authentitaciton",
"object",
"from",
"a",
"JSON",
"string",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L313-L323 | train |
oceanprotocol/squid-py | squid_py/ddo/ddo.py | DDO.generate_checksum | def generate_checksum(did, metadata):
"""
Generation of the hash for integrity checksum.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: hex str
"""
files_checksum = ''
for file in metadata['base'... | python | def generate_checksum(did, metadata):
"""
Generation of the hash for integrity checksum.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: hex str
"""
files_checksum = ''
for file in metadata['base'... | [
"def",
"generate_checksum",
"(",
"did",
",",
"metadata",
")",
":",
"files_checksum",
"=",
"''",
"for",
"file",
"in",
"metadata",
"[",
"'base'",
"]",
"[",
"'files'",
"]",
":",
"if",
"'checksum'",
"in",
"file",
":",
"files_checksum",
"=",
"files_checksum",
"... | Generation of the hash for integrity checksum.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:return: hex str | [
"Generation",
"of",
"the",
"hash",
"for",
"integrity",
"checksum",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/ddo.py#L331-L347 | train |
oceanprotocol/squid-py | squid_py/keeper/didregistry.py | DIDRegistry.register | def register(self, did, checksum, url, account, providers=None):
"""
Register or update a DID on the block chain using the DIDRegistry smart contract.
:param did: DID to register/update, can be a 32 byte or hexstring
:param checksum: hex str hash of TODO
:param url: URL of the r... | python | def register(self, did, checksum, url, account, providers=None):
"""
Register or update a DID on the block chain using the DIDRegistry smart contract.
:param did: DID to register/update, can be a 32 byte or hexstring
:param checksum: hex str hash of TODO
:param url: URL of the r... | [
"def",
"register",
"(",
"self",
",",
"did",
",",
"checksum",
",",
"url",
",",
"account",
",",
"providers",
"=",
"None",
")",
":",
"did_source_id",
"=",
"did_to_id_bytes",
"(",
"did",
")",
"if",
"not",
"did_source_id",
":",
"raise",
"ValueError",
"(",
"f'... | Register or update a DID on the block chain using the DIDRegistry smart contract.
:param did: DID to register/update, can be a 32 byte or hexstring
:param checksum: hex str hash of TODO
:param url: URL of the resolved DID
:param account: instance of Account to use to register/update the... | [
"Register",
"or",
"update",
"a",
"DID",
"on",
"the",
"block",
"chain",
"using",
"the",
"DIDRegistry",
"smart",
"contract",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/didregistry.py#L29-L62 | train |
oceanprotocol/squid-py | squid_py/keeper/didregistry.py | DIDRegistry._register_attribute | def _register_attribute(self, did, checksum, value, account, providers):
"""Register an DID attribute as an event on the block chain.
:param did: 32 byte string/hex of the DID
:param checksum: checksum of the ddo, hex str
:param value: url for resolve the did, str
:param account... | python | def _register_attribute(self, did, checksum, value, account, providers):
"""Register an DID attribute as an event on the block chain.
:param did: 32 byte string/hex of the DID
:param checksum: checksum of the ddo, hex str
:param value: url for resolve the did, str
:param account... | [
"def",
"_register_attribute",
"(",
"self",
",",
"did",
",",
"checksum",
",",
"value",
",",
"account",
",",
"providers",
")",
":",
"assert",
"isinstance",
"(",
"providers",
",",
"list",
")",
",",
"''",
"return",
"self",
".",
"send_transaction",
"(",
"'regis... | Register an DID attribute as an event on the block chain.
:param did: 32 byte string/hex of the DID
:param checksum: checksum of the ddo, hex str
:param value: url for resolve the did, str
:param account: account owner of this DID registration record
:param providers: list of pr... | [
"Register",
"an",
"DID",
"attribute",
"as",
"an",
"event",
"on",
"the",
"block",
"chain",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/didregistry.py#L64-L82 | train |
oceanprotocol/squid-py | squid_py/keeper/didregistry.py | DIDRegistry.remove_provider | def remove_provider(self, did, provider_address, account):
"""
Remove a provider
:param did: the id of an asset on-chain, hex str
:param provider_address: ethereum account address of the provider, hex str
:param account: Account executing the action
:return:
"""
... | python | def remove_provider(self, did, provider_address, account):
"""
Remove a provider
:param did: the id of an asset on-chain, hex str
:param provider_address: ethereum account address of the provider, hex str
:param account: Account executing the action
:return:
"""
... | [
"def",
"remove_provider",
"(",
"self",
",",
"did",
",",
"provider_address",
",",
"account",
")",
":",
"tx_hash",
"=",
"self",
".",
"send_transaction",
"(",
"'removeDIDProvider'",
",",
"(",
"did",
",",
"provider_address",
")",
",",
"transact",
"=",
"{",
"'fro... | Remove a provider
:param did: the id of an asset on-chain, hex str
:param provider_address: ethereum account address of the provider, hex str
:param account: Account executing the action
:return: | [
"Remove",
"a",
"provider"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/didregistry.py#L115-L131 | train |
oceanprotocol/squid-py | squid_py/keeper/didregistry.py | DIDRegistry.get_did_providers | def get_did_providers(self, did):
"""
Return the list providers registered on-chain for the given did.
:param did: hex str the id of an asset on-chain
:return:
list of addresses
None if asset has no registerd providers
"""
register_values = self.c... | python | def get_did_providers(self, did):
"""
Return the list providers registered on-chain for the given did.
:param did: hex str the id of an asset on-chain
:return:
list of addresses
None if asset has no registerd providers
"""
register_values = self.c... | [
"def",
"get_did_providers",
"(",
"self",
",",
"did",
")",
":",
"register_values",
"=",
"self",
".",
"contract_concise",
".",
"getDIDRegister",
"(",
"did",
")",
"if",
"register_values",
"and",
"len",
"(",
"register_values",
")",
"==",
"5",
":",
"return",
"DID... | Return the list providers registered on-chain for the given did.
:param did: hex str the id of an asset on-chain
:return:
list of addresses
None if asset has no registerd providers | [
"Return",
"the",
"list",
"providers",
"registered",
"on",
"-",
"chain",
"for",
"the",
"given",
"did",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/didregistry.py#L143-L156 | train |
oceanprotocol/squid-py | squid_py/keeper/didregistry.py | DIDRegistry.get_owner_asset_ids | def get_owner_asset_ids(self, address):
"""
Get the list of assets owned by an address owner.
:param address: ethereum account address, hex str
:return:
"""
block_filter = self._get_event_filter(owner=address)
log_items = block_filter.get_all_entries(max_tries=5)... | python | def get_owner_asset_ids(self, address):
"""
Get the list of assets owned by an address owner.
:param address: ethereum account address, hex str
:return:
"""
block_filter = self._get_event_filter(owner=address)
log_items = block_filter.get_all_entries(max_tries=5)... | [
"def",
"get_owner_asset_ids",
"(",
"self",
",",
"address",
")",
":",
"block_filter",
"=",
"self",
".",
"_get_event_filter",
"(",
"owner",
"=",
"address",
")",
"log_items",
"=",
"block_filter",
".",
"get_all_entries",
"(",
"max_tries",
"=",
"5",
")",
"did_list"... | Get the list of assets owned by an address owner.
:param address: ethereum account address, hex str
:return: | [
"Get",
"the",
"list",
"of",
"assets",
"owned",
"by",
"an",
"address",
"owner",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/didregistry.py#L158-L171 | train |
oceanprotocol/squid-py | squid_py/ddo/public_key_rsa.py | PublicKeyRSA.set_encode_key_value | def set_encode_key_value(self, value, store_type=PUBLIC_KEY_STORE_TYPE_BASE64):
"""Set the value based on the type of encoding supported by RSA."""
if store_type == PUBLIC_KEY_STORE_TYPE_PEM:
PublicKeyBase.set_encode_key_value(self, value.exportKey('PEM').decode(), store_type)
else:
... | python | def set_encode_key_value(self, value, store_type=PUBLIC_KEY_STORE_TYPE_BASE64):
"""Set the value based on the type of encoding supported by RSA."""
if store_type == PUBLIC_KEY_STORE_TYPE_PEM:
PublicKeyBase.set_encode_key_value(self, value.exportKey('PEM').decode(), store_type)
else:
... | [
"def",
"set_encode_key_value",
"(",
"self",
",",
"value",
",",
"store_type",
"=",
"PUBLIC_KEY_STORE_TYPE_BASE64",
")",
":",
"if",
"store_type",
"==",
"PUBLIC_KEY_STORE_TYPE_PEM",
":",
"PublicKeyBase",
".",
"set_encode_key_value",
"(",
"self",
",",
"value",
".",
"exp... | Set the value based on the type of encoding supported by RSA. | [
"Set",
"the",
"value",
"based",
"on",
"the",
"type",
"of",
"encoding",
"supported",
"by",
"RSA",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ddo/public_key_rsa.py#L27-L32 | train |
oceanprotocol/squid-py | squid_py/did.py | did_parse | def did_parse(did):
"""
Parse a DID into it's parts.
:param did: Asset did, str.
:return: Python dictionary with the method and the id.
"""
if not isinstance(did, str):
raise TypeError(f'Expecting DID of string type, got {did} of {type(did)} type')
match = re.match('^did:([a-z0-9]+... | python | def did_parse(did):
"""
Parse a DID into it's parts.
:param did: Asset did, str.
:return: Python dictionary with the method and the id.
"""
if not isinstance(did, str):
raise TypeError(f'Expecting DID of string type, got {did} of {type(did)} type')
match = re.match('^did:([a-z0-9]+... | [
"def",
"did_parse",
"(",
"did",
")",
":",
"if",
"not",
"isinstance",
"(",
"did",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"f'Expecting DID of string type, got {did} of {type(did)} type'",
")",
"match",
"=",
"re",
".",
"match",
"(",
"'^did:([a-z0-9]+):([a-z... | Parse a DID into it's parts.
:param did: Asset did, str.
:return: Python dictionary with the method and the id. | [
"Parse",
"a",
"DID",
"into",
"it",
"s",
"parts",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/did.py#L31-L50 | train |
oceanprotocol/squid-py | squid_py/did.py | id_to_did | def id_to_did(did_id, method='op'):
"""Return an Ocean DID from given a hex id."""
if isinstance(did_id, bytes):
did_id = Web3.toHex(did_id)
# remove leading '0x' of a hex string
if isinstance(did_id, str):
did_id = remove_0x_prefix(did_id)
else:
raise TypeError("did id must... | python | def id_to_did(did_id, method='op'):
"""Return an Ocean DID from given a hex id."""
if isinstance(did_id, bytes):
did_id = Web3.toHex(did_id)
# remove leading '0x' of a hex string
if isinstance(did_id, str):
did_id = remove_0x_prefix(did_id)
else:
raise TypeError("did id must... | [
"def",
"id_to_did",
"(",
"did_id",
",",
"method",
"=",
"'op'",
")",
":",
"if",
"isinstance",
"(",
"did_id",
",",
"bytes",
")",
":",
"did_id",
"=",
"Web3",
".",
"toHex",
"(",
"did_id",
")",
"if",
"isinstance",
"(",
"did_id",
",",
"str",
")",
":",
"d... | Return an Ocean DID from given a hex id. | [
"Return",
"an",
"Ocean",
"DID",
"from",
"given",
"a",
"hex",
"id",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/did.py#L69-L83 | train |
oceanprotocol/squid-py | squid_py/did.py | did_to_id_bytes | def did_to_id_bytes(did):
"""
Return an Ocean DID to it's correspondng hex id in bytes.
So did:op:<hex>, will return <hex> in byte format
"""
if isinstance(did, str):
if re.match('^[0x]?[0-9A-Za-z]+$', did):
raise ValueError(f'{did} must be a DID not a hex string')
else:... | python | def did_to_id_bytes(did):
"""
Return an Ocean DID to it's correspondng hex id in bytes.
So did:op:<hex>, will return <hex> in byte format
"""
if isinstance(did, str):
if re.match('^[0x]?[0-9A-Za-z]+$', did):
raise ValueError(f'{did} must be a DID not a hex string')
else:... | [
"def",
"did_to_id_bytes",
"(",
"did",
")",
":",
"if",
"isinstance",
"(",
"did",
",",
"str",
")",
":",
"if",
"re",
".",
"match",
"(",
"'^[0x]?[0-9A-Za-z]+$'",
",",
"did",
")",
":",
"raise",
"ValueError",
"(",
"f'{did} must be a DID not a hex string'",
")",
"e... | Return an Ocean DID to it's correspondng hex id in bytes.
So did:op:<hex>, will return <hex> in byte format | [
"Return",
"an",
"Ocean",
"DID",
"to",
"it",
"s",
"correspondng",
"hex",
"id",
"in",
"bytes",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/did.py#L94-L115 | train |
oceanprotocol/squid-py | squid_py/keeper/templates/template_manager.py | TemplateStoreManager.get_template | def get_template(self, template_id):
"""
Get the template for a given template id.
:param template_id: id of the template, str
:return:
"""
template = self.contract_concise.getTemplate(template_id)
if template and len(template) == 4:
return AgreementT... | python | def get_template(self, template_id):
"""
Get the template for a given template id.
:param template_id: id of the template, str
:return:
"""
template = self.contract_concise.getTemplate(template_id)
if template and len(template) == 4:
return AgreementT... | [
"def",
"get_template",
"(",
"self",
",",
"template_id",
")",
":",
"template",
"=",
"self",
".",
"contract_concise",
".",
"getTemplate",
"(",
"template_id",
")",
"if",
"template",
"and",
"len",
"(",
"template",
")",
"==",
"4",
":",
"return",
"AgreementTemplat... | Get the template for a given template id.
:param template_id: id of the template, str
:return: | [
"Get",
"the",
"template",
"for",
"a",
"given",
"template",
"id",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/templates/template_manager.py#L19-L30 | train |
oceanprotocol/squid-py | squid_py/keeper/templates/template_manager.py | TemplateStoreManager.propose_template | def propose_template(self, template_id, from_account):
"""Propose a template.
:param template_id: id of the template, str
:param from_account: Account
:return: bool
"""
tx_hash = self.send_transaction(
'proposeTemplate',
(template_id,),
... | python | def propose_template(self, template_id, from_account):
"""Propose a template.
:param template_id: id of the template, str
:param from_account: Account
:return: bool
"""
tx_hash = self.send_transaction(
'proposeTemplate',
(template_id,),
... | [
"def",
"propose_template",
"(",
"self",
",",
"template_id",
",",
"from_account",
")",
":",
"tx_hash",
"=",
"self",
".",
"send_transaction",
"(",
"'proposeTemplate'",
",",
"(",
"template_id",
",",
")",
",",
"transact",
"=",
"{",
"'from'",
":",
"from_account",
... | Propose a template.
:param template_id: id of the template, str
:param from_account: Account
:return: bool | [
"Propose",
"a",
"template",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/templates/template_manager.py#L32-L44 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceDescriptor.access_service_descriptor | def access_service_descriptor(price, consume_endpoint, service_endpoint, timeout, template_id):
"""
Access service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the a... | python | def access_service_descriptor(price, consume_endpoint, service_endpoint, timeout, template_id):
"""
Access service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the a... | [
"def",
"access_service_descriptor",
"(",
"price",
",",
"consume_endpoint",
",",
"service_endpoint",
",",
"timeout",
",",
"template_id",
")",
":",
"return",
"(",
"ServiceTypes",
".",
"ASSET_ACCESS",
",",
"{",
"'price'",
":",
"price",
",",
"'consumeEndpoint'",
":",
... | Access service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the asset DDO, str
:param timeout: amount of time in seconds before the agreement expires, int
:param tem... | [
"Access",
"service",
"descriptor",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L42-L56 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceDescriptor.compute_service_descriptor | def compute_service_descriptor(price, consume_endpoint, service_endpoint, timeout):
"""
Compute service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the asset DDO, s... | python | def compute_service_descriptor(price, consume_endpoint, service_endpoint, timeout):
"""
Compute service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the asset DDO, s... | [
"def",
"compute_service_descriptor",
"(",
"price",
",",
"consume_endpoint",
",",
"service_endpoint",
",",
"timeout",
")",
":",
"return",
"(",
"ServiceTypes",
".",
"CLOUD_COMPUTE",
",",
"{",
"'price'",
":",
"price",
",",
"'consumeEndpoint'",
":",
"consume_endpoint",
... | Compute service descriptor.
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the asset DDO, str
:param timeout: amount of time in seconds before the agreement expires, int
:return: ... | [
"Compute",
"service",
"descriptor",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L59-L72 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceFactory.build_services | def build_services(did, service_descriptors):
"""
Build a list of services.
:param did: DID, str
:param service_descriptors: List of tuples of length 2. The first item must be one of
ServiceTypes
and the second item is a dict of parameters and values required by the serv... | python | def build_services(did, service_descriptors):
"""
Build a list of services.
:param did: DID, str
:param service_descriptors: List of tuples of length 2. The first item must be one of
ServiceTypes
and the second item is a dict of parameters and values required by the serv... | [
"def",
"build_services",
"(",
"did",
",",
"service_descriptors",
")",
":",
"services",
"=",
"[",
"]",
"sa_def_key",
"=",
"ServiceAgreement",
".",
"SERVICE_DEFINITION_ID",
"for",
"i",
",",
"service_desc",
"in",
"enumerate",
"(",
"service_descriptors",
")",
":",
"... | Build a list of services.
:param did: DID, str
:param service_descriptors: List of tuples of length 2. The first item must be one of
ServiceTypes
and the second item is a dict of parameters and values required by the service
:return: List of Services | [
"Build",
"a",
"list",
"of",
"services",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L79-L97 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceFactory.build_service | def build_service(service_descriptor, did):
"""
Build a service.
:param service_descriptor: Tuples of length 2. The first item must be one of ServiceTypes
and the second item is a dict of parameters and values required by the service
:param did: DID, str
:return: Service... | python | def build_service(service_descriptor, did):
"""
Build a service.
:param service_descriptor: Tuples of length 2. The first item must be one of ServiceTypes
and the second item is a dict of parameters and values required by the service
:param did: DID, str
:return: Service... | [
"def",
"build_service",
"(",
"service_descriptor",
",",
"did",
")",
":",
"assert",
"isinstance",
"(",
"service_descriptor",
",",
"tuple",
")",
"and",
"len",
"(",
"service_descriptor",
")",
"==",
"2",
",",
"'Unknown service descriptor format.'",
"service_type",
",",
... | Build a service.
:param service_descriptor: Tuples of length 2. The first item must be one of ServiceTypes
and the second item is a dict of parameters and values required by the service
:param did: DID, str
:return: Service | [
"Build",
"a",
"service",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L100-L137 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceFactory.build_metadata_service | def build_metadata_service(did, metadata, service_endpoint):
"""
Build a metadata service.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:param service_endpoint: identifier of the service inside the asset DDO, str
:retu... | python | def build_metadata_service(did, metadata, service_endpoint):
"""
Build a metadata service.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:param service_endpoint: identifier of the service inside the asset DDO, str
:retu... | [
"def",
"build_metadata_service",
"(",
"did",
",",
"metadata",
",",
"service_endpoint",
")",
":",
"return",
"Service",
"(",
"service_endpoint",
",",
"ServiceTypes",
".",
"METADATA",
",",
"values",
"=",
"{",
"'metadata'",
":",
"metadata",
"}",
",",
"did",
"=",
... | Build a metadata service.
:param did: DID, str
:param metadata: conforming to the Metadata accepted by Ocean Protocol, dict
:param service_endpoint: identifier of the service inside the asset DDO, str
:return: Service | [
"Build",
"a",
"metadata",
"service",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L140-L152 | train |
oceanprotocol/squid-py | squid_py/agreements/service_factory.py | ServiceFactory.build_access_service | def build_access_service(did, price, consume_endpoint, service_endpoint, timeout, template_id):
"""
Build the access service.
:param did: DID, str
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier... | python | def build_access_service(did, price, consume_endpoint, service_endpoint, timeout, template_id):
"""
Build the access service.
:param did: DID, str
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier... | [
"def",
"build_access_service",
"(",
"did",
",",
"price",
",",
"consume_endpoint",
",",
"service_endpoint",
",",
"timeout",
",",
"template_id",
")",
":",
"param_map",
"=",
"{",
"'_documentId'",
":",
"did_to_id",
"(",
"did",
")",
",",
"'_amount'",
":",
"price",
... | Build the access service.
:param did: DID, str
:param price: Asset price, int
:param consume_endpoint: url of the service provider, str
:param service_endpoint: identifier of the service inside the asset DDO, str
:param timeout: amount of time in seconds before the agreement exp... | [
"Build",
"the",
"access",
"service",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_factory.py#L166-L204 | train |
oceanprotocol/squid-py | squid_py/agreements/storage.py | record_service_agreement | def record_service_agreement(storage_path, service_agreement_id, did, service_definition_id, price,
files, start_time,
status='pending'):
"""
Records the given pending service agreement.
:param storage_path: storage path for the internal db, str
... | python | def record_service_agreement(storage_path, service_agreement_id, did, service_definition_id, price,
files, start_time,
status='pending'):
"""
Records the given pending service agreement.
:param storage_path: storage path for the internal db, str
... | [
"def",
"record_service_agreement",
"(",
"storage_path",
",",
"service_agreement_id",
",",
"did",
",",
"service_definition_id",
",",
"price",
",",
"files",
",",
"start_time",
",",
"status",
"=",
"'pending'",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
... | Records the given pending service agreement.
:param storage_path: storage path for the internal db, str
:param service_agreement_id:
:param did: DID, str
:param service_definition_id: identifier of the service inside the asset DDO, str
:param price: Asset price, int
:param files:
:param sta... | [
"Records",
"the",
"given",
"pending",
"service",
"agreement",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/storage.py#L8-L39 | train |
oceanprotocol/squid-py | squid_py/agreements/storage.py | update_service_agreement_status | def update_service_agreement_status(storage_path, service_agreement_id, status='pending'):
"""
Update the service agreement status.
:param storage_path: storage path for the internal db, str
:param service_agreement_id:
:param status:
:return:
"""
conn = sqlite3.connect(storage_path)
... | python | def update_service_agreement_status(storage_path, service_agreement_id, status='pending'):
"""
Update the service agreement status.
:param storage_path: storage path for the internal db, str
:param service_agreement_id:
:param status:
:return:
"""
conn = sqlite3.connect(storage_path)
... | [
"def",
"update_service_agreement_status",
"(",
"storage_path",
",",
"service_agreement_id",
",",
"status",
"=",
"'pending'",
")",
":",
"conn",
"=",
"sqlite3",
".",
"connect",
"(",
"storage_path",
")",
"try",
":",
"cursor",
"=",
"conn",
".",
"cursor",
"(",
")",... | Update the service agreement status.
:param storage_path: storage path for the internal db, str
:param service_agreement_id:
:param status:
:return: | [
"Update",
"the",
"service",
"agreement",
"status",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/storage.py#L42-L60 | train |
oceanprotocol/squid-py | squid_py/log.py | setup_logging | def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""Logging setup."""
path = default_path
value = os.getenv(env_key, None)
if value:
path = value
if os.path.exists(path):
with open(path, 'rt') as file:
try:
con... | python | def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""Logging setup."""
path = default_path
value = os.getenv(env_key, None)
if value:
path = value
if os.path.exists(path):
with open(path, 'rt') as file:
try:
con... | [
"def",
"setup_logging",
"(",
"default_path",
"=",
"'logging.yaml'",
",",
"default_level",
"=",
"logging",
".",
"INFO",
",",
"env_key",
"=",
"'LOG_CFG'",
")",
":",
"path",
"=",
"default_path",
"value",
"=",
"os",
".",
"getenv",
"(",
"env_key",
",",
"None",
... | Logging setup. | [
"Logging",
"setup",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/log.py#L13-L34 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_secret_store.py | OceanSecretStore.encrypt | def encrypt(self, document_id, content, account):
"""
Encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document to use for e... | python | def encrypt(self, document_id, content, account):
"""
Encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document to use for e... | [
"def",
"encrypt",
"(",
"self",
",",
"document_id",
",",
"content",
",",
"account",
")",
":",
"return",
"self",
".",
"_secret_store",
"(",
"account",
")",
".",
"encrypt_document",
"(",
"document_id",
",",
"content",
")"
] | Encrypt string data using the DID as an secret store id,
if secret store is enabled then return the result from secret store encryption
None for no encryption performed
:param document_id: hex str id of document to use for encryption session
:param content: str to be encrypted
... | [
"Encrypt",
"string",
"data",
"using",
"the",
"DID",
"as",
"an",
"secret",
"store",
"id",
"if",
"secret",
"store",
"is",
"enabled",
"then",
"return",
"the",
"result",
"from",
"secret",
"store",
"encryption"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_secret_store.py#L34-L46 | train |
oceanprotocol/squid-py | squid_py/did_resolver/did_resolver.py | DIDResolver.get_resolve_url | def get_resolve_url(self, did_bytes):
"""Return a did value and value type from the block chain event record using 'did'.
:param did_bytes: DID, hex-str
:return url: Url, str
"""
data = self._did_registry.get_registered_attribute(did_bytes)
if not (data and data.get('val... | python | def get_resolve_url(self, did_bytes):
"""Return a did value and value type from the block chain event record using 'did'.
:param did_bytes: DID, hex-str
:return url: Url, str
"""
data = self._did_registry.get_registered_attribute(did_bytes)
if not (data and data.get('val... | [
"def",
"get_resolve_url",
"(",
"self",
",",
"did_bytes",
")",
":",
"data",
"=",
"self",
".",
"_did_registry",
".",
"get_registered_attribute",
"(",
"did_bytes",
")",
"if",
"not",
"(",
"data",
"and",
"data",
".",
"get",
"(",
"'value'",
")",
")",
":",
"ret... | Return a did value and value type from the block chain event record using 'did'.
:param did_bytes: DID, hex-str
:return url: Url, str | [
"Return",
"a",
"did",
"value",
"and",
"value",
"type",
"from",
"the",
"block",
"chain",
"event",
"record",
"using",
"did",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/did_resolver/did_resolver.py#L46-L56 | train |
oceanprotocol/squid-py | squid_py/keeper/contract_base.py | ContractBase.get_instance | def get_instance(cls, dependencies=None):
"""
Return an instance for a contract name.
:param dependencies:
:return: Contract base instance
"""
assert cls is not ContractBase, 'ContractBase is not meant to be used directly.'
assert cls.CONTRACT_NAME, 'CONTRACT_NAM... | python | def get_instance(cls, dependencies=None):
"""
Return an instance for a contract name.
:param dependencies:
:return: Contract base instance
"""
assert cls is not ContractBase, 'ContractBase is not meant to be used directly.'
assert cls.CONTRACT_NAME, 'CONTRACT_NAM... | [
"def",
"get_instance",
"(",
"cls",
",",
"dependencies",
"=",
"None",
")",
":",
"assert",
"cls",
"is",
"not",
"ContractBase",
",",
"'ContractBase is not meant to be used directly.'",
"assert",
"cls",
".",
"CONTRACT_NAME",
",",
"'CONTRACT_NAME must be set to a valid keeper ... | Return an instance for a contract name.
:param dependencies:
:return: Contract base instance | [
"Return",
"an",
"instance",
"for",
"a",
"contract",
"name",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/contract_base.py#L38-L47 | train |
oceanprotocol/squid-py | squid_py/keeper/contract_base.py | ContractBase.get_tx_receipt | def get_tx_receipt(tx_hash):
"""
Get the receipt of a tx.
:param tx_hash: hash of the transaction
:return: Tx receipt
"""
try:
Web3Provider.get_web3().eth.waitForTransactionReceipt(tx_hash, timeout=20)
except Timeout:
logger.info('Waiting ... | python | def get_tx_receipt(tx_hash):
"""
Get the receipt of a tx.
:param tx_hash: hash of the transaction
:return: Tx receipt
"""
try:
Web3Provider.get_web3().eth.waitForTransactionReceipt(tx_hash, timeout=20)
except Timeout:
logger.info('Waiting ... | [
"def",
"get_tx_receipt",
"(",
"tx_hash",
")",
":",
"try",
":",
"Web3Provider",
".",
"get_web3",
"(",
")",
".",
"eth",
".",
"waitForTransactionReceipt",
"(",
"tx_hash",
",",
"timeout",
"=",
"20",
")",
"except",
"Timeout",
":",
"logger",
".",
"info",
"(",
... | Get the receipt of a tx.
:param tx_hash: hash of the transaction
:return: Tx receipt | [
"Get",
"the",
"receipt",
"of",
"a",
"tx",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/contract_base.py#L83-L95 | train |
oceanprotocol/squid-py | squid_py/keeper/contract_base.py | ContractBase.subscribe_to_event | def subscribe_to_event(self, event_name, timeout, event_filter, callback=False,
timeout_callback=None, args=None, wait=False):
"""
Create a listener for the event choose.
:param event_name: name of the event to subscribe, str
:param timeout:
:param eve... | python | def subscribe_to_event(self, event_name, timeout, event_filter, callback=False,
timeout_callback=None, args=None, wait=False):
"""
Create a listener for the event choose.
:param event_name: name of the event to subscribe, str
:param timeout:
:param eve... | [
"def",
"subscribe_to_event",
"(",
"self",
",",
"event_name",
",",
"timeout",
",",
"event_filter",
",",
"callback",
"=",
"False",
",",
"timeout_callback",
"=",
"None",
",",
"args",
"=",
"None",
",",
"wait",
"=",
"False",
")",
":",
"from",
"squid_py",
".",
... | Create a listener for the event choose.
:param event_name: name of the event to subscribe, str
:param timeout:
:param event_filter:
:param callback:
:param timeout_callback:
:param args:
:param wait: if true block the listener until get the event, bool
:r... | [
"Create",
"a",
"listener",
"for",
"the",
"event",
"choose",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/contract_base.py#L97-L122 | train |
oceanprotocol/squid-py | squid_py/agreements/events/escrow_reward_condition.py | refund_reward | def refund_reward(event, agreement_id, did, service_agreement, price, consumer_account,
publisher_address, condition_ids):
"""
Refund the reward to the publisher address.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did:... | python | def refund_reward(event, agreement_id, did, service_agreement, price, consumer_account,
publisher_address, condition_ids):
"""
Refund the reward to the publisher address.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did:... | [
"def",
"refund_reward",
"(",
"event",
",",
"agreement_id",
",",
"did",
",",
"service_agreement",
",",
"price",
",",
"consumer_account",
",",
"publisher_address",
",",
"condition_ids",
")",
":",
"logger",
".",
"debug",
"(",
"f\"trigger refund after event {event}.\"",
... | Refund the reward to the publisher address.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param service_agreement: ServiceAgreement instance
:param price: Asset price, int
:param consumer_account: Account instance of the... | [
"Refund",
"the",
"reward",
"to",
"the",
"publisher",
"address",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/events/escrow_reward_condition.py#L56-L98 | train |
oceanprotocol/squid-py | squid_py/agreements/events/escrow_reward_condition.py | consume_asset | def consume_asset(event, agreement_id, did, service_agreement, consumer_account, consume_callback):
"""
Consumption of an asset after get the event call.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param service_agreem... | python | def consume_asset(event, agreement_id, did, service_agreement, consumer_account, consume_callback):
"""
Consumption of an asset after get the event call.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param service_agreem... | [
"def",
"consume_asset",
"(",
"event",
",",
"agreement_id",
",",
"did",
",",
"service_agreement",
",",
"consumer_account",
",",
"consume_callback",
")",
":",
"logger",
".",
"debug",
"(",
"f\"consuming asset after event {event}.\"",
")",
"if",
"consume_callback",
":",
... | Consumption of an asset after get the event call.
:param event: AttributeDict with the event data.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param service_agreement: ServiceAgreement instance
:param consumer_account: Account instance of the consumer
:param consume_... | [
"Consumption",
"of",
"an",
"asset",
"after",
"get",
"the",
"event",
"call",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/events/escrow_reward_condition.py#L101-L128 | train |
oceanprotocol/squid-py | squid_py/keeper/diagnostics.py | Diagnostics.verify_contracts | def verify_contracts():
"""
Verify that the contracts are deployed correctly in the network.
:raise Exception: raise exception if the contracts are not deployed correctly.
"""
artifacts_path = ConfigProvider.get_config().keeper_path
logger.info(f'Keeper contract artifact... | python | def verify_contracts():
"""
Verify that the contracts are deployed correctly in the network.
:raise Exception: raise exception if the contracts are not deployed correctly.
"""
artifacts_path = ConfigProvider.get_config().keeper_path
logger.info(f'Keeper contract artifact... | [
"def",
"verify_contracts",
"(",
")",
":",
"artifacts_path",
"=",
"ConfigProvider",
".",
"get_config",
"(",
")",
".",
"keeper_path",
"logger",
".",
"info",
"(",
"f'Keeper contract artifacts (JSON abi files) at: {artifacts_path}'",
")",
"if",
"os",
".",
"environ",
".",
... | Verify that the contracts are deployed correctly in the network.
:raise Exception: raise exception if the contracts are not deployed correctly. | [
"Verify",
"that",
"the",
"contracts",
"are",
"deployed",
"correctly",
"in",
"the",
"network",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/diagnostics.py#L19-L66 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_services.py | OceanServices.create_access_service | def create_access_service(price, service_endpoint, consume_endpoint, timeout=None):
"""
Publish an asset with an `Access` service according to the supplied attributes.
:param price: Asset price, int
:param service_endpoint: str URL for initiating service access request
:param co... | python | def create_access_service(price, service_endpoint, consume_endpoint, timeout=None):
"""
Publish an asset with an `Access` service according to the supplied attributes.
:param price: Asset price, int
:param service_endpoint: str URL for initiating service access request
:param co... | [
"def",
"create_access_service",
"(",
"price",
",",
"service_endpoint",
",",
"consume_endpoint",
",",
"timeout",
"=",
"None",
")",
":",
"timeout",
"=",
"timeout",
"or",
"3600",
"service",
"=",
"ServiceDescriptor",
".",
"access_service_descriptor",
"(",
"price",
","... | Publish an asset with an `Access` service according to the supplied attributes.
:param price: Asset price, int
:param service_endpoint: str URL for initiating service access request
:param consume_endpoint: str URL to consume service
:param timeout: int amount of time in seconds before ... | [
"Publish",
"an",
"asset",
"with",
"an",
"Access",
"service",
"according",
"to",
"the",
"supplied",
"attributes",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_services.py#L12-L27 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_conditions.py | OceanConditions.lock_reward | def lock_reward(self, agreement_id, amount, account):
"""
Lock reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: bool
"""
return self._keeper.lock_reward_condition.ful... | python | def lock_reward(self, agreement_id, amount, account):
"""
Lock reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: bool
"""
return self._keeper.lock_reward_condition.ful... | [
"def",
"lock_reward",
"(",
"self",
",",
"agreement_id",
",",
"amount",
",",
"account",
")",
":",
"return",
"self",
".",
"_keeper",
".",
"lock_reward_condition",
".",
"fulfill",
"(",
"agreement_id",
",",
"self",
".",
"_keeper",
".",
"escrow_reward_condition",
"... | Lock reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: bool | [
"Lock",
"reward",
"condition",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_conditions.py#L15-L26 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_conditions.py | OceanConditions.grant_access | def grant_access(self, agreement_id, did, grantee_address, account):
"""
Grant access condition.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param grantee_address: Address, hex str
:param account: Account
:return:
"""
r... | python | def grant_access(self, agreement_id, did, grantee_address, account):
"""
Grant access condition.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param grantee_address: Address, hex str
:param account: Account
:return:
"""
r... | [
"def",
"grant_access",
"(",
"self",
",",
"agreement_id",
",",
"did",
",",
"grantee_address",
",",
"account",
")",
":",
"return",
"self",
".",
"_keeper",
".",
"access_secret_store_condition",
".",
"fulfill",
"(",
"agreement_id",
",",
"add_0x_prefix",
"(",
"did_to... | Grant access condition.
:param agreement_id: id of the agreement, hex str
:param did: DID, str
:param grantee_address: Address, hex str
:param account: Account
:return: | [
"Grant",
"access",
"condition",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_conditions.py#L28-L40 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_conditions.py | OceanConditions.release_reward | def release_reward(self, agreement_id, amount, account):
"""
Release reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return:
"""
agreement_values = self._keeper.agreement_ma... | python | def release_reward(self, agreement_id, amount, account):
"""
Release reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return:
"""
agreement_values = self._keeper.agreement_ma... | [
"def",
"release_reward",
"(",
"self",
",",
"agreement_id",
",",
"amount",
",",
"account",
")",
":",
"agreement_values",
"=",
"self",
".",
"_keeper",
".",
"agreement_manager",
".",
"get_agreement",
"(",
"agreement_id",
")",
"consumer",
",",
"provider",
"=",
"se... | Release reward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: | [
"Release",
"reward",
"condition",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_conditions.py#L42-L63 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_conditions.py | OceanConditions.refund_reward | def refund_reward(self, agreement_id, amount, account):
"""
Refund reaward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return:
"""
return self.release_reward(agreement_id, amou... | python | def refund_reward(self, agreement_id, amount, account):
"""
Refund reaward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return:
"""
return self.release_reward(agreement_id, amou... | [
"def",
"refund_reward",
"(",
"self",
",",
"agreement_id",
",",
"amount",
",",
"account",
")",
":",
"return",
"self",
".",
"release_reward",
"(",
"agreement_id",
",",
"amount",
",",
"account",
")"
] | Refund reaward condition.
:param agreement_id: id of the agreement, hex str
:param amount: Amount of tokens, int
:param account: Account
:return: | [
"Refund",
"reaward",
"condition",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_conditions.py#L65-L74 | train |
oceanprotocol/squid-py | squid_py/agreements/service_agreement_template.py | ServiceAgreementTemplate.from_json_file | def from_json_file(cls, path):
"""
Return a template from a json allocated in a path.
:param path: string
:return: ServiceAgreementTemplate
"""
with open(path) as jsf:
template_json = json.load(jsf)
return cls(template_json=template_json) | python | def from_json_file(cls, path):
"""
Return a template from a json allocated in a path.
:param path: string
:return: ServiceAgreementTemplate
"""
with open(path) as jsf:
template_json = json.load(jsf)
return cls(template_json=template_json) | [
"def",
"from_json_file",
"(",
"cls",
",",
"path",
")",
":",
"with",
"open",
"(",
"path",
")",
"as",
"jsf",
":",
"template_json",
"=",
"json",
".",
"load",
"(",
"jsf",
")",
"return",
"cls",
"(",
"template_json",
"=",
"template_json",
")"
] | Return a template from a json allocated in a path.
:param path: string
:return: ServiceAgreementTemplate | [
"Return",
"a",
"template",
"from",
"a",
"json",
"allocated",
"in",
"a",
"path",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement_template.py#L24-L33 | train |
oceanprotocol/squid-py | squid_py/agreements/service_agreement_template.py | ServiceAgreementTemplate.parse_template_json | def parse_template_json(self, template_json):
"""
Parse a template from a json.
:param template_json: json dict
"""
assert template_json['type'] == self.DOCUMENT_TYPE, ''
self.template_id = template_json['templateId']
self.name = template_json.get('name')
... | python | def parse_template_json(self, template_json):
"""
Parse a template from a json.
:param template_json: json dict
"""
assert template_json['type'] == self.DOCUMENT_TYPE, ''
self.template_id = template_json['templateId']
self.name = template_json.get('name')
... | [
"def",
"parse_template_json",
"(",
"self",
",",
"template_json",
")",
":",
"assert",
"template_json",
"[",
"'type'",
"]",
"==",
"self",
".",
"DOCUMENT_TYPE",
",",
"''",
"self",
".",
"template_id",
"=",
"template_json",
"[",
"'templateId'",
"]",
"self",
".",
... | Parse a template from a json.
:param template_json: json dict | [
"Parse",
"a",
"template",
"from",
"a",
"json",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement_template.py#L35-L45 | train |
oceanprotocol/squid-py | squid_py/agreements/service_agreement_template.py | ServiceAgreementTemplate.as_dictionary | def as_dictionary(self):
"""
Return the service agreement template as a dictionary.
:return: dict
"""
template = {
'contractName': self.contract_name,
'events': [e.as_dictionary() for e in self.agreement_events],
'fulfillmentOrder': self.fulfi... | python | def as_dictionary(self):
"""
Return the service agreement template as a dictionary.
:return: dict
"""
template = {
'contractName': self.contract_name,
'events': [e.as_dictionary() for e in self.agreement_events],
'fulfillmentOrder': self.fulfi... | [
"def",
"as_dictionary",
"(",
"self",
")",
":",
"template",
"=",
"{",
"'contractName'",
":",
"self",
".",
"contract_name",
",",
"'events'",
":",
"[",
"e",
".",
"as_dictionary",
"(",
")",
"for",
"e",
"in",
"self",
".",
"agreement_events",
"]",
",",
"'fulfi... | Return the service agreement template as a dictionary.
:return: dict | [
"Return",
"the",
"service",
"agreement",
"template",
"as",
"a",
"dictionary",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement_template.py#L110-L128 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_tokens.py | OceanTokens.request | def request(self, account, amount):
"""
Request a number of tokens to be minted and transfered to `account`
:param account: Account instance requesting the tokens
:param amount: int number of tokens to request
:return: bool
"""
return self._keeper.dispenser.reque... | python | def request(self, account, amount):
"""
Request a number of tokens to be minted and transfered to `account`
:param account: Account instance requesting the tokens
:param amount: int number of tokens to request
:return: bool
"""
return self._keeper.dispenser.reque... | [
"def",
"request",
"(",
"self",
",",
"account",
",",
"amount",
")",
":",
"return",
"self",
".",
"_keeper",
".",
"dispenser",
".",
"request_tokens",
"(",
"amount",
",",
"account",
")"
] | Request a number of tokens to be minted and transfered to `account`
:param account: Account instance requesting the tokens
:param amount: int number of tokens to request
:return: bool | [
"Request",
"a",
"number",
"of",
"tokens",
"to",
"be",
"minted",
"and",
"transfered",
"to",
"account"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_tokens.py#L11-L19 | train |
oceanprotocol/squid-py | squid_py/ocean/ocean_tokens.py | OceanTokens.transfer | def transfer(self, receiver_address, amount, sender_account):
"""
Transfer a number of tokens from `sender_account` to `receiver_address`
:param receiver_address: hex str ethereum address to receive this transfer of tokens
:param amount: int number of tokens to transfer
:param s... | python | def transfer(self, receiver_address, amount, sender_account):
"""
Transfer a number of tokens from `sender_account` to `receiver_address`
:param receiver_address: hex str ethereum address to receive this transfer of tokens
:param amount: int number of tokens to transfer
:param s... | [
"def",
"transfer",
"(",
"self",
",",
"receiver_address",
",",
"amount",
",",
"sender_account",
")",
":",
"self",
".",
"_keeper",
".",
"token",
".",
"token_approve",
"(",
"receiver_address",
",",
"amount",
",",
"sender_account",
")",
"self",
".",
"_keeper",
"... | Transfer a number of tokens from `sender_account` to `receiver_address`
:param receiver_address: hex str ethereum address to receive this transfer of tokens
:param amount: int number of tokens to transfer
:param sender_account: Account instance to take the tokens from
:return: bool | [
"Transfer",
"a",
"number",
"of",
"tokens",
"from",
"sender_account",
"to",
"receiver_address"
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_tokens.py#L21-L32 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.list_assets | def list_assets(self):
"""
List all the assets registered in the aquarius instance.
:return: List of DID string
"""
response = self.requests_session.get(self._base_url).content
if not response:
return {}
try:
asset_list = json.loads(respo... | python | def list_assets(self):
"""
List all the assets registered in the aquarius instance.
:return: List of DID string
"""
response = self.requests_session.get(self._base_url).content
if not response:
return {}
try:
asset_list = json.loads(respo... | [
"def",
"list_assets",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"requests_session",
".",
"get",
"(",
"self",
".",
"_base_url",
")",
".",
"content",
"if",
"not",
"response",
":",
"return",
"{",
"}",
"try",
":",
"asset_list",
"=",
"json",
".",... | List all the assets registered in the aquarius instance.
:return: List of DID string | [
"List",
"all",
"the",
"assets",
"registered",
"in",
"the",
"aquarius",
"instance",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L55-L77 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.get_asset_ddo | def get_asset_ddo(self, did):
"""
Retrieve asset ddo for a given did.
:param did: Asset DID string
:return: DDO instance
"""
response = self.requests_session.get(f'{self.url}/{did}').content
if not response:
return {}
try:
parsed_r... | python | def get_asset_ddo(self, did):
"""
Retrieve asset ddo for a given did.
:param did: Asset DID string
:return: DDO instance
"""
response = self.requests_session.get(f'{self.url}/{did}').content
if not response:
return {}
try:
parsed_r... | [
"def",
"get_asset_ddo",
"(",
"self",
",",
"did",
")",
":",
"response",
"=",
"self",
".",
"requests_session",
".",
"get",
"(",
"f'{self.url}/{did}'",
")",
".",
"content",
"if",
"not",
"response",
":",
"return",
"{",
"}",
"try",
":",
"parsed_response",
"=",
... | Retrieve asset ddo for a given did.
:param did: Asset DID string
:return: DDO instance | [
"Retrieve",
"asset",
"ddo",
"for",
"a",
"given",
"did",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L79-L97 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.get_asset_metadata | def get_asset_metadata(self, did):
"""
Retrieve asset metadata for a given did.
:param did: Asset DID string
:return: metadata key of the DDO instance
"""
response = self.requests_session.get(f'{self._base_url}/metadata/{did}').content
if not response:
... | python | def get_asset_metadata(self, did):
"""
Retrieve asset metadata for a given did.
:param did: Asset DID string
:return: metadata key of the DDO instance
"""
response = self.requests_session.get(f'{self._base_url}/metadata/{did}').content
if not response:
... | [
"def",
"get_asset_metadata",
"(",
"self",
",",
"did",
")",
":",
"response",
"=",
"self",
".",
"requests_session",
".",
"get",
"(",
"f'{self._base_url}/metadata/{did}'",
")",
".",
"content",
"if",
"not",
"response",
":",
"return",
"{",
"}",
"try",
":",
"parse... | Retrieve asset metadata for a given did.
:param did: Asset DID string
:return: metadata key of the DDO instance | [
"Retrieve",
"asset",
"metadata",
"for",
"a",
"given",
"did",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L99-L117 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.list_assets_ddo | def list_assets_ddo(self):
"""
List all the ddos registered in the aquarius instance.
:return: List of DDO instance
"""
return json.loads(self.requests_session.get(self.url).content) | python | def list_assets_ddo(self):
"""
List all the ddos registered in the aquarius instance.
:return: List of DDO instance
"""
return json.loads(self.requests_session.get(self.url).content) | [
"def",
"list_assets_ddo",
"(",
"self",
")",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"requests_session",
".",
"get",
"(",
"self",
".",
"url",
")",
".",
"content",
")"
] | List all the ddos registered in the aquarius instance.
:return: List of DDO instance | [
"List",
"all",
"the",
"ddos",
"registered",
"in",
"the",
"aquarius",
"instance",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L119-L125 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.publish_asset_ddo | def publish_asset_ddo(self, ddo):
"""
Register asset ddo in aquarius.
:param ddo: DDO instance
:return: API response (depends on implementation)
"""
try:
asset_did = ddo.did
response = self.requests_session.post(self.url, data=ddo.as_text(),
... | python | def publish_asset_ddo(self, ddo):
"""
Register asset ddo in aquarius.
:param ddo: DDO instance
:return: API response (depends on implementation)
"""
try:
asset_did = ddo.did
response = self.requests_session.post(self.url, data=ddo.as_text(),
... | [
"def",
"publish_asset_ddo",
"(",
"self",
",",
"ddo",
")",
":",
"try",
":",
"asset_did",
"=",
"ddo",
".",
"did",
"response",
"=",
"self",
".",
"requests_session",
".",
"post",
"(",
"self",
".",
"url",
",",
"data",
"=",
"ddo",
".",
"as_text",
"(",
")",... | Register asset ddo in aquarius.
:param ddo: DDO instance
:return: API response (depends on implementation) | [
"Register",
"asset",
"ddo",
"in",
"aquarius",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L127-L151 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.update_asset_ddo | def update_asset_ddo(self, did, ddo):
"""
Update the ddo of a did already registered.
:param did: Asset DID string
:param ddo: DDO instance
:return: API response (depends on implementation)
"""
response = self.requests_session.put(f'{self.url}/{did}', data=ddo.as... | python | def update_asset_ddo(self, did, ddo):
"""
Update the ddo of a did already registered.
:param did: Asset DID string
:param ddo: DDO instance
:return: API response (depends on implementation)
"""
response = self.requests_session.put(f'{self.url}/{did}', data=ddo.as... | [
"def",
"update_asset_ddo",
"(",
"self",
",",
"did",
",",
"ddo",
")",
":",
"response",
"=",
"self",
".",
"requests_session",
".",
"put",
"(",
"f'{self.url}/{did}'",
",",
"data",
"=",
"ddo",
".",
"as_text",
"(",
")",
",",
"headers",
"=",
"self",
".",
"_h... | Update the ddo of a did already registered.
:param did: Asset DID string
:param ddo: DDO instance
:return: API response (depends on implementation) | [
"Update",
"the",
"ddo",
"of",
"a",
"did",
"already",
"registered",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L153-L166 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.text_search | def text_search(self, text, sort=None, offset=100, page=1):
"""
Search in aquarius using text query.
Given the string aquarius will do a full-text query to search in all documents.
Currently implemented are the MongoDB and Elastic Search drivers.
For a detailed guide on how to... | python | def text_search(self, text, sort=None, offset=100, page=1):
"""
Search in aquarius using text query.
Given the string aquarius will do a full-text query to search in all documents.
Currently implemented are the MongoDB and Elastic Search drivers.
For a detailed guide on how to... | [
"def",
"text_search",
"(",
"self",
",",
"text",
",",
"sort",
"=",
"None",
",",
"offset",
"=",
"100",
",",
"page",
"=",
"1",
")",
":",
"assert",
"page",
">=",
"1",
",",
"f'Invalid page value {page}. Required page >= 1.'",
"payload",
"=",
"{",
"\"text\"",
":... | Search in aquarius using text query.
Given the string aquarius will do a full-text query to search in all documents.
Currently implemented are the MongoDB and Elastic Search drivers.
For a detailed guide on how to search, see the MongoDB driver documentation:
mongodb driverCurrently i... | [
"Search",
"in",
"aquarius",
"using",
"text",
"query",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L168-L200 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.query_search | def query_search(self, search_query, sort=None, offset=100, page=1):
"""
Search using a query.
Currently implemented is the MongoDB query model to search for documents according to:
https://docs.mongodb.com/manual/tutorial/query-documents/
And an Elastic Search driver, which im... | python | def query_search(self, search_query, sort=None, offset=100, page=1):
"""
Search using a query.
Currently implemented is the MongoDB query model to search for documents according to:
https://docs.mongodb.com/manual/tutorial/query-documents/
And an Elastic Search driver, which im... | [
"def",
"query_search",
"(",
"self",
",",
"search_query",
",",
"sort",
"=",
"None",
",",
"offset",
"=",
"100",
",",
"page",
"=",
"1",
")",
":",
"assert",
"page",
">=",
"1",
",",
"f'Invalid page value {page}. Required page >= 1.'",
"search_query",
"[",
"'sort'",... | Search using a query.
Currently implemented is the MongoDB query model to search for documents according to:
https://docs.mongodb.com/manual/tutorial/query-documents/
And an Elastic Search driver, which implements a basic parser to convert the query into
elastic search format.
... | [
"Search",
"using",
"a",
"query",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L202-L232 | train |
oceanprotocol/squid-py | squid_py/aquarius/aquarius.py | Aquarius.retire_asset_ddo | def retire_asset_ddo(self, did):
"""
Retire asset ddo of Aquarius.
:param did: Asset DID string
:return: API response (depends on implementation)
"""
response = self.requests_session.delete(f'{self.url}/{did}', headers=self._headers)
if response.status_code == 20... | python | def retire_asset_ddo(self, did):
"""
Retire asset ddo of Aquarius.
:param did: Asset DID string
:return: API response (depends on implementation)
"""
response = self.requests_session.delete(f'{self.url}/{did}', headers=self._headers)
if response.status_code == 20... | [
"def",
"retire_asset_ddo",
"(",
"self",
",",
"did",
")",
":",
"response",
"=",
"self",
".",
"requests_session",
".",
"delete",
"(",
"f'{self.url}/{did}'",
",",
"headers",
"=",
"self",
".",
"_headers",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
... | Retire asset ddo of Aquarius.
:param did: Asset DID string
:return: API response (depends on implementation) | [
"Retire",
"asset",
"ddo",
"of",
"Aquarius",
"."
] | 43a5b7431627e4c9ab7382ed9eb8153e96ed4483 | https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/aquarius/aquarius.py#L234-L246 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.