_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q11000 | ppjson | train | def ppjson(dumpit: Any, elide_to: int = None) -> str:
"""
JSON pretty printer, whether already json-encoded or not
:param dumpit: object to pretty-print
:param elide_to: optional maximum length including ellipses ('...')
:return: json pretty-print
"""
if elide_to is not None:
elide... | python | {
"resource": ""
} |
q11001 | do_wait | train | def do_wait(coro: Callable) -> Any:
"""
Perform aynchronous operation; await then return the result.
:param coro: coroutine to await
:return: coroutine result
"""
event_loop = None
try:
event_loop = asyncio.get_event_loop()
except RuntimeError:
event_loop = asyncio.new_... | python | {
"resource": ""
} |
q11002 | Stopwatch.mark | train | def mark(self, digits: int = None) -> float:
"""
Return time in seconds since last mark, reset, or construction.
:param digits: number of fractional decimal digits to retain (default as constructed)
"""
self._mark[:] = [self._mark[1], time()]
rv = self._mark[1] - self._... | python | {
"resource": ""
} |
q11003 | StorageRecordSearch.open | train | async def open(self) -> None:
"""
Begin the search operation.
"""
LOGGER.debug('StorageRecordSearch.open >>>')
if self.opened:
LOGGER.debug('StorageRecordSearch.open <!< Search is already opened')
raise BadSearch('Search is already opened')
if n... | python | {
"resource": ""
} |
q11004 | StorageRecordSearch.fetch | train | async def fetch(self, limit: int = None) -> Sequence[StorageRecord]:
"""
Fetch next batch of search results.
Raise BadSearch if search is closed, WalletState if wallet is closed.
:param limit: maximum number of records to return (default value Wallet.DEFAULT_CHUNK)
:return: nex... | python | {
"resource": ""
} |
q11005 | StorageRecordSearch.close | train | async def close(self) -> None:
"""
Close search.
"""
LOGGER.debug('StorageRecordSearch.close >>>')
if self._handle:
await non_secrets.close_wallet_search(self.handle)
self._handle = None
LOGGER.debug('StorageRecordSearch.close <<<') | python | {
"resource": ""
} |
q11006 | NodePool.cache_id | train | def cache_id(self) -> str:
"""
Return identifier for archivable caches, computing it first and retaining it if need be.
Raise AbsentPool if ledger configuration is not yet available.
:param name: pool name
:return: archivable cache identifier
"""
if self._cache_... | python | {
"resource": ""
} |
q11007 | NodePool.close | train | async def close(self) -> None:
"""
Explicit exit. Closes pool. For use when keeping pool open across multiple calls.
"""
LOGGER.debug('NodePool.close >>>')
if not self.handle:
LOGGER.warning('Abstaining from closing pool %s: already closed', self.name)
else:... | python | {
"resource": ""
} |
q11008 | NodePool.refresh | train | async def refresh(self) -> None:
"""
Refresh local copy of pool ledger and update node pool connections.
"""
LOGGER.debug('NodePool.refresh >>>')
await pool.refresh_pool_ledger(self.handle)
LOGGER.debug('NodePool.refresh <<<') | python | {
"resource": ""
} |
q11009 | BaseAnchor.get_nym_role | train | async def get_nym_role(self, target_did: str = None) -> Role:
"""
Return the cryptonym role for input did from the ledger - note that this may exceed
the role of least privilege for the class.
Raise AbsentNym if current anchor has no cryptonym on the ledger, or WalletState if current DI... | python | {
"resource": ""
} |
q11010 | BaseAnchor.get_did_endpoint | train | async def get_did_endpoint(self, remote_did: str) -> EndpointInfo:
"""
Return endpoint info for remote DID.
Raise BadIdentifier for bad remote DID. Raise WalletState if bypassing cache but wallet is closed.
Raise AbsentRecord for no such endpoint.
:param remote_did: pairwise rem... | python | {
"resource": ""
} |
q11011 | BaseAnchor._verkey_for | train | async def _verkey_for(self, target: str) -> str:
"""
Given a DID, retrieve its verification key, looking in wallet, then pool.
Given a verification key or None, return input.
Raise WalletState if the wallet is closed. Given a recipient DID not in the wallet,
raise AbsentPool if ... | python | {
"resource": ""
} |
q11012 | BaseAnchor.encrypt | train | async def encrypt(self, message: bytes, authn: bool = False, recip: str = None) -> bytes:
"""
Encrypt plaintext for owner of DID or verification key, anonymously or via
authenticated encryption scheme. If given DID, first check wallet and then pool
for corresponding verification key.
... | python | {
"resource": ""
} |
q11013 | BaseAnchor.sign | train | async def sign(self, message: bytes) -> bytes:
"""
Sign message; return signature. Raise WalletState if wallet is closed.
:param message: Content to sign, as bytes
:return: signature, as bytes
"""
LOGGER.debug('BaseAnchor.sign >>> message: %s', message)
if not ... | python | {
"resource": ""
} |
q11014 | Service.to_dict | train | def to_dict(self):
"""
Return dict representation of service to embed in DID document.
"""
rv = {
'id': self.id,
'type': self.type,
'priority': self.priority
}
if self.recip_keys:
rv['routingKeys'] = [canon_ref(k.did, k.id,... | python | {
"resource": ""
} |
q11015 | HolderProver._assert_link_secret | train | async def _assert_link_secret(self, action: str) -> str:
"""
Return current wallet link secret label. Raise AbsentLinkSecret if link secret is not set.
:param action: action requiring link secret
"""
rv = await self.wallet.get_link_secret_label()
if rv is None:
... | python | {
"resource": ""
} |
q11016 | HolderProver.load_cache_for_proof | train | async def load_cache_for_proof(self, archive: bool = False) -> int:
"""
Load schema, cred def, revocation caches; optionally archive enough to go
offline and be able to generate proof on all credentials in wallet.
Return timestamp (epoch seconds) of cache load event, also used as subdir... | python | {
"resource": ""
} |
q11017 | HolderProver.get_cred_info_by_id | train | async def get_cred_info_by_id(self, cred_id: str) -> str:
"""
Return cred-info json from wallet by wallet credential identifier.
Raise AbsentCred for no such credential. Raise WalletState if the wallet is closed.
:param cred_id: credential identifier of interest
:return: json w... | python | {
"resource": ""
} |
q11018 | HolderProver.get_cred_briefs_by_proof_req_q | train | async def get_cred_briefs_by_proof_req_q(self, proof_req_json: str, x_queries_json: str = None) -> str:
"""
A cred-brief aggregates a cred-info and a non-revocation interval. A cred-brief-dict maps
wallet cred-ids to their corresponding cred-briefs.
Return json (cred-brief-dict) object ... | python | {
"resource": ""
} |
q11019 | SchemaCache.index | train | def index(self) -> dict:
"""
Return dict mapping content sequence numbers to schema keys.
:return: dict mapping sequence numbers to schema keys
"""
LOGGER.debug('SchemaCache.index >>>')
rv = self._seq_no2schema_key
LOGGER.debug('SchemaCache.index <<< %s', rv)
... | python | {
"resource": ""
} |
q11020 | SchemaCache.schema_key_for | train | def schema_key_for(self, seq_no: int) -> SchemaKey:
"""
Get schema key for schema by sequence number if known, None for no such schema in cache.
:param seq_no: sequence number
:return: corresponding schema key or None
"""
LOGGER.debug('SchemaCache.schema_key_for >>> seq... | python | {
"resource": ""
} |
q11021 | SchemaCache.schemata | train | def schemata(self) -> list:
"""
Return list with schemata in cache.
:return: list of schemata
"""
LOGGER.debug('SchemaCache.schemata >>>')
LOGGER.debug('SchemaCache.schemata <<<')
return [self._schema_key2schema[seq_no] for seq_no in self._schema_key2schema] | python | {
"resource": ""
} |
q11022 | RevoCacheEntry.get_delta_json | train | async def get_delta_json(
self,
rr_delta_builder: Callable[['HolderProver', str, int, int, dict], Awaitable[Tuple[str, int]]],
fro: int,
to: int) -> (str, int):
"""
Get rev reg delta json, and its timestamp on the distributed ledger,
from cached re... | python | {
"resource": ""
} |
q11023 | RevoCacheEntry.get_state_json | train | async def get_state_json(
self,
rr_state_builder: Callable[['Verifier', str, int], Awaitable[Tuple[str, int]]],
fro: int,
to: int) -> (str, int):
"""
Get rev reg state json, and its timestamp on the distributed ledger,
from cached rev reg state fra... | python | {
"resource": ""
} |
q11024 | ArchivableCaches.clear | train | def clear() -> None:
"""
Clear all archivable caches in memory.
"""
LOGGER.debug('clear >>>')
with SCHEMA_CACHE.lock:
SCHEMA_CACHE.clear()
with CRED_DEF_CACHE.lock:
CRED_DEF_CACHE.clear()
with REVO_CACHE.lock:
REVO_CACHE.clear... | python | {
"resource": ""
} |
q11025 | ArchivableCaches.archive | train | def archive(base_dir: str) -> int:
"""
Archive schema, cred def, revocation caches to disk as json.
:param base_dir: archive base directory
:return: timestamp (epoch seconds) used as subdirectory
"""
LOGGER.debug('archive >>> base_dir: %s', base_dir)
rv = int(t... | python | {
"resource": ""
} |
q11026 | storage_record2pairwise_info | train | def storage_record2pairwise_info(storec: StorageRecord) -> PairwiseInfo:
"""
Given indy-sdk non_secrets implementation of pairwise storage record dict, return corresponding PairwiseInfo.
:param storec: (non-secret) storage record to convert to PairwiseInfo
:return: PairwiseInfo on record DIDs, verkeys,... | python | {
"resource": ""
} |
q11027 | WalletManager._config2indy | train | def _config2indy(self, config: dict) -> dict:
"""
Given a configuration dict with indy and possibly more configuration values, return the
corresponding indy wallet configuration dict from current default and input values.
:param config: input configuration
:return: configuration... | python | {
"resource": ""
} |
q11028 | WalletManager._config2von | train | def _config2von(self, config: dict, access: str = None) -> dict:
"""
Given a configuration dict with indy and possibly more configuration values, return the
corresponding VON wallet configuration dict from current default and input values.
:param config: input configuration
:par... | python | {
"resource": ""
} |
q11029 | WalletManager.create | train | async def create(self, config: dict = None, access: str = None, replace: bool = False) -> Wallet:
"""
Create wallet on input name with given configuration and access credential value.
Raise ExtantWallet if wallet on input name exists already and replace parameter is False.
Raise BadAcce... | python | {
"resource": ""
} |
q11030 | WalletManager.get | train | def get(self, config: dict, access: str = None) -> Wallet:
"""
Instantiate and return VON anchor wallet object on given configuration, respecting wallet manager
default configuration values.
:param config: configuration data for both indy-sdk and VON anchor wallet:
- 'name'... | python | {
"resource": ""
} |
q11031 | WalletManager.export_wallet | train | async def export_wallet(self, von_wallet: Wallet, path: str) -> None:
"""
Export an existing VON anchor wallet. Raise WalletState if wallet is closed.
:param von_wallet: open wallet
:param path: path to which to export wallet
"""
LOGGER.debug('WalletManager.export_walle... | python | {
"resource": ""
} |
q11032 | WalletManager.import_wallet | train | async def import_wallet(self, indy_config: dict, path: str, access: str = None) -> None:
"""
Import a VON anchor wallet. Raise BadAccess on bad access credential value.
:param indy_config: indy wallet configuration to use, with:
- 'id'
- 'storage_type' (optional)
... | python | {
"resource": ""
} |
q11033 | WalletManager.remove | train | async def remove(self, von_wallet: Wallet) -> None:
"""
Remove serialized wallet if it exists. Raise WalletState if wallet is open.
:param von_wallet: (closed) wallet to remove
"""
LOGGER.debug('WalletManager.remove >>> wallet %s', von_wallet)
await von_wallet.remove()... | python | {
"resource": ""
} |
q11034 | WalletManager.register_storage_library | train | async def register_storage_library(storage_type: str, c_library: str, entry_point: str) -> None:
"""
Load a wallet storage plug-in.
An indy-sdk wallet storage plug-in is a shared library; relying parties must explicitly
load it before creating or opening a wallet with the plug-in.
... | python | {
"resource": ""
} |
q11035 | Wallet.create_signing_key | train | async def create_signing_key(self, seed: str = None, metadata: dict = None) -> KeyInfo:
"""
Create a new signing key pair.
Raise WalletState if wallet is closed, ExtantRecord if verification key already exists.
:param seed: optional seed allowing deterministic key creation
:par... | python | {
"resource": ""
} |
q11036 | Wallet.get_signing_key | train | async def get_signing_key(self, verkey: str) -> KeyInfo:
"""
Get signing key pair for input verification key.
Raise WalletState if wallet is closed, AbsentRecord for no such key pair.
:param verkey: verification key of key pair
:return: KeyInfo for key pair
"""
... | python | {
"resource": ""
} |
q11037 | Wallet.create_local_did | train | async def create_local_did(self, seed: str = None, loc_did: str = None, metadata: dict = None) -> DIDInfo:
"""
Create and store a new local DID for use in pairwise DID relations.
:param seed: seed from which to create (default random)
:param loc_did: local DID value (default None to let... | python | {
"resource": ""
} |
q11038 | Wallet.replace_local_did_metadata | train | async def replace_local_did_metadata(self, loc_did: str, metadata: dict) -> DIDInfo:
"""
Replace the metadata associated with a local DID.
Raise WalletState if wallet is closed, AbsentRecord for no such local DID.
:param loc_did: local DID of interest
:param metadata: new metad... | python | {
"resource": ""
} |
q11039 | Wallet.get_local_dids | train | async def get_local_dids(self) -> Sequence[DIDInfo]:
"""
Get list of DIDInfos for local DIDs.
:return: list of local DIDInfos
"""
LOGGER.debug('Wallet.get_local_dids >>>')
dids_with_meta = json.loads(did.list_my_dids_with_meta(self.handle)) # list
rv = []
... | python | {
"resource": ""
} |
q11040 | Wallet.get_local_did | train | async def get_local_did(self, loc: str) -> DIDInfo:
"""
Get local DID info by local DID or verification key.
Raise AbsentRecord for no such local DID.
:param loc: DID or verification key of interest
:return: DIDInfo for local DID
"""
LOGGER.debug('Wallet.get_loc... | python | {
"resource": ""
} |
q11041 | Wallet.get_anchor_did | train | async def get_anchor_did(self) -> str:
"""
Get current anchor DID by metadata, None for not yet set.
:return: DID
"""
LOGGER.debug('Wallet.get_anchor_did >>>')
if not self.handle:
LOGGER.debug('Wallet.get_anchor_did <!< Wallet %s is closed', self.name)
... | python | {
"resource": ""
} |
q11042 | Wallet._write_link_secret_label | train | async def _write_link_secret_label(self, label) -> None:
"""
Update non-secret storage record with link secret label.
:param label: link secret label
"""
LOGGER.debug('Wallet._write_link_secret_label <<< %s', label)
if await self.get_link_secret_label() == label:
... | python | {
"resource": ""
} |
q11043 | Wallet.get_link_secret_label | train | async def get_link_secret_label(self) -> str:
"""
Get current link secret label from non-secret storage records; return None for no match.
:return: latest non-secret storage record for link secret label
"""
LOGGER.debug('Wallet.get_link_secret_label >>>')
if not self.h... | python | {
"resource": ""
} |
q11044 | Wallet.create | train | async def create(self) -> None:
"""
Persist the wallet. Raise ExtantWallet if it already exists.
Actuators should prefer WalletManager.create() to calling this method directly - the wallet manager
filters wallet configuration through preset defaults.
"""
LOGGER.debug('W... | python | {
"resource": ""
} |
q11045 | Wallet.write_pairwise | train | async def write_pairwise(
self,
their_did: str,
their_verkey: str = None,
my_did: str = None,
metadata: dict = None,
replace_meta: bool = False) -> PairwiseInfo:
"""
Store a pairwise DID for a secure connection. Use verification key... | python | {
"resource": ""
} |
q11046 | Wallet.delete_pairwise | train | async def delete_pairwise(self, their_did: str) -> None:
"""
Remove a pairwise DID record by its remote DID. Silently return if no such record is present.
Raise WalletState for closed wallet, or BadIdentifier for invalid pairwise DID.
:param their_did: remote DID marking pairwise DID to... | python | {
"resource": ""
} |
q11047 | Wallet.get_pairwise | train | async def get_pairwise(self, pairwise_filt: str = None) -> dict:
"""
Return dict mapping each pairwise DID of interest in wallet to its pairwise info, or,
for no filter specified, mapping them all. If wallet has no such item, return empty dict.
:param pairwise_filt: remote DID of intere... | python | {
"resource": ""
} |
q11048 | Wallet.write_non_secret | train | async def write_non_secret(self, storec: StorageRecord, replace_meta: bool = False) -> StorageRecord:
"""
Add or update non-secret storage record to the wallet; return resulting wallet non-secret record.
:param storec: non-secret storage record
:param replace_meta: whether to replace an... | python | {
"resource": ""
} |
q11049 | Wallet.delete_non_secret | train | async def delete_non_secret(self, typ: str, ident: str) -> None:
"""
Remove a non-secret record by its type and identifier. Silently return if no such record is present.
Raise WalletState for closed wallet.
:param typ: non-secret storage record type
:param ident: non-secret stor... | python | {
"resource": ""
} |
q11050 | Wallet.get_non_secret | train | async def get_non_secret(
self,
typ: str,
filt: Union[dict, str] = None,
canon_wql: Callable[[dict], dict] = None,
limit: int = None) -> dict:
"""
Return dict mapping each non-secret storage record of interest by identifier or,
for no f... | python | {
"resource": ""
} |
q11051 | Wallet.encrypt | train | async def encrypt(
self,
message: bytes,
authn: bool = False,
to_verkey: str = None,
from_verkey: str = None) -> bytes:
"""
Encrypt plaintext for owner of DID, anonymously or via authenticated encryption scheme.
Raise AbsentMessage for ... | python | {
"resource": ""
} |
q11052 | Wallet.sign | train | async def sign(self, message: bytes, verkey: str = None) -> bytes:
"""
Derive signing key and Sign message; return signature. Raise WalletState if wallet is closed.
Raise AbsentMessage for missing message, or WalletState if wallet is closed.
:param message: Content to sign, as bytes
... | python | {
"resource": ""
} |
q11053 | Wallet.unpack | train | async def unpack(self, ciphertext: bytes) -> (str, str, str):
"""
Unpack a message. Return triple with cleartext, sender verification key, and recipient verification key.
Raise AbsentMessage for missing ciphertext, or WalletState if wallet is closed. Raise AbsentRecord
if wallet has no k... | python | {
"resource": ""
} |
q11054 | Wallet.reseed_apply | train | async def reseed_apply(self) -> DIDInfo:
"""
Replace verification key with new verification key from reseed operation.
Raise WalletState if wallet is closed.
:return: DIDInfo with new verification key and metadata for DID
"""
LOGGER.debug('Wallet.reseed_apply >>>')
... | python | {
"resource": ""
} |
q11055 | Origin.send_schema | train | async def send_schema(self, schema_data_json: str) -> str:
"""
Send schema to ledger, then retrieve it as written to the ledger and return it.
Raise BadLedgerTxn on failure. Raise BadAttribute for attribute name with spaces or
reserved for indy-sdk.
If schema already exists on l... | python | {
"resource": ""
} |
q11056 | NominalAnchor.least_role | train | def least_role() -> Role:
"""
Return the indy-sdk null role for a tails sync anchor, which does not need write access.
:return: USER role
"""
LOGGER.debug('NominalAnchor.least_role >>>')
rv = Role.USER
LOGGER.debug('NominalAnchor.least_role <<< %s', rv)
... | python | {
"resource": ""
} |
q11057 | parse_requirements | train | def parse_requirements(filename):
"""
Load requirements from a pip requirements file.
:param filename: file name with requirements to parse
"""
try:
with open(filename) as fh_req:
return [line.strip() for line in fh_req if line.strip() and not line.startswith('#')]
except F... | python | {
"resource": ""
} |
q11058 | NodePoolManager.list | train | async def list(self) -> List[str]:
"""
Return list of pool names configured, empty list for none.
:return: list of pool names.
"""
LOGGER.debug('NodePoolManager.list >>>')
rv = [p['pool'] for p in await pool.list_pools()]
LOGGER.debug('NodePoolManager.list <<<... | python | {
"resource": ""
} |
q11059 | NodePoolManager.get | train | def get(self, name: str, config: dict = None) -> NodePool:
"""
Return node pool in input name and optional configuration.
:param name: name of configured pool
:param config: pool configuration with optional 'timeout' int, 'extended_timeout' int,
'preordered_nodes' array of s... | python | {
"resource": ""
} |
q11060 | NodePoolManager.remove | train | async def remove(self, name: str) -> None:
"""
Remove serialized pool info if it exists. Abstain from removing open node pool.
"""
LOGGER.debug('NodePoolManager.remove >>> name: %s', name)
try:
await pool.delete_pool_ledger_config(name)
except IndyError as x... | python | {
"resource": ""
} |
q11061 | DIDDoc.authnkey | train | def authnkey(self) -> dict:
"""
Accessor for public keys marked as authentication keys, by identifier.
"""
return {k: self._pubkey[k] for k in self._pubkey if self._pubkey[k].authn} | python | {
"resource": ""
} |
q11062 | DIDDoc.set | train | def set(self, item: Union[Service, PublicKey]) -> 'DIDDoc':
"""
Add or replace service or public key; return current DIDDoc.
Raise BadDIDDocItem if input item is neither service nor public key.
:param item: service or public key to set
:return: current DIDDoc
"""
... | python | {
"resource": ""
} |
q11063 | DIDDoc.serialize | train | def serialize(self) -> str:
"""
Dump current object to a JSON-compatible dictionary.
:return: dict representation of current DIDDoc
"""
return {
'@context': DIDDoc.CONTEXT,
'id': canon_ref(self.did, self.did),
'publicKey': [pubkey.to_dict() f... | python | {
"resource": ""
} |
q11064 | DIDDoc.add_service_pubkeys | train | def add_service_pubkeys(self, service: dict, tags: Union[Sequence[str], str]) -> List[PublicKey]:
"""
Add public keys specified in service. Return public keys so discovered.
Raise AbsentDIDDocItem for public key reference not present in DID document.
:param service: service from DID do... | python | {
"resource": ""
} |
q11065 | DIDDoc.deserialize | train | def deserialize(cls, did_doc: dict) -> 'DIDDoc':
"""
Construct DIDDoc object from dict representation.
Raise BadIdentifier for bad DID.
:param did_doc: DIDDoc dict reprentation.
:return: DIDDoc from input json.
"""
rv = None
if 'id' in did_doc:
... | python | {
"resource": ""
} |
q11066 | Protocol.txn_data2schema_key | train | def txn_data2schema_key(self, txn: dict) -> SchemaKey:
"""
Return schema key from ledger transaction data.
:param txn: get-schema transaction (by sequence number)
:return: schema key identified
"""
rv = None
if self == Protocol.V_13:
rv = SchemaKey(t... | python | {
"resource": ""
} |
q11067 | Protocol.txn2data | train | def txn2data(self, txn: dict) -> str:
"""
Given ledger transaction, return its data json.
:param txn: transaction as dict
:return: transaction data json
"""
rv_json = json.dumps({})
if self == Protocol.V_13:
rv_json = json.dumps(txn['result'].get('da... | python | {
"resource": ""
} |
q11068 | Protocol.txn2epoch | train | def txn2epoch(self, txn: dict) -> int:
"""
Given ledger transaction, return its epoch time.
:param txn: transaction as dict
:return: transaction time
"""
rv = None
if self == Protocol.V_13:
rv = txn['result']['txnTime']
else:
rv =... | python | {
"resource": ""
} |
q11069 | Protocol.genesis_host_port | train | def genesis_host_port(self, genesis_txn: dict) -> tuple:
"""
Given a genesis transaction, return its node host and port.
:param genesis_txn: genesis transaction as dict
:return: node host and port
"""
txn_data = genesis_txn['data'] if self == Protocol.V_13 else genesis_... | python | {
"resource": ""
} |
q11070 | Tails.open | train | async def open(self) -> 'Tails':
"""
Open reader handle and return current object.
:return: current object
"""
LOGGER.debug('Tails.open >>>')
self._reader_handle = await blob_storage.open_reader('default', self._tails_config_json)
LOGGER.debug('Tails.open <<<'... | python | {
"resource": ""
} |
q11071 | Tails.ok_hash | train | def ok_hash(token: str) -> bool:
"""
Whether input token looks like a valid tails hash.
:param token: candidate string
:return: whether input token looks like a valid tails hash
"""
LOGGER.debug('Tails.ok_hash >>> token: %s', token)
rv = re.match('[{}]{{42,44}}... | python | {
"resource": ""
} |
q11072 | Predicate.get | train | def get(relation: str) -> 'Predicate':
"""
Return enum instance corresponding to input relation string
"""
for pred in Predicate:
if relation.upper() in (pred.value.fortran, pred.value.wql.upper(), pred.value.math):
return pred
return None | python | {
"resource": ""
} |
q11073 | Predicate.to_int | train | def to_int(value: Any) -> int:
"""
Cast a value as its equivalent int for indy predicate argument. Raise ValueError for any input but
int, stringified int, or boolean.
:param value: value to coerce.
"""
if isinstance(value, (bool, int)):
return int(value)
... | python | {
"resource": ""
} |
q11074 | Role.get | train | def get(token: Union[str, int] = None) -> 'Role':
"""
Return enum instance corresponding to input token.
:param token: token identifying role to indy-sdk: 'STEWARD', 'TRUSTEE', 'TRUST_ANCHOR', '' or None
:return: enum instance corresponding to input token
"""
if token i... | python | {
"resource": ""
} |
q11075 | Role.token | train | def token(self) -> str:
"""
Return token identifying role to indy-sdk.
:return: token: 'STEWARD', 'TRUSTEE', 'TRUST_ANCHOR', or None (for USER)
"""
return self.value[0] if self in (Role.USER, Role.ROLE_REMOVE) else self.name | python | {
"resource": ""
} |
q11076 | cached_get | train | def cached_get(timeout, *params):
"""Decorator applied specifically to a view's get method"""
def decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(view_or_request, *args, **kwargs):
# The type of the request gets muddled when using a fu... | python | {
"resource": ""
} |
q11077 | ultracache | train | def ultracache(timeout, *params):
"""Decorator applied to a view class. The get method is decorated
implicitly."""
def decorator(cls):
class WrappedClass(cls):
def __init__(self, *args, **kwargs):
super(WrappedClass, self).__init__(*args, **kwargs)
@cached_g... | python | {
"resource": ""
} |
q11078 | Issuer._send_rev_reg_def | train | async def _send_rev_reg_def(self, rr_id: str) -> None:
"""
Move tails file from hopper; deserialize revocation registry definition and initial entry;
send to ledger and cache revocation registry definition.
Operation serializes to subdirectory within tails hopper directory; symbolic
... | python | {
"resource": ""
} |
q11079 | Issuer._set_rev_reg | train | async def _set_rev_reg(self, rr_id: str, rr_size: int) -> None:
"""
Move precomputed revocation registry data from hopper into place within tails directory.
:param rr_id: revocation registry identifier
:param rr_size: revocation registry size, in case creation required
"""
... | python | {
"resource": ""
} |
q11080 | Issuer._sync_revoc_for_issue | train | async def _sync_revoc_for_issue(self, rr_id: str, rr_size: int = None) -> None:
"""
Create revocation registry if need be for input revocation registry identifier;
open and cache tails file reader.
:param rr_id: revocation registry identifier
:param rr_size: if new revocation re... | python | {
"resource": ""
} |
q11081 | canon_ref | train | def canon_ref(did: str, ref: str, delimiter: str = None):
"""
Given a reference in a DID document, return it in its canonical form of a URI.
:param did: DID acting as the identifier of the DID document
:param ref: reference to canonicalize, either a DID or a fragment pointing to a location in the DID d... | python | {
"resource": ""
} |
q11082 | _get_pwned | train | def _get_pwned(prefix):
"""
Fetches a dict of all hash suffixes from Pwned Passwords for a
given SHA-1 prefix.
"""
try:
response = requests.get(
url=API_ENDPOINT.format(prefix),
headers={'User-Agent': USER_AGENT},
timeout=getattr(
settings... | python | {
"resource": ""
} |
q11083 | pwned_password | train | def pwned_password(password):
"""
Checks a password against the Pwned Passwords database.
"""
if not isinstance(password, text_type):
raise TypeError('Password values to check must be Unicode strings.')
password_hash = hashlib.sha1(password.encode('utf-8')).hexdigest().upper()
prefix, s... | python | {
"resource": ""
} |
q11084 | Optimizer.add_regularizer | train | def add_regularizer(self, proxfun, **kwargs):
"""
Add a regularizer from the operators module to the list of objectives
Parameters
----------
proxfun : string or function
If a string, then it must be the name of a corresponding function in the `operators` module.
... | python | {
"resource": ""
} |
q11085 | Optimizer.set_regularizers | train | def set_regularizers(self, regularizers, clear=True):
"""
Adds a set of regularizers
Parameters
----------
regularizers : dict
Each key is the name of a corresponding proximal operator, and the
value associated with that key is a set of keyword arguments
... | python | {
"resource": ""
} |
q11086 | Optimizer.minimize | train | def minimize(self, theta_init, max_iter=50, callback=None, disp=0, tau=(10., 2., 2.), tol=1e-3):
"""
Minimize a list of objectives using a proximal consensus algorithm
Parameters
----------
theta_init : ndarray
Initial parameter vector (numpy array)
max_iter... | python | {
"resource": ""
} |
q11087 | Optimizer.update_display | train | def update_display(self, iteration, disp_level, col_width=12): # pragma: no cover
"""
Prints information about the optimization procedure to standard output
Parameters
----------
iteration : int
The current iteration. Must either a positive integer or -1, which indi... | python | {
"resource": ""
} |
q11088 | susvd | train | def susvd(x, x_obs, rho, penalties):
"""
Sequential unfolding SVD
Parameters
----------
x : Tensor
x_obs : array_like
rho : float
penalties : array_like
penalty for each unfolding of the input tensor
"""
assert type(x) == Tensor, "Input array must be a Tensor"
w... | python | {
"resource": ""
} |
q11089 | Construct.build | train | def build(self, obj, context=None) -> bytes:
"""
Build bytes from the python object.
:param obj: Python object to build bytes from.
:param context: Optional context dictionary.
"""
stream = BytesIO()
self.build_stream(obj, stream, context)
return stream.g... | python | {
"resource": ""
} |
q11090 | Construct.parse | train | def parse(self, data: bytes, context=None):
"""
Parse some python object from the data.
:param data: Data to be parsed.
:param context: Optional context dictionary.
"""
stream = BytesIO(data)
return self.parse_stream(stream, context) | python | {
"resource": ""
} |
q11091 | Construct.build_stream | train | def build_stream(self, obj, stream: BytesIO, context=None) -> None:
"""
Build bytes from the python object into the stream.
:param obj: Python object to build bytes from.
:param stream: A ``io.BytesIO`` instance to write bytes into.
:param context: Optional context dictionary.
... | python | {
"resource": ""
} |
q11092 | Construct.parse_stream | train | def parse_stream(self, stream: BytesIO, context=None):
"""
Parse some python object from the stream.
:param stream: Stream from which the data is read and parsed.
:param context: Optional context dictionary.
"""
if context is None:
context = Context()
... | python | {
"resource": ""
} |
q11093 | Construct.sizeof | train | def sizeof(self, context=None) -> int:
"""
Return the size of the construct in bytes.
:param context: Optional context dictionary.
"""
if context is None:
context = Context()
if not isinstance(context, Context):
context = Context(context)
... | python | {
"resource": ""
} |
q11094 | poissreg | train | def poissreg(x0, rho, x, y):
"""
Proximal operator for Poisson regression
Computes the proximal operator of the negative log-likelihood loss assumping a Poisson noise distribution.
Parameters
----------
x0 : array_like
The starting or initial point used in the proximal update step
... | python | {
"resource": ""
} |
q11095 | bfgs | train | def bfgs(x0, rho, f_df, maxiter=50, method='BFGS'):
"""
Proximal operator for minimizing an arbitrary function using BFGS
Uses the BFGS algorithm to find the proximal update for an arbitrary function, `f`, whose gradient is known.
Parameters
----------
x0 : array_like
The starting or i... | python | {
"resource": ""
} |
q11096 | smooth | train | def smooth(x0, rho, gamma, axis=0):
"""
Proximal operator for a smoothing function enforced via the discrete laplacian operator
Notes
-----
Currently only works with matrices (2-D arrays) as input
Parameters
----------
x0 : array_like
The starting or initial point used in the p... | python | {
"resource": ""
} |
q11097 | tvd | train | def tvd(x0, rho, gamma):
"""
Proximal operator for the total variation denoising penalty
Requires scikit-image be installed
Parameters
----------
x0 : array_like
The starting or initial point used in the proximal update step
rho : float
Momentum parameter for the proximal ... | python | {
"resource": ""
} |
q11098 | linsys | train | def linsys(x0, rho, P, q):
"""
Proximal operator for the linear approximation Ax = b
Minimizes the function:
.. math:: f(x) = (1/2)||Ax-b||_2^2 = (1/2)x^TA^TAx - (b^TA)x + b^Tb
Parameters
----------
x0 : array_like
The starting or initial point used in the proximal update step
... | python | {
"resource": ""
} |
q11099 | StatusCodeAssertionsMixin.assert_redirect | train | def assert_redirect(self, response, expected_url=None):
"""
assertRedirects from Django TestCase follows the redirects chains,
this assertion does not - which is more like real unit testing
"""
self.assertIn(
response.status_code,
self.redirect_codes,
... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.