repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/manager.py
NodePoolManager.get
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
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...
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 strings :return: node pool
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/manager.py#L120-L135
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/manager.py
NodePoolManager.remove
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
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...
Remove serialized pool info if it exists. Abstain from removing open node pool.
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/manager.py#L137-L149
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/diddoc.py
DIDDoc.authnkey
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
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}
Accessor for public keys marked as authentication keys, by identifier.
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/diddoc.py#L81-L86
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/diddoc.py
DIDDoc.set
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
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 """ ...
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
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/diddoc.py#L96-L111
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/diddoc.py
DIDDoc.serialize
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
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...
Dump current object to a JSON-compatible dictionary. :return: dict representation of current DIDDoc
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/diddoc.py#L113-L129
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/diddoc.py
DIDDoc.add_service_pubkeys
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
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...
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 document :param tags: potential tags marking public keys of type of interest - the standard is still coalescing ...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/diddoc.py#L140-L182
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/diddoc.py
DIDDoc.deserialize
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
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: ...
Construct DIDDoc object from dict representation. Raise BadIdentifier for bad DID. :param did_doc: DIDDoc dict reprentation. :return: DIDDoc from input json.
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/diddoc.py#L185-L252
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.get
def get(version: str) -> 'Protocol': """ Return enum instance corresponding to input version value ('1.6' etc.) """ return Protocol.V_13 if version == Protocol.V_13.value.name else Protocol.DEFAULT
python
def get(version: str) -> 'Protocol': """ Return enum instance corresponding to input version value ('1.6' etc.) """ return Protocol.V_13 if version == Protocol.V_13.value.name else Protocol.DEFAULT
Return enum instance corresponding to input version value ('1.6' etc.)
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L43-L48
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.cd_id_tag
def cd_id_tag(self, for_box_id: bool = False) -> str: """ Return (place-holder) credential definition identifier tag for current version of node protocol. At present, von_anchor always uses the tag of 'tag' if the protocol calls for one. :param for_box_id: whether to prefix a colon, if ...
python
def cd_id_tag(self, for_box_id: bool = False) -> str: """ Return (place-holder) credential definition identifier tag for current version of node protocol. At present, von_anchor always uses the tag of 'tag' if the protocol calls for one. :param for_box_id: whether to prefix a colon, if ...
Return (place-holder) credential definition identifier tag for current version of node protocol. At present, von_anchor always uses the tag of 'tag' if the protocol calls for one. :param for_box_id: whether to prefix a colon, if current protocol uses one, in constructing a cred def id or re...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L62-L74
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.cred_def_id
def cred_def_id(self, issuer_did: str, schema_seq_no: int) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. :param issuer_did: DID of credential definition issuer :param schema_seq_no: schema sequence number :return: credential...
python
def cred_def_id(self, issuer_did: str, schema_seq_no: int) -> str: """ Return credential definition identifier for input issuer DID and schema sequence number. :param issuer_did: DID of credential definition issuer :param schema_seq_no: schema sequence number :return: credential...
Return credential definition identifier for input issuer DID and schema sequence number. :param issuer_did: DID of credential definition issuer :param schema_seq_no: schema sequence number :return: credential definition identifier
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L76-L88
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.txn_data2schema_key
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
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...
Return schema key from ledger transaction data. :param txn: get-schema transaction (by sequence number) :return: schema key identified
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L90-L108
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.txn2data
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
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...
Given ledger transaction, return its data json. :param txn: transaction as dict :return: transaction data json
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L110-L124
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.txn2epoch
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
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 =...
Given ledger transaction, return its epoch time. :param txn: transaction as dict :return: transaction time
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L126-L140
PSPC-SPAC-buyandsell/von_anchor
von_anchor/nodepool/protocol.py
Protocol.genesis_host_port
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
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_...
Given a genesis transaction, return its node host and port. :param genesis_txn: genesis transaction as dict :return: node host and port
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/nodepool/protocol.py#L142-L151
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.open
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
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 <<<'...
Open reader handle and return current object. :return: current object
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L97-L109
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.ok_hash
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
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}}...
Whether input token looks like a valid tails hash. :param token: candidate string :return: whether input token looks like a valid tails hash
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L112-L124
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.associate
def associate(base_dir: str, rr_id: str, tails_hash: str) -> None: """ Create symbolic link to tails file named tails_hash for rev reg id rr_id. :param rr_id: rev reg id :param tails_hash: hash of tails file, serving as file name """ LOGGER.debug('Tails.associate >>> ba...
python
def associate(base_dir: str, rr_id: str, tails_hash: str) -> None: """ Create symbolic link to tails file named tails_hash for rev reg id rr_id. :param rr_id: rev reg id :param tails_hash: hash of tails file, serving as file name """ LOGGER.debug('Tails.associate >>> ba...
Create symbolic link to tails file named tails_hash for rev reg id rr_id. :param rr_id: rev reg id :param tails_hash: hash of tails file, serving as file name
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L127-L153
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.dir
def dir(base_dir: str, rr_id: str) -> str: """ Return correct subdirectory of input base dir for artifacts corresponding to input rev reg id. :param base_dir: base directory for tails files, thereafter split by cred def id :param rr_id: rev reg id """ LOGGER.debug('Tail...
python
def dir(base_dir: str, rr_id: str) -> str: """ Return correct subdirectory of input base dir for artifacts corresponding to input rev reg id. :param base_dir: base directory for tails files, thereafter split by cred def id :param rr_id: rev reg id """ LOGGER.debug('Tail...
Return correct subdirectory of input base dir for artifacts corresponding to input rev reg id. :param base_dir: base directory for tails files, thereafter split by cred def id :param rr_id: rev reg id
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L156-L172
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.linked
def linked(base_dir: str, rr_id: str) -> str: """ Get, from the specified directory, the path to the tails file associated with the input revocation registry identifier, or None for no such file. :param base_dir: base directory for tails files, thereafter split by cred def id :p...
python
def linked(base_dir: str, rr_id: str) -> str: """ Get, from the specified directory, the path to the tails file associated with the input revocation registry identifier, or None for no such file. :param base_dir: base directory for tails files, thereafter split by cred def id :p...
Get, from the specified directory, the path to the tails file associated with the input revocation registry identifier, or None for no such file. :param base_dir: base directory for tails files, thereafter split by cred def id :param rr_id: rev reg id :return: (stringified) path to tail...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L175-L196
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.links
def links(base_dir: str, issuer_did: str = None) -> set: """ Return set of all paths to symbolic links (rev reg ids) associating their respective tails files, in specified base tails directory recursively (omitting the .hopper subdirectory), on input issuer DID if specified. :pa...
python
def links(base_dir: str, issuer_did: str = None) -> set: """ Return set of all paths to symbolic links (rev reg ids) associating their respective tails files, in specified base tails directory recursively (omitting the .hopper subdirectory), on input issuer DID if specified. :pa...
Return set of all paths to symbolic links (rev reg ids) associating their respective tails files, in specified base tails directory recursively (omitting the .hopper subdirectory), on input issuer DID if specified. :param base_dir: base directory for tails files, thereafter split by cred def id...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L199-L224
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.unlinked
def unlinked(base_dir: str) -> set: """ Return all paths to tails files, in specified tails base directory recursively (omitting the .hopper subdirectory), without symbolic links associating revocation registry identifiers. At an Issuer, tails files should not persist long witho...
python
def unlinked(base_dir: str) -> set: """ Return all paths to tails files, in specified tails base directory recursively (omitting the .hopper subdirectory), without symbolic links associating revocation registry identifiers. At an Issuer, tails files should not persist long witho...
Return all paths to tails files, in specified tails base directory recursively (omitting the .hopper subdirectory), without symbolic links associating revocation registry identifiers. At an Issuer, tails files should not persist long without revocation registry identifier association vi...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L227-L253
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.next_tag
def next_tag(base_dir: str, cd_id: str) -> (str, int): """ Return the next tag name available for a new rev reg id on input cred def id in base directory, and suggested size of associated rev reg. :param base_dir: base directory for tails files, thereafter split by cred def id :...
python
def next_tag(base_dir: str, cd_id: str) -> (str, int): """ Return the next tag name available for a new rev reg id on input cred def id in base directory, and suggested size of associated rev reg. :param base_dir: base directory for tails files, thereafter split by cred def id :...
Return the next tag name available for a new rev reg id on input cred def id in base directory, and suggested size of associated rev reg. :param base_dir: base directory for tails files, thereafter split by cred def id :param cd_id: credential definition identifier of interest :return: ...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L256-L279
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.current_rev_reg_id
def current_rev_reg_id(base_dir: str, cd_id: str) -> str: """ Return the current revocation registry identifier for input credential definition identifier, in input directory. Raise AbsentTails if no corresponding tails file, signifying no such revocation registry defined. :par...
python
def current_rev_reg_id(base_dir: str, cd_id: str) -> str: """ Return the current revocation registry identifier for input credential definition identifier, in input directory. Raise AbsentTails if no corresponding tails file, signifying no such revocation registry defined. :par...
Return the current revocation registry identifier for input credential definition identifier, in input directory. Raise AbsentTails if no corresponding tails file, signifying no such revocation registry defined. :param base_dir: base directory for tails files, thereafter split by cred def id ...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L282-L307
PSPC-SPAC-buyandsell/von_anchor
von_anchor/tails.py
Tails.path
def path(self) -> str: """ Accessor for (stringified) path to current tails file. :return: (stringified) path to current tails file. """ config = json.loads(self._tails_config_json) return join(config['base_dir'], config['file'])
python
def path(self) -> str: """ Accessor for (stringified) path to current tails file. :return: (stringified) path to current tails file. """ config = json.loads(self._tails_config_json) return join(config['base_dir'], config['file'])
Accessor for (stringified) path to current tails file. :return: (stringified) path to current tails file.
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/tails.py#L331-L339
PSPC-SPAC-buyandsell/von_anchor
von_anchor/indytween.py
encode
def encode(orig: Any) -> str: """ Encode credential attribute value, purely stringifying any int32 and leaving numeric int32 strings alone, but mapping any other input to a stringified 256-bit (but not 32-bit) integer. Predicates in indy-sdk operate on int32 values properly only when their encoded value...
python
def encode(orig: Any) -> str: """ Encode credential attribute value, purely stringifying any int32 and leaving numeric int32 strings alone, but mapping any other input to a stringified 256-bit (but not 32-bit) integer. Predicates in indy-sdk operate on int32 values properly only when their encoded value...
Encode credential attribute value, purely stringifying any int32 and leaving numeric int32 strings alone, but mapping any other input to a stringified 256-bit (but not 32-bit) integer. Predicates in indy-sdk operate on int32 values properly only when their encoded values match their raw values. :param orig...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/indytween.py#L32-L56
PSPC-SPAC-buyandsell/von_anchor
von_anchor/indytween.py
Predicate.get
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
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
Return enum instance corresponding to input relation string
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/indytween.py#L100-L108
PSPC-SPAC-buyandsell/von_anchor
von_anchor/indytween.py
Predicate.to_int
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
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) ...
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.
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/indytween.py#L111-L121
PSPC-SPAC-buyandsell/von_anchor
von_anchor/indytween.py
Role.get
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
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...
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
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/indytween.py#L136-L155
PSPC-SPAC-buyandsell/von_anchor
von_anchor/indytween.py
Role.token
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
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
Return token identifying role to indy-sdk. :return: token: 'STEWARD', 'TRUSTEE', 'TRUST_ANCHOR', or None (for USER)
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/indytween.py#L167-L174
praekelt/django-ultracache
ultracache/decorators.py
cached_get
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
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...
Decorator applied specifically to a view's get method
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/decorators.py#L16-L101
praekelt/django-ultracache
ultracache/decorators.py
ultracache
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
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...
Decorator applied to a view class. The get method is decorated implicitly.
https://github.com/praekelt/django-ultracache/blob/8898f10e50fc8f8d0a4cb7d3fe4d945bf257bd9f/ultracache/decorators.py#L104-L118
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.open
async def open(self) -> 'Issuer': """ Explicit entry. Perform ancestor opening operations, then synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Issuer.open >>>') await super().open() for path_rr_id in Tai...
python
async def open(self) -> 'Issuer': """ Explicit entry. Perform ancestor opening operations, then synchronize revocation registry to tails tree content. :return: current object """ LOGGER.debug('Issuer.open >>>') await super().open() for path_rr_id in Tai...
Explicit entry. Perform ancestor opening operations, then synchronize revocation registry to tails tree content. :return: current object
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L111-L126
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer._send_rev_reg_def
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
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 ...
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 link presence signals completion. Raise AbsentRevReg if revoc...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L128-L193
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer._set_rev_reg
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
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 """ ...
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
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L195-L217
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer._sync_revoc_for_issue
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
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...
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 registry necessary, its size (default as per RevRegBuilder.create_rev_reg())
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L219-L266
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.path_tails
def path_tails(self, rr_id: str) -> str: """ Return path to tails file for input revocation registry identifier. :param rr_id: revocation registry identifier of interest :return: path to tails file for input revocation registry identifier """ LOGGER.debug('Issuer.path_t...
python
def path_tails(self, rr_id: str) -> str: """ Return path to tails file for input revocation registry identifier. :param rr_id: revocation registry identifier of interest :return: path to tails file for input revocation registry identifier """ LOGGER.debug('Issuer.path_t...
Return path to tails file for input revocation registry identifier. :param rr_id: revocation registry identifier of interest :return: path to tails file for input revocation registry identifier
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L268-L284
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer._create_cred_def
async def _create_cred_def(self, schema: dict, ledger_cred_def: dict, revo: bool) -> (str, bool): """ Create credential definition in wallet as part of the send_cred_def() sequence. Return whether the private key for the cred def is OK to continue with the sequence, propagating the cred ...
python
async def _create_cred_def(self, schema: dict, ledger_cred_def: dict, revo: bool) -> (str, bool): """ Create credential definition in wallet as part of the send_cred_def() sequence. Return whether the private key for the cred def is OK to continue with the sequence, propagating the cred ...
Create credential definition in wallet as part of the send_cred_def() sequence. Return whether the private key for the cred def is OK to continue with the sequence, propagating the cred def and revocation registry info to the ledger. :param schema: schema on which to create cred def :pa...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L286-L342
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.send_cred_def
async def send_cred_def(self, s_id: str, revo: bool = True, rr_size: int = None) -> str: """ Create a credential definition as Issuer, store it in its wallet, and send it to the ledger. Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure to send cred...
python
async def send_cred_def(self, s_id: str, revo: bool = True, rr_size: int = None) -> str: """ Create a credential definition as Issuer, store it in its wallet, and send it to the ledger. Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure to send cred...
Create a credential definition as Issuer, store it in its wallet, and send it to the ledger. Raise CorruptWallet for wallet not pertaining to current ledger, BadLedgerTxn on failure to send credential definition to ledger if need be, WalletState for closed wallet, or IndyError for any other fai...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L344-L422
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.create_cred_offer
async def create_cred_offer(self, schema_seq_no: int) -> str: """ Create credential offer as Issuer for given schema. Raise CorruptWallet if the wallet has no private key for the corresponding credential definition. Raise WalletState for closed wallet. :param schema_seq_no: sch...
python
async def create_cred_offer(self, schema_seq_no: int) -> str: """ Create credential offer as Issuer for given schema. Raise CorruptWallet if the wallet has no private key for the corresponding credential definition. Raise WalletState for closed wallet. :param schema_seq_no: sch...
Create credential offer as Issuer for given schema. Raise CorruptWallet if the wallet has no private key for the corresponding credential definition. Raise WalletState for closed wallet. :param schema_seq_no: schema sequence number :return: credential offer json for use in storing cred...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L424-L462
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.create_cred
async def create_cred( self, cred_offer_json, cred_req_json: str, cred_attrs: dict, rr_size: int = None) -> (str, str): """ Create credential as Issuer out of credential request and dict of key:value (raw, unencoded) entries for attribu...
python
async def create_cred( self, cred_offer_json, cred_req_json: str, cred_attrs: dict, rr_size: int = None) -> (str, str): """ Create credential as Issuer out of credential request and dict of key:value (raw, unencoded) entries for attribu...
Create credential as Issuer out of credential request and dict of key:value (raw, unencoded) entries for attributes. Return credential json, and if cred def supports revocation, credential revocation identifier. Raise WalletState for closed wallet. If the credential definition supports...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L464-L566
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.revoke_cred
async def revoke_cred(self, rr_id: str, cr_id) -> int: """ Revoke credential that input revocation registry identifier and credential revocation identifier specify. Return (epoch seconds) time of revocation. Raise AbsentTails if no tails file is available for input revocation r...
python
async def revoke_cred(self, rr_id: str, cr_id) -> int: """ Revoke credential that input revocation registry identifier and credential revocation identifier specify. Return (epoch seconds) time of revocation. Raise AbsentTails if no tails file is available for input revocation r...
Revoke credential that input revocation registry identifier and credential revocation identifier specify. Return (epoch seconds) time of revocation. Raise AbsentTails if no tails file is available for input revocation registry identifier. Raise WalletState for closed wallet. Ra...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L568-L622
PSPC-SPAC-buyandsell/von_anchor
von_anchor/anchor/issuer.py
Issuer.get_box_ids_issued
async def get_box_ids_issued(self) -> str: """ Return json object on lists of all unique box identifiers (schema identifiers, credential definition identifiers, and revocation registry identifiers) for all credential definitions and credentials issued; e.g., :: { ...
python
async def get_box_ids_issued(self) -> str: """ Return json object on lists of all unique box identifiers (schema identifiers, credential definition identifiers, and revocation registry identifiers) for all credential definitions and credentials issued; e.g., :: { ...
Return json object on lists of all unique box identifiers (schema identifiers, credential definition identifiers, and revocation registry identifiers) for all credential definitions and credentials issued; e.g., :: { "schema_id": [ "R17v42T4pk......
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/anchor/issuer.py#L624-L679
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/docutil.py
resource
def resource(ref: str, delimiter: str = None) -> str: """ Given a (URI) reference, return up to its delimiter (exclusively), or all of it if there is none. :param ref: reference :param delimiter: delimiter character (default None maps to '#', or ';' introduces identifiers) """ return ref.split...
python
def resource(ref: str, delimiter: str = None) -> str: """ Given a (URI) reference, return up to its delimiter (exclusively), or all of it if there is none. :param ref: reference :param delimiter: delimiter character (default None maps to '#', or ';' introduces identifiers) """ return ref.split...
Given a (URI) reference, return up to its delimiter (exclusively), or all of it if there is none. :param ref: reference :param delimiter: delimiter character (default None maps to '#', or ';' introduces identifiers)
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/docutil.py#L24-L32
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/docutil.py
canon_did
def canon_did(uri: str) -> str: """ Convert a URI into a DID if need be, left-stripping 'did:sov:' if present. Return input if already a DID. Raise BadIdentifier for invalid input. :param uri: input URI or DID :return: corresponding DID """ if ok_did(uri): return uri if uri.st...
python
def canon_did(uri: str) -> str: """ Convert a URI into a DID if need be, left-stripping 'did:sov:' if present. Return input if already a DID. Raise BadIdentifier for invalid input. :param uri: input URI or DID :return: corresponding DID """ if ok_did(uri): return uri if uri.st...
Convert a URI into a DID if need be, left-stripping 'did:sov:' if present. Return input if already a DID. Raise BadIdentifier for invalid input. :param uri: input URI or DID :return: corresponding DID
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/docutil.py#L35-L51
PSPC-SPAC-buyandsell/von_anchor
von_anchor/a2a/docutil.py
canon_ref
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
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...
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 doc :param delimiter: delimiter character marking fragment (default...
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/a2a/docutil.py#L54-L82
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/record.py
StorageRecord.ok_tags
def ok_tags(tags: dict) -> bool: """ Whether input tags dict is OK as an indy-sdk tags structure (depth=1, string values). """ if not tags: return True depth = 0 queue = [(i, depth+1) for i in tags.values() if isinstance(i, dict)] max_depth = 0 ...
python
def ok_tags(tags: dict) -> bool: """ Whether input tags dict is OK as an indy-sdk tags structure (depth=1, string values). """ if not tags: return True depth = 0 queue = [(i, depth+1) for i in tags.values() if isinstance(i, dict)] max_depth = 0 ...
Whether input tags dict is OK as an indy-sdk tags structure (depth=1, string values).
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/record.py#L57-L72
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/record.py
StorageRecord.tags
def tags(self, val: str) -> None: """ Accessor for record tags (metadata). :param val: record tags """ if not StorageRecord.ok_tags(val): LOGGER.debug('StorageRecord.__init__ <!< Tags %s must map strings to strings', val) raise BadRecord('Tags {} must ma...
python
def tags(self, val: str) -> None: """ Accessor for record tags (metadata). :param val: record tags """ if not StorageRecord.ok_tags(val): LOGGER.debug('StorageRecord.__init__ <!< Tags %s must map strings to strings', val) raise BadRecord('Tags {} must ma...
Accessor for record tags (metadata). :param val: record tags
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/record.py#L135-L146
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/record.py
StorageRecord.clear_tags
def clear_tags(self) -> dict: """ Accessor for record tags (metadata) stored in the clear. :return: record tags stored in the clear """ return {t: self.tags[t] for t in (self.tags or {}) if t.startswith('~')} or None
python
def clear_tags(self) -> dict: """ Accessor for record tags (metadata) stored in the clear. :return: record tags stored in the clear """ return {t: self.tags[t] for t in (self.tags or {}) if t.startswith('~')} or None
Accessor for record tags (metadata) stored in the clear. :return: record tags stored in the clear
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/record.py#L149-L156
PSPC-SPAC-buyandsell/von_anchor
von_anchor/wallet/record.py
StorageRecord.encr_tags
def encr_tags(self) -> dict: """ Accessor for record tags (metadata) stored encrypted. :return: record tags stored encrypted """ return {t: self._tags[t] for t in self.tags or {} if not t.startswith('~')} or None
python
def encr_tags(self) -> dict: """ Accessor for record tags (metadata) stored encrypted. :return: record tags stored encrypted """ return {t: self._tags[t] for t in self.tags or {} if not t.startswith('~')} or None
Accessor for record tags (metadata) stored encrypted. :return: record tags stored encrypted
https://github.com/PSPC-SPAC-buyandsell/von_anchor/blob/78ac1de67be42a676274f4bf71fe12f66e72f309/von_anchor/wallet/record.py#L159-L166
ubernostrum/pwned-passwords-django
src/pwned_passwords_django/api.py
_get_pwned
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
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...
Fetches a dict of all hash suffixes from Pwned Passwords for a given SHA-1 prefix.
https://github.com/ubernostrum/pwned-passwords-django/blob/e61f3ec21c37f1c2b4568bf11ea7eb782e2a5fb5/src/pwned_passwords_django/api.py#L29-L58
ubernostrum/pwned-passwords-django
src/pwned_passwords_django/api.py
pwned_password
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
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...
Checks a password against the Pwned Passwords database.
https://github.com/ubernostrum/pwned-passwords-django/blob/e61f3ec21c37f1c2b4568bf11ea7eb782e2a5fb5/src/pwned_passwords_django/api.py#L61-L74
ganguli-lab/proxalgs
proxalgs/core.py
Optimizer.add_regularizer
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
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. ...
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. If a function, then it must apply a proximal update given...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/core.py#L59-L92
ganguli-lab/proxalgs
proxalgs/core.py
Optimizer.set_regularizers
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
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 ...
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 clear : boolean, optional Whether or not to clear the...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/core.py#L94-L115
ganguli-lab/proxalgs
proxalgs/core.py
Optimizer.minimize
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
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...
Minimize a list of objectives using a proximal consensus algorithm Parameters ---------- theta_init : ndarray Initial parameter vector (numpy array) max_iter : int, optional Maximum number of iterations to run (default: 50) callback : function, optional...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/core.py#L121-L232
ganguli-lab/proxalgs
proxalgs/core.py
Optimizer.update_display
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
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...
Prints information about the optimization procedure to standard output Parameters ---------- iteration : int The current iteration. Must either a positive integer or -1, which indicates the end of the algorithm disp_level : int An integer which controls how much...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/core.py#L234-L281
ganguli-lab/proxalgs
proxalgs/tensor.py
susvd
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
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...
Sequential unfolding SVD Parameters ---------- x : Tensor x_obs : array_like rho : float penalties : array_like penalty for each unfolding of the input tensor
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/tensor.py#L69-L96
malinoff/structures
structures/core.py
Construct.build
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
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...
Build bytes from the python object. :param obj: Python object to build bytes from. :param context: Optional context dictionary.
https://github.com/malinoff/structures/blob/36b1d641d399cd0b2a824704da53d8b5c8bd4f10/structures/core.py#L41-L50
malinoff/structures
structures/core.py
Construct.parse
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
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)
Parse some python object from the data. :param data: Data to be parsed. :param context: Optional context dictionary.
https://github.com/malinoff/structures/blob/36b1d641d399cd0b2a824704da53d8b5c8bd4f10/structures/core.py#L52-L60
malinoff/structures
structures/core.py
Construct.build_stream
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
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. ...
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.
https://github.com/malinoff/structures/blob/36b1d641d399cd0b2a824704da53d8b5c8bd4f10/structures/core.py#L62-L79
malinoff/structures
structures/core.py
Construct.parse_stream
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
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() ...
Parse some python object from the stream. :param stream: Stream from which the data is read and parsed. :param context: Optional context dictionary.
https://github.com/malinoff/structures/blob/36b1d641d399cd0b2a824704da53d8b5c8bd4f10/structures/core.py#L81-L97
malinoff/structures
structures/core.py
Construct.sizeof
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
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) ...
Return the size of the construct in bytes. :param context: Optional context dictionary.
https://github.com/malinoff/structures/blob/36b1d641d399cd0b2a824704da53d8b5c8bd4f10/structures/core.py#L99-L114
ganguli-lab/proxalgs
proxalgs/operators.py
sfo
def sfo(x0, rho, optimizer, num_steps=50): """ Proximal operator for an arbitrary function minimized via the Sum-of-Functions optimizer (SFO) Notes ----- SFO is a function optimizer for the case where the target function breaks into a sum over minibatches, or a sum over contributing functio...
python
def sfo(x0, rho, optimizer, num_steps=50): """ Proximal operator for an arbitrary function minimized via the Sum-of-Functions optimizer (SFO) Notes ----- SFO is a function optimizer for the case where the target function breaks into a sum over minibatches, or a sum over contributing functio...
Proximal operator for an arbitrary function minimized via the Sum-of-Functions optimizer (SFO) Notes ----- SFO is a function optimizer for the case where the target function breaks into a sum over minibatches, or a sum over contributing functions. It is described in more detail in [1]_. Pa...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L42-L86
ganguli-lab/proxalgs
proxalgs/operators.py
poissreg
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
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 ...
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 rho : float Momentum parameter f...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L90-L122
ganguli-lab/proxalgs
proxalgs/operators.py
bfgs
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
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...
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 initial point used in the proximal update step rho : float ...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L126-L176
ganguli-lab/proxalgs
proxalgs/operators.py
smooth
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
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...
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 proximal update step rho : float Mom...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L180-L210
ganguli-lab/proxalgs
proxalgs/operators.py
nucnorm
def nucnorm(x0, rho, gamma): """ Proximal operator for the nuclear norm (sum of the singular values of a matrix) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger val...
python
def nucnorm(x0, rho, gamma): """ Proximal operator for the nuclear norm (sum of the singular values of a matrix) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger val...
Proximal operator for the nuclear norm (sum of the singular values of a matrix) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger value -> stays closer to x0) gamma : fl...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L214-L244
ganguli-lab/proxalgs
proxalgs/operators.py
tvd
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
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 ...
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 step (larger value -> stays closer to...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L272-L305
ganguli-lab/proxalgs
proxalgs/operators.py
sparse
def sparse(x0, rho, gamma): """ Proximal operator for the l1 norm (induces sparsity) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger value -> stays closer to x0) ...
python
def sparse(x0, rho, gamma): """ Proximal operator for the l1 norm (induces sparsity) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger value -> stays closer to x0) ...
Proximal operator for the l1 norm (induces sparsity) Parameters ---------- x0 : array_like The starting or initial point used in the proximal update step rho : float Momentum parameter for the proximal step (larger value -> stays closer to x0) gamma : float A constant that...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L309-L332
ganguli-lab/proxalgs
proxalgs/operators.py
linsys
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
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 ...
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 rho : float Momentum paramete...
https://github.com/ganguli-lab/proxalgs/blob/74f54467ad072d3229edea93fa84ddd98dd77c67/proxalgs/operators.py#L358-L385
kobinpy/kobin
kobin/responses.py
BaseResponse.status
def status(self): """ The HTTP status line as a string (e.g. ``404 Not Found``).""" status = _HTTP_STATUS_LINES.get(self._status_code) return str(status or ('{} Unknown'.format(self._status_code)))
python
def status(self): """ The HTTP status line as a string (e.g. ``404 Not Found``).""" status = _HTTP_STATUS_LINES.get(self._status_code) return str(status or ('{} Unknown'.format(self._status_code)))
The HTTP status line as a string (e.g. ``404 Not Found``).
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/responses.py#L56-L59
kobinpy/kobin
kobin/responses.py
BaseResponse.headerlist
def headerlist(self): """ WSGI conform list of (header, value) tuples. """ if 'Content-Type' not in self.headers: self.headers.add_header('Content-Type', self.default_content_type) if self._cookies: for c in self._cookies.values(): self.headers.add_header(...
python
def headerlist(self): """ WSGI conform list of (header, value) tuples. """ if 'Content-Type' not in self.headers: self.headers.add_header('Content-Type', self.default_content_type) if self._cookies: for c in self._cookies.values(): self.headers.add_header(...
WSGI conform list of (header, value) tuples.
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/responses.py#L68-L75
sunscrapers/djet
djet/assertions.py
StatusCodeAssertionsMixin.assert_redirect
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
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, ...
assertRedirects from Django TestCase follows the redirects chains, this assertion does not - which is more like real unit testing
https://github.com/sunscrapers/djet/blob/9e28278404bfeab4b2e2abb22094a0d41f07f805/djet/assertions.py#L40-L59
sunscrapers/djet
djet/assertions.py
InstanceAssertionsMixin.assert_instance_created
def assert_instance_created(self, model_class, **kwargs): """ Checks if a model instance was created in the database. For example:: >>> with self.assert_instance_created(Article, slug='lorem-ipsum'): ... Article.objects.create(slug='lorem-ipsum') """ return ...
python
def assert_instance_created(self, model_class, **kwargs): """ Checks if a model instance was created in the database. For example:: >>> with self.assert_instance_created(Article, slug='lorem-ipsum'): ... Article.objects.create(slug='lorem-ipsum') """ return ...
Checks if a model instance was created in the database. For example:: >>> with self.assert_instance_created(Article, slug='lorem-ipsum'): ... Article.objects.create(slug='lorem-ipsum')
https://github.com/sunscrapers/djet/blob/9e28278404bfeab4b2e2abb22094a0d41f07f805/djet/assertions.py#L174-L188
sunscrapers/djet
djet/assertions.py
InstanceAssertionsMixin.assert_instance_deleted
def assert_instance_deleted(self, model_class, **kwargs): """ Checks if the model instance was deleted from the database. For example:: >>> with self.assert_instance_deleted(Article, slug='lorem-ipsum'): ... Article.objects.get(slug='lorem-ipsum').delete() """ ...
python
def assert_instance_deleted(self, model_class, **kwargs): """ Checks if the model instance was deleted from the database. For example:: >>> with self.assert_instance_deleted(Article, slug='lorem-ipsum'): ... Article.objects.get(slug='lorem-ipsum').delete() """ ...
Checks if the model instance was deleted from the database. For example:: >>> with self.assert_instance_deleted(Article, slug='lorem-ipsum'): ... Article.objects.get(slug='lorem-ipsum').delete()
https://github.com/sunscrapers/djet/blob/9e28278404bfeab4b2e2abb22094a0d41f07f805/djet/assertions.py#L190-L204
kobinpy/kobin
kobin/requests.py
_split_into_mimetype_and_priority
def _split_into_mimetype_and_priority(x): """Split an accept header item into mimetype and priority. >>> _split_into_mimetype_and_priority('text/*') ('text/*', 1.0) >>> _split_into_mimetype_and_priority('application/json;q=0.5') ('application/json', 0.5) """ if ';' in x: content_ty...
python
def _split_into_mimetype_and_priority(x): """Split an accept header item into mimetype and priority. >>> _split_into_mimetype_and_priority('text/*') ('text/*', 1.0) >>> _split_into_mimetype_and_priority('application/json;q=0.5') ('application/json', 0.5) """ if ';' in x: content_ty...
Split an accept header item into mimetype and priority. >>> _split_into_mimetype_and_priority('text/*') ('text/*', 1.0) >>> _split_into_mimetype_and_priority('application/json;q=0.5') ('application/json', 0.5)
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/requests.py#L161-L177
kobinpy/kobin
kobin/requests.py
_parse_and_sort_accept_header
def _parse_and_sort_accept_header(accept_header): """Parse and sort the accept header items. >>> _parse_and_sort_accept_header('application/json;q=0.5, text/*') [('text/*', 1.0), ('application/json', 0.5)] """ return sorted([_split_into_mimetype_and_priority(x) for x in accept_header.split(',')], ...
python
def _parse_and_sort_accept_header(accept_header): """Parse and sort the accept header items. >>> _parse_and_sort_accept_header('application/json;q=0.5, text/*') [('text/*', 1.0), ('application/json', 0.5)] """ return sorted([_split_into_mimetype_and_priority(x) for x in accept_header.split(',')], ...
Parse and sort the accept header items. >>> _parse_and_sort_accept_header('application/json;q=0.5, text/*') [('text/*', 1.0), ('application/json', 0.5)]
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/requests.py#L180-L187
kobinpy/kobin
kobin/requests.py
accept_best_match
def accept_best_match(accept_header, mimetypes): """Return a mimetype best matched the accept headers. >>> accept_best_match('application/json, text/html', ['application/json', 'text/plain']) 'application/json' >>> accept_best_match('application/json;q=0.5, text/*', ['application/json', 'text/plain'])...
python
def accept_best_match(accept_header, mimetypes): """Return a mimetype best matched the accept headers. >>> accept_best_match('application/json, text/html', ['application/json', 'text/plain']) 'application/json' >>> accept_best_match('application/json;q=0.5, text/*', ['application/json', 'text/plain'])...
Return a mimetype best matched the accept headers. >>> accept_best_match('application/json, text/html', ['application/json', 'text/plain']) 'application/json' >>> accept_best_match('application/json;q=0.5, text/*', ['application/json', 'text/plain']) 'text/plain'
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/requests.py#L190-L203
kobinpy/kobin
kobin/routes.py
match_url_vars_type
def match_url_vars_type(url_vars, type_hints): """ Match types of url vars. >>> match_url_vars_type({'user_id': '1'}, {'user_id': int}) (True, {'user_id': 1}) >>> match_url_vars_type({'user_id': 'foo'}, {'user_id': int}) (False, {}) """ typed_url_vars = {} try: for k, v in url_v...
python
def match_url_vars_type(url_vars, type_hints): """ Match types of url vars. >>> match_url_vars_type({'user_id': '1'}, {'user_id': int}) (True, {'user_id': 1}) >>> match_url_vars_type({'user_id': 'foo'}, {'user_id': int}) (False, {}) """ typed_url_vars = {} try: for k, v in url_v...
Match types of url vars. >>> match_url_vars_type({'user_id': '1'}, {'user_id': int}) (True, {'user_id': 1}) >>> match_url_vars_type({'user_id': 'foo'}, {'user_id': int}) (False, {})
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L84-L102
kobinpy/kobin
kobin/routes.py
match_path
def match_path(rule, path): """ Match path. >>> match_path('/foo', '/foo') (True, {}) >>> match_path('/foo', '/bar') (False, {}) >>> match_path('/users/{user_id}', '/users/1') (True, {'user_id': '1'}) >>> match_path('/users/{user_id}', '/users/not-integer') (True, {'user_id': 'not-i...
python
def match_path(rule, path): """ Match path. >>> match_path('/foo', '/foo') (True, {}) >>> match_path('/foo', '/bar') (False, {}) >>> match_path('/users/{user_id}', '/users/1') (True, {'user_id': '1'}) >>> match_path('/users/{user_id}', '/users/not-integer') (True, {'user_id': 'not-i...
Match path. >>> match_path('/foo', '/foo') (True, {}) >>> match_path('/foo', '/bar') (False, {}) >>> match_path('/users/{user_id}', '/users/1') (True, {'user_id': '1'}) >>> match_path('/users/{user_id}', '/users/not-integer') (True, {'user_id': 'not-integer'})
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L105-L130
kobinpy/kobin
kobin/routes.py
Router.match
def match(self, path, method): """ Get callback and url_vars. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) ...
python
def match(self, path, method): """ Get callback and url_vars. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) ...
Get callback and url_vars. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) >>> callback, url_vars = r.match('/user...
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L137-L178
kobinpy/kobin
kobin/routes.py
Router.add
def add(self, rule, method, name, callback): """ Add a new rule or replace the target for an existing rule. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users...
python
def add(self, rule, method, name, callback): """ Add a new rule or replace the target for an existing rule. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users...
Add a new rule or replace the target for an existing rule. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) >>> path...
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L180-L215
kobinpy/kobin
kobin/routes.py
Router.reverse
def reverse(self, name, **kwargs): """ Reverse routing. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) >>>...
python
def reverse(self, name, **kwargs): """ Reverse routing. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) >>>...
Reverse routing. >>> from kobin import Response >>> r = Router() >>> def view(user_id: int) -> Response: ... return Response(f'You are {user_id}') ... >>> r.add('/users/{user_id}', 'GET', 'user-detail', view) >>> r.reverse('user-detail', user_id=1) '/...
https://github.com/kobinpy/kobin/blob/e6caff5af05db8a6e511d3de275d262466ab36a6/kobin/routes.py#L217-L231
maxcountryman/atomos
atomos/util.py
synchronized
def synchronized(fn): ''' A decorator which acquires a lock before attempting to execute its wrapped function. Releases the lock in a finally clause. :param fn: The function to wrap. ''' lock = threading.Lock() @functools.wraps(fn) def decorated(*args, **kwargs): lock.acquire()...
python
def synchronized(fn): ''' A decorator which acquires a lock before attempting to execute its wrapped function. Releases the lock in a finally clause. :param fn: The function to wrap. ''' lock = threading.Lock() @functools.wraps(fn) def decorated(*args, **kwargs): lock.acquire()...
A decorator which acquires a lock before attempting to execute its wrapped function. Releases the lock in a finally clause. :param fn: The function to wrap.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/util.py#L21-L38
maxcountryman/atomos
atomos/atomic.py
AtomicReference.set
def set(self, value): ''' Atomically sets the value to `value`. :param value: The value to set. ''' with self._lock.exclusive: self._value = value return value
python
def set(self, value): ''' Atomically sets the value to `value`. :param value: The value to set. ''' with self._lock.exclusive: self._value = value return value
Atomically sets the value to `value`. :param value: The value to set.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L38-L46
maxcountryman/atomos
atomos/atomic.py
AtomicReference.get_and_set
def get_and_set(self, value): ''' Atomically sets the value to `value` and returns the old value. :param value: The value to set. ''' with self._lock.exclusive: oldval = self._value self._value = value return oldval
python
def get_and_set(self, value): ''' Atomically sets the value to `value` and returns the old value. :param value: The value to set. ''' with self._lock.exclusive: oldval = self._value self._value = value return oldval
Atomically sets the value to `value` and returns the old value. :param value: The value to set.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L48-L57
maxcountryman/atomos
atomos/atomic.py
AtomicReference.compare_and_set
def compare_and_set(self, expect, update): ''' Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value. ''' ...
python
def compare_and_set(self, expect, update): ''' Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value. ''' ...
Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L59-L73
maxcountryman/atomos
atomos/atomic.py
AtomicNumber.add_and_get
def add_and_get(self, delta): ''' Atomically adds `delta` to the current value. :param delta: The delta to add. ''' with self._lock.exclusive: self._value += delta return self._value
python
def add_and_get(self, delta): ''' Atomically adds `delta` to the current value. :param delta: The delta to add. ''' with self._lock.exclusive: self._value += delta return self._value
Atomically adds `delta` to the current value. :param delta: The delta to add.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L111-L119
maxcountryman/atomos
atomos/atomic.py
AtomicNumber.get_and_add
def get_and_add(self, delta): ''' Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add. ''' with self._lock.exclusive: oldval = self._value self._value += delta return oldval
python
def get_and_add(self, delta): ''' Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add. ''' with self._lock.exclusive: oldval = self._value self._value += delta return oldval
Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L121-L130
maxcountryman/atomos
atomos/atomic.py
AtomicNumber.subtract_and_get
def subtract_and_get(self, delta): ''' Atomically subtracts `delta` from the current value. :param delta: The delta to subtract. ''' with self._lock.exclusive: self._value -= delta return self._value
python
def subtract_and_get(self, delta): ''' Atomically subtracts `delta` from the current value. :param delta: The delta to subtract. ''' with self._lock.exclusive: self._value -= delta return self._value
Atomically subtracts `delta` from the current value. :param delta: The delta to subtract.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L132-L140
maxcountryman/atomos
atomos/atomic.py
AtomicNumber.get_and_subtract
def get_and_subtract(self, delta): ''' Atomically subtracts `delta` from the current value and returns the old value. :param delta: The delta to subtract. ''' with self._lock.exclusive: oldval = self._value self._value -= delta return ...
python
def get_and_subtract(self, delta): ''' Atomically subtracts `delta` from the current value and returns the old value. :param delta: The delta to subtract. ''' with self._lock.exclusive: oldval = self._value self._value -= delta return ...
Atomically subtracts `delta` from the current value and returns the old value. :param delta: The delta to subtract.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atomic.py#L142-L152
maxcountryman/atomos
atomos/atom.py
ARef.notify_watches
def notify_watches(self, oldval, newval): ''' Passes `oldval` and `newval` to each `fn` in the watches dictionary, passing along its respective key and the reference to this object. :param oldval: The old value which will be passed to the watch. :param newval: The new value whic...
python
def notify_watches(self, oldval, newval): ''' Passes `oldval` and `newval` to each `fn` in the watches dictionary, passing along its respective key and the reference to this object. :param oldval: The old value which will be passed to the watch. :param newval: The new value whic...
Passes `oldval` and `newval` to each `fn` in the watches dictionary, passing along its respective key and the reference to this object. :param oldval: The old value which will be passed to the watch. :param newval: The new value which will be passed to the watch.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atom.py#L64-L76
maxcountryman/atomos
atomos/atom.py
Atom.swap
def swap(self, fn, *args, **kwargs): ''' Given a mutator `fn`, calls `fn` with the atom's current state, `args`, and `kwargs`. The return value of this invocation becomes the new value of the atom. Returns the new value. :param fn: A function which will be passed the current sta...
python
def swap(self, fn, *args, **kwargs): ''' Given a mutator `fn`, calls `fn` with the atom's current state, `args`, and `kwargs`. The return value of this invocation becomes the new value of the atom. Returns the new value. :param fn: A function which will be passed the current sta...
Given a mutator `fn`, calls `fn` with the atom's current state, `args`, and `kwargs`. The return value of this invocation becomes the new value of the atom. Returns the new value. :param fn: A function which will be passed the current state. Should return a new state. This absolutel...
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atom.py#L154-L172
maxcountryman/atomos
atomos/atom.py
Atom.reset
def reset(self, newval): ''' Resets the atom's value to `newval`, returning `newval`. :param newval: The new value to set. ''' oldval = self._state.get() self._state.set(newval) self.notify_watches(oldval, newval) return newval
python
def reset(self, newval): ''' Resets the atom's value to `newval`, returning `newval`. :param newval: The new value to set. ''' oldval = self._state.get() self._state.set(newval) self.notify_watches(oldval, newval) return newval
Resets the atom's value to `newval`, returning `newval`. :param newval: The new value to set.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atom.py#L174-L183
maxcountryman/atomos
atomos/atom.py
Atom.compare_and_set
def compare_and_set(self, oldval, newval): ''' Given `oldval` and `newval`, sets the atom's value to `newval` if and only if `oldval` is the atom's current value. Returns `True` upon success, otherwise `False`. :param oldval: The old expected value. :param newval: The ne...
python
def compare_and_set(self, oldval, newval): ''' Given `oldval` and `newval`, sets the atom's value to `newval` if and only if `oldval` is the atom's current value. Returns `True` upon success, otherwise `False`. :param oldval: The old expected value. :param newval: The ne...
Given `oldval` and `newval`, sets the atom's value to `newval` if and only if `oldval` is the atom's current value. Returns `True` upon success, otherwise `False`. :param oldval: The old expected value. :param newval: The new value which will be set if and only if `oldval` e...
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/atom.py#L185-L199
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicCtypesReference.set
def set(self, value): ''' Atomically sets the value to `value`. :param value: The value to set. ''' with self._reference.get_lock(): self._reference.value = value return value
python
def set(self, value): ''' Atomically sets the value to `value`. :param value: The value to set. ''' with self._reference.get_lock(): self._reference.value = value return value
Atomically sets the value to `value`. :param value: The value to set.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L95-L103
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicCtypesReference.get_and_set
def get_and_set(self, value): ''' Atomically sets the value to `value` and returns the old value. :param value: The value to set. ''' with self._reference.get_lock(): oldval = self._reference.value self._reference.value = value return oldval
python
def get_and_set(self, value): ''' Atomically sets the value to `value` and returns the old value. :param value: The value to set. ''' with self._reference.get_lock(): oldval = self._reference.value self._reference.value = value return oldval
Atomically sets the value to `value` and returns the old value. :param value: The value to set.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L105-L114
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicCtypesReference.compare_and_set
def compare_and_set(self, expect, update): ''' Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value. ''' ...
python
def compare_and_set(self, expect, update): ''' Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value. ''' ...
Atomically sets the value to `update` if the current value is equal to `expect`. :param expect: The expected current value. :param update: The value to set if and only if `expect` equals the current value.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L116-L130
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicNumber.add_and_get
def add_and_get(self, delta): ''' Atomically adds `delta` to the current value. :param delta: The delta to add. ''' with self._reference.get_lock(): self._reference.value += delta return self._reference.value
python
def add_and_get(self, delta): ''' Atomically adds `delta` to the current value. :param delta: The delta to add. ''' with self._reference.get_lock(): self._reference.value += delta return self._reference.value
Atomically adds `delta` to the current value. :param delta: The delta to add.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L169-L177
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicNumber.get_and_add
def get_and_add(self, delta): ''' Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add. ''' with self._reference.get_lock(): oldval = self._reference.value self._reference.value += delta return...
python
def get_and_add(self, delta): ''' Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add. ''' with self._reference.get_lock(): oldval = self._reference.value self._reference.value += delta return...
Atomically adds `delta` to the current value and returns the old value. :param delta: The delta to add.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L179-L188
maxcountryman/atomos
atomos/multiprocessing/atomic.py
AtomicNumber.subtract_and_get
def subtract_and_get(self, delta): ''' Atomically subtracts `delta` from the current value. :param delta: The delta to subtract. ''' with self._reference.get_lock(): self._reference.value -= delta return self._reference.value
python
def subtract_and_get(self, delta): ''' Atomically subtracts `delta` from the current value. :param delta: The delta to subtract. ''' with self._reference.get_lock(): self._reference.value -= delta return self._reference.value
Atomically subtracts `delta` from the current value. :param delta: The delta to subtract.
https://github.com/maxcountryman/atomos/blob/418746c69134efba3c4f999405afe9113dee4827/atomos/multiprocessing/atomic.py#L190-L198