repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
_wait_for_macaroon
def _wait_for_macaroon(wait_url): ''' Returns a macaroon from a legacy wait endpoint. ''' headers = { BAKERY_PROTOCOL_HEADER: str(bakery.LATEST_VERSION) } resp = requests.get(url=wait_url, headers=headers) if resp.status_code != 200: raise InteractionError('cannot get {}'.format(...
python
def _wait_for_macaroon(wait_url): ''' Returns a macaroon from a legacy wait endpoint. ''' headers = { BAKERY_PROTOCOL_HEADER: str(bakery.LATEST_VERSION) } resp = requests.get(url=wait_url, headers=headers) if resp.status_code != 200: raise InteractionError('cannot get {}'.format(...
[ "def", "_wait_for_macaroon", "(", "wait_url", ")", ":", "headers", "=", "{", "BAKERY_PROTOCOL_HEADER", ":", "str", "(", "bakery", ".", "LATEST_VERSION", ")", "}", "resp", "=", "requests", ".", "get", "(", "url", "=", "wait_url", ",", "headers", "=", "heade...
Returns a macaroon from a legacy wait endpoint.
[ "Returns", "a", "macaroon", "from", "a", "legacy", "wait", "endpoint", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L361-L371
train
Returns a macaroon from a legacy wait endpoint.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
_legacy_get_interaction_methods
def _legacy_get_interaction_methods(u): ''' Queries a URL as found in an ErrInteractionRequired VisitURL field to find available interaction methods. It does this by sending a GET request to the URL with the Accept header set to "application/json" and parsing the resulting response as a dict. ''...
python
def _legacy_get_interaction_methods(u): ''' Queries a URL as found in an ErrInteractionRequired VisitURL field to find available interaction methods. It does this by sending a GET request to the URL with the Accept header set to "application/json" and parsing the resulting response as a dict. ''...
[ "def", "_legacy_get_interaction_methods", "(", "u", ")", ":", "headers", "=", "{", "BAKERY_PROTOCOL_HEADER", ":", "str", "(", "bakery", ".", "LATEST_VERSION", ")", ",", "'Accept'", ":", "'application/json'", "}", "resp", "=", "requests", ".", "get", "(", "url"...
Queries a URL as found in an ErrInteractionRequired VisitURL field to find available interaction methods. It does this by sending a GET request to the URL with the Accept header set to "application/json" and parsing the resulting response as a dict.
[ "Queries", "a", "URL", "as", "found", "in", "an", "ErrInteractionRequired", "VisitURL", "field", "to", "find", "available", "interaction", "methods", ".", "It", "does", "this", "by", "sending", "a", "GET", "request", "to", "the", "URL", "with", "the", "Accep...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L374-L397
train
Queries a URL as found in an ErrInteractionRequired VisitURL field to find available interaction methods.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
Client.request
def request(self, method, url, **kwargs): '''Use the requests library to make a request. Using this method is like doing: requests.request(method, url, auth=client.auth()) ''' # TODO should we raise an exception if auth or cookies are explicitly # mentioned in kwargs...
python
def request(self, method, url, **kwargs): '''Use the requests library to make a request. Using this method is like doing: requests.request(method, url, auth=client.auth()) ''' # TODO should we raise an exception if auth or cookies are explicitly # mentioned in kwargs...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "# TODO should we raise an exception if auth or cookies are explicitly", "# mentioned in kwargs?", "kwargs", "[", "'auth'", "]", "=", "self", ".", "auth", "(", ")", "kwarg...
Use the requests library to make a request. Using this method is like doing: requests.request(method, url, auth=client.auth())
[ "Use", "the", "requests", "library", "to", "make", "a", "request", ".", "Using", "this", "method", "is", "like", "doing", ":" ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L77-L87
train
Use the requests library to make a request.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
Client.handle_error
def handle_error(self, error, url): '''Try to resolve the given error, which should be a response to the given URL, by discharging any macaroon contained in it. That is, if error.code is ERR_DISCHARGE_REQUIRED then it will try to discharge err.info.macaroon. If the discharge succ...
python
def handle_error(self, error, url): '''Try to resolve the given error, which should be a response to the given URL, by discharging any macaroon contained in it. That is, if error.code is ERR_DISCHARGE_REQUIRED then it will try to discharge err.info.macaroon. If the discharge succ...
[ "def", "handle_error", "(", "self", ",", "error", ",", "url", ")", ":", "if", "error", ".", "info", "is", "None", "or", "error", ".", "info", ".", "macaroon", "is", "None", ":", "raise", "BakeryException", "(", "'unable to read info in discharge error '", "'...
Try to resolve the given error, which should be a response to the given URL, by discharging any macaroon contained in it. That is, if error.code is ERR_DISCHARGE_REQUIRED then it will try to discharge err.info.macaroon. If the discharge succeeds, the discharged macaroon will be saved to ...
[ "Try", "to", "resolve", "the", "given", "error", "which", "should", "be", "a", "response", "to", "the", "given", "URL", "by", "discharging", "any", "macaroon", "contained", "in", "it", ".", "That", "is", "if", "error", ".", "code", "is", "ERR_DISCHARGE_REQ...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L89-L121
train
Try to resolve the given error which should be a response to the given URL. If the error is a response then the error will be a response . If the error is an ERR_DISCHARGE_REQUIREDException then the exception will be raised.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
Client.acquire_discharge
def acquire_discharge(self, cav, payload): ''' Request a discharge macaroon from the caveat location as an HTTP URL. @param cav Third party {pymacaroons.Caveat} to be discharged. @param payload External caveat data {bytes}. @return The acquired macaroon {macaroonbakery.Macaroon} ...
python
def acquire_discharge(self, cav, payload): ''' Request a discharge macaroon from the caveat location as an HTTP URL. @param cav Third party {pymacaroons.Caveat} to be discharged. @param payload External caveat data {bytes}. @return The acquired macaroon {macaroonbakery.Macaroon} ...
[ "def", "acquire_discharge", "(", "self", ",", "cav", ",", "payload", ")", ":", "resp", "=", "self", ".", "_acquire_discharge_with_token", "(", "cav", ",", "payload", ",", "None", ")", "# TODO Fabrice what is the other http response possible ??", "if", "resp", ".", ...
Request a discharge macaroon from the caveat location as an HTTP URL. @param cav Third party {pymacaroons.Caveat} to be discharged. @param payload External caveat data {bytes}. @return The acquired macaroon {macaroonbakery.Macaroon}
[ "Request", "a", "discharge", "macaroon", "from", "the", "caveat", "location", "as", "an", "HTTP", "URL", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L123-L156
train
Request a discharge macaroon from the caveat location as an HTTP URL.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_client.py
Client._interact
def _interact(self, location, error_info, payload): '''Gathers a macaroon by directing the user to interact with a web page. The error_info argument holds the interaction-required error response. @return DischargeToken, bakery.Macaroon ''' if (self._interaction_methods is...
python
def _interact(self, location, error_info, payload): '''Gathers a macaroon by directing the user to interact with a web page. The error_info argument holds the interaction-required error response. @return DischargeToken, bakery.Macaroon ''' if (self._interaction_methods is...
[ "def", "_interact", "(", "self", ",", "location", ",", "error_info", ",", "payload", ")", ":", "if", "(", "self", ".", "_interaction_methods", "is", "None", "or", "len", "(", "self", ".", "_interaction_methods", ")", "==", "0", ")", ":", "raise", "Intera...
Gathers a macaroon by directing the user to interact with a web page. The error_info argument holds the interaction-required error response. @return DischargeToken, bakery.Macaroon
[ "Gathers", "a", "macaroon", "by", "directing", "the", "user", "to", "interact", "with", "a", "web", "page", ".", "The", "error_info", "argument", "holds", "the", "interaction", "-", "required", "error", "response", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_client.py#L173-L200
train
Returns a DischargeToken and a bakery. Macaroon.
blockstack/keylib-py
keylib/utils.py
random_secret_exponent
def random_secret_exponent(curve_order): """ Generates a random secret exponent. """ # run a rejection sampling algorithm to ensure the random int is less # than the curve order while True: # generate a random 256 bit hex string random_hex = hexlify(dev_urandom_entropy(32)) rando...
python
def random_secret_exponent(curve_order): """ Generates a random secret exponent. """ # run a rejection sampling algorithm to ensure the random int is less # than the curve order while True: # generate a random 256 bit hex string random_hex = hexlify(dev_urandom_entropy(32)) rando...
[ "def", "random_secret_exponent", "(", "curve_order", ")", ":", "# run a rejection sampling algorithm to ensure the random int is less", "# than the curve order", "while", "True", ":", "# generate a random 256 bit hex string", "random_hex", "=", "hexlify", "(", "dev_urandom_entropy", ...
Generates a random secret exponent.
[ "Generates", "a", "random", "secret", "exponent", "." ]
7bbd1697a144eb50293f5d50797c4a747c2c906a
https://github.com/blockstack/keylib-py/blob/7bbd1697a144eb50293f5d50797c4a747c2c906a/keylib/utils.py#L20-L30
train
Generates a random secret exponent.
Phyks/libbmc
libbmc/bibtex.py
dict2bibtex
def dict2bibtex(data): """ Convert a single BibTeX entry dict to a BibTeX string. :param data: A dict representing BibTeX entry, as the ones from \ ``bibtexparser.BibDatabase.entries`` output. :return: A formatted BibTeX string. """ bibtex = '@' + data['ENTRYTYPE'] + '{' + data['ID'...
python
def dict2bibtex(data): """ Convert a single BibTeX entry dict to a BibTeX string. :param data: A dict representing BibTeX entry, as the ones from \ ``bibtexparser.BibDatabase.entries`` output. :return: A formatted BibTeX string. """ bibtex = '@' + data['ENTRYTYPE'] + '{' + data['ID'...
[ "def", "dict2bibtex", "(", "data", ")", ":", "bibtex", "=", "'@'", "+", "data", "[", "'ENTRYTYPE'", "]", "+", "'{'", "+", "data", "[", "'ID'", "]", "+", "\",\\n\"", "for", "field", "in", "[", "i", "for", "i", "in", "sorted", "(", "data", ")", "if...
Convert a single BibTeX entry dict to a BibTeX string. :param data: A dict representing BibTeX entry, as the ones from \ ``bibtexparser.BibDatabase.entries`` output. :return: A formatted BibTeX string.
[ "Convert", "a", "single", "BibTeX", "entry", "dict", "to", "a", "BibTeX", "string", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L17-L30
train
Convert a dictionary representing a BibTeX entry into a BibTeX string.
Phyks/libbmc
libbmc/bibtex.py
write
def write(filename, data): """ Create a new BibTeX file. :param filename: The name of the BibTeX file to write. :param data: A ``bibtexparser.BibDatabase`` object. """ with open(filename, 'w') as fh: fh.write(bibdatabase2bibtex(data))
python
def write(filename, data): """ Create a new BibTeX file. :param filename: The name of the BibTeX file to write. :param data: A ``bibtexparser.BibDatabase`` object. """ with open(filename, 'w') as fh: fh.write(bibdatabase2bibtex(data))
[ "def", "write", "(", "filename", ",", "data", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fh", ":", "fh", ".", "write", "(", "bibdatabase2bibtex", "(", "data", ")", ")" ]
Create a new BibTeX file. :param filename: The name of the BibTeX file to write. :param data: A ``bibtexparser.BibDatabase`` object.
[ "Create", "a", "new", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L43-L51
train
Write a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
edit
def edit(filename, identifier, data): """ Update an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to update, in the BibTeX file. :param data: A dict associating fields and updated values. Fields present \ in the BibT...
python
def edit(filename, identifier, data): """ Update an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to update, in the BibTeX file. :param data: A dict associating fields and updated values. Fields present \ in the BibT...
[ "def", "edit", "(", "filename", ",", "identifier", ",", "data", ")", ":", "# Get current bibtex", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fh", ":", "bibtex", "=", "bibtexparser", ".", "load", "(", "fh", ")", "# Update it", "# TODO: Not wor...
Update an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to update, in the BibTeX file. :param data: A dict associating fields and updated values. Fields present \ in the BibTeX file but not in this dict will be kept as is.
[ "Update", "an", "entry", "in", "a", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L65-L83
train
Edit an entry in a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
delete
def delete(filename, identifier): """ Delete an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to delete, in the BibTeX file. """ # Get current bibtex with open(filename, 'r') as fh: bibtex = bibtexparser.load(fh)...
python
def delete(filename, identifier): """ Delete an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to delete, in the BibTeX file. """ # Get current bibtex with open(filename, 'r') as fh: bibtex = bibtexparser.load(fh)...
[ "def", "delete", "(", "filename", ",", "identifier", ")", ":", "# Get current bibtex", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fh", ":", "bibtex", "=", "bibtexparser", ".", "load", "(", "fh", ")", "# Delete the bibtex entry", "# TODO: Not work...
Delete an entry in a BibTeX file. :param filename: The name of the BibTeX file to edit. :param identifier: The id of the entry to delete, in the BibTeX file.
[ "Delete", "an", "entry", "in", "a", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L107-L126
train
Delete an entry in a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
get
def get(filename, ignore_fields=None): """ Get all entries from a BibTeX file. :param filename: The name of the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ file. :returns: A ``bibtexparser.BibDatabase`` object representing the fetched \ ...
python
def get(filename, ignore_fields=None): """ Get all entries from a BibTeX file. :param filename: The name of the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ file. :returns: A ``bibtexparser.BibDatabase`` object representing the fetched \ ...
[ "def", "get", "(", "filename", ",", "ignore_fields", "=", "None", ")", ":", "# Handle default argument", "if", "ignore_fields", "is", "None", ":", "ignore_fields", "=", "[", "]", "# Open bibtex file", "with", "open", "(", "filename", ",", "'r'", ")", "as", "...
Get all entries from a BibTeX file. :param filename: The name of the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ file. :returns: A ``bibtexparser.BibDatabase`` object representing the fetched \ entries.
[ "Get", "all", "entries", "from", "a", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L129-L153
train
Get all entries from a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
get_entry_by_filter
def get_entry_by_filter(filename, filter_function, ignore_fields=None): """ Get an entry from a BibTeX file. .. note :: Returns the first matching entry. :param filename: The name of the BibTeX file. :param filter_function: A function returning ``True`` or ``False`` \ whether ...
python
def get_entry_by_filter(filename, filter_function, ignore_fields=None): """ Get an entry from a BibTeX file. .. note :: Returns the first matching entry. :param filename: The name of the BibTeX file. :param filter_function: A function returning ``True`` or ``False`` \ whether ...
[ "def", "get_entry_by_filter", "(", "filename", ",", "filter_function", ",", "ignore_fields", "=", "None", ")", ":", "# Handle default argument", "if", "ignore_fields", "is", "None", ":", "ignore_fields", "=", "[", "]", "# Open bibtex file", "with", "open", "(", "f...
Get an entry from a BibTeX file. .. note :: Returns the first matching entry. :param filename: The name of the BibTeX file. :param filter_function: A function returning ``True`` or ``False`` \ whether the entry should be included or not. :param ignore_fields: An optional list of f...
[ "Get", "an", "entry", "from", "a", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L156-L200
train
Get an entry from a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
get_entry
def get_entry(filename, identifier, ignore_fields=None): """ Get an entry from a BibTeX file. :param filename: The name of the BibTeX file. :param identifier: An id of the entry to fetch, in the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ fil...
python
def get_entry(filename, identifier, ignore_fields=None): """ Get an entry from a BibTeX file. :param filename: The name of the BibTeX file. :param identifier: An id of the entry to fetch, in the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ fil...
[ "def", "get_entry", "(", "filename", ",", "identifier", ",", "ignore_fields", "=", "None", ")", ":", "# Handle default argument", "if", "ignore_fields", "is", "None", ":", "ignore_fields", "=", "[", "]", "return", "get_entry_by_filter", "(", "filename", ",", "la...
Get an entry from a BibTeX file. :param filename: The name of the BibTeX file. :param identifier: An id of the entry to fetch, in the BibTeX file. :param ignore_fields: An optional list of fields to strip from the BibTeX \ file. :returns: A ``bibtexparser.BibDatabase`` object representing ...
[ "Get", "an", "entry", "from", "a", "BibTeX", "file", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L203-L221
train
Get an entry from a BibTeX file.
Phyks/libbmc
libbmc/bibtex.py
to_filename
def to_filename(data, mask=DEFAULT_PAPERS_FILENAME_MASK, extra_formatters=None): """ Convert a bibtex entry to a formatted filename according to a given mask. .. note :: Available formatters out of the box are: - ``journal`` - ``title`` ...
python
def to_filename(data, mask=DEFAULT_PAPERS_FILENAME_MASK, extra_formatters=None): """ Convert a bibtex entry to a formatted filename according to a given mask. .. note :: Available formatters out of the box are: - ``journal`` - ``title`` ...
[ "def", "to_filename", "(", "data", ",", "mask", "=", "DEFAULT_PAPERS_FILENAME_MASK", ",", "extra_formatters", "=", "None", ")", ":", "# Handle default argument", "if", "extra_formatters", "is", "None", ":", "extra_formatters", "=", "{", "}", "entry", "=", "data", ...
Convert a bibtex entry to a formatted filename according to a given mask. .. note :: Available formatters out of the box are: - ``journal`` - ``title`` - ``year`` - ``first`` for the first author - ``last`` for the last author - ``aut...
[ "Convert", "a", "bibtex", "entry", "to", "a", "formatted", "filename", "according", "to", "a", "given", "mask", "." ]
9ef1a29d2514157d1edd6c13ecbd61b07ae9315e
https://github.com/Phyks/libbmc/blob/9ef1a29d2514157d1edd6c13ecbd61b07ae9315e/libbmc/bibtex.py#L224-L285
train
Convert a bibtex entry to a formatted filename according to a given mask.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
load_uint
async def load_uint(reader, width): """ Constant-width integer serialization :param reader: :param width: :return: """ buffer = _UINT_BUFFER result = 0 shift = 0 for _ in range(width): await reader.areadinto(buffer) result += buffer[0] << shift shift += 8 ...
python
async def load_uint(reader, width): """ Constant-width integer serialization :param reader: :param width: :return: """ buffer = _UINT_BUFFER result = 0 shift = 0 for _ in range(width): await reader.areadinto(buffer) result += buffer[0] << shift shift += 8 ...
[ "async", "def", "load_uint", "(", "reader", ",", "width", ")", ":", "buffer", "=", "_UINT_BUFFER", "result", "=", "0", "shift", "=", "0", "for", "_", "in", "range", "(", "width", ")", ":", "await", "reader", ".", "areadinto", "(", "buffer", ")", "res...
Constant-width integer serialization :param reader: :param width: :return:
[ "Constant", "-", "width", "integer", "serialization", ":", "param", "reader", ":", ":", "param", "width", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L4-L18
train
Load a constant - width integer from a file - like object.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
dump_uint
async def dump_uint(writer, n, width): """ Constant-width integer serialization :param writer: :param n: :param width: :return: """ buffer = _UINT_BUFFER for _ in range(width): buffer[0] = n & 0xff await writer.awrite(buffer) n >>= 8
python
async def dump_uint(writer, n, width): """ Constant-width integer serialization :param writer: :param n: :param width: :return: """ buffer = _UINT_BUFFER for _ in range(width): buffer[0] = n & 0xff await writer.awrite(buffer) n >>= 8
[ "async", "def", "dump_uint", "(", "writer", ",", "n", ",", "width", ")", ":", "buffer", "=", "_UINT_BUFFER", "for", "_", "in", "range", "(", "width", ")", ":", "buffer", "[", "0", "]", "=", "n", "&", "0xff", "await", "writer", ".", "awrite", "(", ...
Constant-width integer serialization :param writer: :param n: :param width: :return:
[ "Constant", "-", "width", "integer", "serialization", ":", "param", "writer", ":", ":", "param", "n", ":", ":", "param", "width", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L21-L33
train
A constant - width integer serialization.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
load_uvarint_b
def load_uvarint_b(buffer): """ Variable int deserialization, synchronous from buffer. :param buffer: :return: """ result = 0 idx = 0 byte = 0x80 while byte & 0x80: byte = buffer[idx] result += (byte & 0x7F) << (7 * idx) idx += 1 return result
python
def load_uvarint_b(buffer): """ Variable int deserialization, synchronous from buffer. :param buffer: :return: """ result = 0 idx = 0 byte = 0x80 while byte & 0x80: byte = buffer[idx] result += (byte & 0x7F) << (7 * idx) idx += 1 return result
[ "def", "load_uvarint_b", "(", "buffer", ")", ":", "result", "=", "0", "idx", "=", "0", "byte", "=", "0x80", "while", "byte", "&", "0x80", ":", "byte", "=", "buffer", "[", "idx", "]", "result", "+=", "(", "byte", "&", "0x7F", ")", "<<", "(", "7", ...
Variable int deserialization, synchronous from buffer. :param buffer: :return:
[ "Variable", "int", "deserialization", "synchronous", "from", "buffer", ".", ":", "param", "buffer", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L49-L62
train
Variable int deserialization synchronous from buffer.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
dump_uvarint_b_into
def dump_uvarint_b_into(n, buffer, offset=0): """ Serializes n as variable size integer to the provided buffer. Buffer has to ha :param n: :param buffer: :param offset: :return: """ shifted = True while shifted: shifted = n >> 7 buffer[offset] = (n & 0x7F) | (0x80...
python
def dump_uvarint_b_into(n, buffer, offset=0): """ Serializes n as variable size integer to the provided buffer. Buffer has to ha :param n: :param buffer: :param offset: :return: """ shifted = True while shifted: shifted = n >> 7 buffer[offset] = (n & 0x7F) | (0x80...
[ "def", "dump_uvarint_b_into", "(", "n", ",", "buffer", ",", "offset", "=", "0", ")", ":", "shifted", "=", "True", "while", "shifted", ":", "shifted", "=", "n", ">>", "7", "buffer", "[", "offset", "]", "=", "(", "n", "&", "0x7F", ")", "|", "(", "0...
Serializes n as variable size integer to the provided buffer. Buffer has to ha :param n: :param buffer: :param offset: :return:
[ "Serializes", "n", "as", "variable", "size", "integer", "to", "the", "provided", "buffer", ".", "Buffer", "has", "to", "ha", ":", "param", "n", ":", ":", "param", "buffer", ":", ":", "param", "offset", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L75-L90
train
Serializes n as variable size integer to the provided buffer.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
load_uint_b
def load_uint_b(buffer, width): """ Loads fixed size integer from the buffer :param buffer: :return: """ result = 0 for idx in range(width): result += buffer[idx] << (8 * idx) return result
python
def load_uint_b(buffer, width): """ Loads fixed size integer from the buffer :param buffer: :return: """ result = 0 for idx in range(width): result += buffer[idx] << (8 * idx) return result
[ "def", "load_uint_b", "(", "buffer", ",", "width", ")", ":", "result", "=", "0", "for", "idx", "in", "range", "(", "width", ")", ":", "result", "+=", "buffer", "[", "idx", "]", "<<", "(", "8", "*", "idx", ")", "return", "result" ]
Loads fixed size integer from the buffer :param buffer: :return:
[ "Loads", "fixed", "size", "integer", "from", "the", "buffer", ":", "param", "buffer", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L93-L102
train
Load fixed size integer from the buffer.
ph4r05/monero-serialize
monero_serialize/core/int_serialize.py
dump_uint_b_into
def dump_uint_b_into(n, width, buffer, offset=0): """ Serializes fixed size integer to the buffer :param n: :param width: :return: """ for idx in range(width): buffer[idx + offset] = n & 0xff n >>= 8 return buffer
python
def dump_uint_b_into(n, width, buffer, offset=0): """ Serializes fixed size integer to the buffer :param n: :param width: :return: """ for idx in range(width): buffer[idx + offset] = n & 0xff n >>= 8 return buffer
[ "def", "dump_uint_b_into", "(", "n", ",", "width", ",", "buffer", ",", "offset", "=", "0", ")", ":", "for", "idx", "in", "range", "(", "width", ")", ":", "buffer", "[", "idx", "+", "offset", "]", "=", "n", "&", "0xff", "n", ">>=", "8", "return", ...
Serializes fixed size integer to the buffer :param n: :param width: :return:
[ "Serializes", "fixed", "size", "integer", "to", "the", "buffer", ":", "param", "n", ":", ":", "param", "width", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/core/int_serialize.py#L116-L126
train
Serializes fixed size integer into a buffer.
ets-labs/python-domain-models
domain_models/fields.py
Field.bind_name
def bind_name(self, name): """Bind field to its name in model class.""" if self.name: raise errors.Error('Already bound "{0}" with name "{1}" could not ' 'be rebound'.format(self, self.name)) self.name = name self.storage_name = ''.join(('_', se...
python
def bind_name(self, name): """Bind field to its name in model class.""" if self.name: raise errors.Error('Already bound "{0}" with name "{1}" could not ' 'be rebound'.format(self, self.name)) self.name = name self.storage_name = ''.join(('_', se...
[ "def", "bind_name", "(", "self", ",", "name", ")", ":", "if", "self", ".", "name", ":", "raise", "errors", ".", "Error", "(", "'Already bound \"{0}\" with name \"{1}\" could not '", "'be rebound'", ".", "format", "(", "self", ",", "self", ".", "name", ")", "...
Bind field to its name in model class.
[ "Bind", "field", "to", "its", "name", "in", "model", "class", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L24-L31
train
Bind field to its name in model class.
ets-labs/python-domain-models
domain_models/fields.py
Field.bind_model_cls
def bind_model_cls(self, model_cls): """Bind field to model class.""" if self.model_cls: raise errors.Error('"{0}" has been already bound to "{1}" and ' 'could not be rebound to "{2}"'.format( self, self.model_cls, model_cls))...
python
def bind_model_cls(self, model_cls): """Bind field to model class.""" if self.model_cls: raise errors.Error('"{0}" has been already bound to "{1}" and ' 'could not be rebound to "{2}"'.format( self, self.model_cls, model_cls))...
[ "def", "bind_model_cls", "(", "self", ",", "model_cls", ")", ":", "if", "self", ".", "model_cls", ":", "raise", "errors", ".", "Error", "(", "'\"{0}\" has been already bound to \"{1}\" and '", "'could not be rebound to \"{2}\"'", ".", "format", "(", "self", ",", "se...
Bind field to model class.
[ "Bind", "field", "to", "model", "class", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L33-L40
train
Bind field to model class.
ets-labs/python-domain-models
domain_models/fields.py
Field.init_model
def init_model(self, model, value): """Init model with field. :param DomainModel model: :param object value: """ if value is None and self.default is not None: value = self.default() if callable(self.default) else self.default self.set_value(model, value)
python
def init_model(self, model, value): """Init model with field. :param DomainModel model: :param object value: """ if value is None and self.default is not None: value = self.default() if callable(self.default) else self.default self.set_value(model, value)
[ "def", "init_model", "(", "self", ",", "model", ",", "value", ")", ":", "if", "value", "is", "None", "and", "self", ".", "default", "is", "not", "None", ":", "value", "=", "self", ".", "default", "(", ")", "if", "callable", "(", "self", ".", "defau...
Init model with field. :param DomainModel model: :param object value:
[ "Init", "model", "with", "field", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L42-L51
train
Init model with field.
ets-labs/python-domain-models
domain_models/fields.py
Field.get_value
def get_value(self, model, default=None): """Return field's value. :param DomainModel model: :param object default: :rtype object: """ if default is not None: default = self._converter(default) value = getattr(model, self.storage_name) return...
python
def get_value(self, model, default=None): """Return field's value. :param DomainModel model: :param object default: :rtype object: """ if default is not None: default = self._converter(default) value = getattr(model, self.storage_name) return...
[ "def", "get_value", "(", "self", ",", "model", ",", "default", "=", "None", ")", ":", "if", "default", "is", "not", "None", ":", "default", "=", "self", ".", "_converter", "(", "default", ")", "value", "=", "getattr", "(", "model", ",", "self", ".", ...
Return field's value. :param DomainModel model: :param object default: :rtype object:
[ "Return", "field", "s", "value", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L53-L64
train
Return field s value.
ets-labs/python-domain-models
domain_models/fields.py
Field.set_value
def set_value(self, model, value): """Set field's value. :param DomainModel model: :param object value: """ if value is None and self.required: raise AttributeError("This field is required.") if value is not None: value = self._converter(value) ...
python
def set_value(self, model, value): """Set field's value. :param DomainModel model: :param object value: """ if value is None and self.required: raise AttributeError("This field is required.") if value is not None: value = self._converter(value) ...
[ "def", "set_value", "(", "self", ",", "model", ",", "value", ")", ":", "if", "value", "is", "None", "and", "self", ".", "required", ":", "raise", "AttributeError", "(", "\"This field is required.\"", ")", "if", "value", "is", "not", "None", ":", "value", ...
Set field's value. :param DomainModel model: :param object value:
[ "Set", "field", "s", "value", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L66-L78
train
Set field s value.
ets-labs/python-domain-models
domain_models/fields.py
Field._get_model_instance
def _get_model_instance(model_cls, data): """Convert dict into object of class of passed model. :param class model_cls: :param object data: :rtype DomainModel: """ if not isinstance(data, (model_cls, dict)): raise TypeError('{0} is not valid type, instance of...
python
def _get_model_instance(model_cls, data): """Convert dict into object of class of passed model. :param class model_cls: :param object data: :rtype DomainModel: """ if not isinstance(data, (model_cls, dict)): raise TypeError('{0} is not valid type, instance of...
[ "def", "_get_model_instance", "(", "model_cls", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "(", "model_cls", ",", "dict", ")", ")", ":", "raise", "TypeError", "(", "'{0} is not valid type, instance of '", "'{1} or dict required'", ".", "...
Convert dict into object of class of passed model. :param class model_cls: :param object data: :rtype DomainModel:
[ "Convert", "dict", "into", "object", "of", "class", "of", "passed", "model", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L97-L107
train
Convert dict into object of class model_cls.
ets-labs/python-domain-models
domain_models/fields.py
Date._converter
def _converter(self, value): """Convert raw input value of the field.""" if not isinstance(value, datetime.date): raise TypeError('{0} is not valid date'.format(value)) return value
python
def _converter(self, value): """Convert raw input value of the field.""" if not isinstance(value, datetime.date): raise TypeError('{0} is not valid date'.format(value)) return value
[ "def", "_converter", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ".", "date", ")", ":", "raise", "TypeError", "(", "'{0} is not valid date'", ".", "format", "(", "value", ")", ")", "return", "value" ]
Convert raw input value of the field.
[ "Convert", "raw", "input", "value", "of", "the", "field", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L153-L157
train
Convert raw input value of the field.
ets-labs/python-domain-models
domain_models/fields.py
Collection._converter
def _converter(self, value): """Convert raw input value of the field. :param object value: :rtype object: """ if type(value) is not self.related_model_cls.Collection: value = self.related_model_cls.Collection([ self._get_model_instance(self.related_mo...
python
def _converter(self, value): """Convert raw input value of the field. :param object value: :rtype object: """ if type(value) is not self.related_model_cls.Collection: value = self.related_model_cls.Collection([ self._get_model_instance(self.related_mo...
[ "def", "_converter", "(", "self", ",", "value", ")", ":", "if", "type", "(", "value", ")", "is", "not", "self", ".", "related_model_cls", ".", "Collection", ":", "value", "=", "self", ".", "related_model_cls", ".", "Collection", "(", "[", "self", ".", ...
Convert raw input value of the field. :param object value: :rtype object:
[ "Convert", "raw", "input", "value", "of", "the", "field", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L203-L213
train
Convert raw input value of the field.
ets-labs/python-domain-models
domain_models/fields.py
Collection.get_builtin_type
def get_builtin_type(self, model): """Return built-in type representation of Collection. :param DomainModel model: :rtype list: """ return [item.get_data() if isinstance(item, self.related_model_cls) else item for item in self.get_value(model)]
python
def get_builtin_type(self, model): """Return built-in type representation of Collection. :param DomainModel model: :rtype list: """ return [item.get_data() if isinstance(item, self.related_model_cls) else item for item in self.get_value(model)]
[ "def", "get_builtin_type", "(", "self", ",", "model", ")", ":", "return", "[", "item", ".", "get_data", "(", ")", "if", "isinstance", "(", "item", ",", "self", ".", "related_model_cls", ")", "else", "item", "for", "item", "in", "self", ".", "get_value", ...
Return built-in type representation of Collection. :param DomainModel model: :rtype list:
[ "Return", "built", "-", "in", "type", "representation", "of", "Collection", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/fields.py#L215-L222
train
Return built - in type representation of Collection.
useblocks/groundwork
groundwork/docstring.py
parse
def parse(text): """ Parse the docstring into its components. :returns: parsed docstring """ ret = Docstring() if not text: return ret text = inspect.cleandoc(text) match = re.search('^:', text, flags=re.M) if match: desc_chunk = text[:match.start()] meta_ch...
python
def parse(text): """ Parse the docstring into its components. :returns: parsed docstring """ ret = Docstring() if not text: return ret text = inspect.cleandoc(text) match = re.search('^:', text, flags=re.M) if match: desc_chunk = text[:match.start()] meta_ch...
[ "def", "parse", "(", "text", ")", ":", "ret", "=", "Docstring", "(", ")", "if", "not", "text", ":", "return", "ret", "text", "=", "inspect", ".", "cleandoc", "(", "text", ")", "match", "=", "re", ".", "search", "(", "'^:'", ",", "text", ",", "fla...
Parse the docstring into its components. :returns: parsed docstring
[ "Parse", "the", "docstring", "into", "its", "components", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L146-L192
train
Parse the docstring into its components.
useblocks/groundwork
groundwork/docstring.py
DocstringMeta.from_meta
def from_meta(cls, meta, meta_all=None): """Copy DocstringMeta from another instance.""" if len(meta.args) == 2: name = meta.args[1] meta_type = None for x in meta_all: if x.args[1] == name and x.args[0] == 'type': meta_type = x.des...
python
def from_meta(cls, meta, meta_all=None): """Copy DocstringMeta from another instance.""" if len(meta.args) == 2: name = meta.args[1] meta_type = None for x in meta_all: if x.args[1] == name and x.args[0] == 'type': meta_type = x.des...
[ "def", "from_meta", "(", "cls", ",", "meta", ",", "meta_all", "=", "None", ")", ":", "if", "len", "(", "meta", ".", "args", ")", "==", "2", ":", "name", "=", "meta", ".", "args", "[", "1", "]", "meta_type", "=", "None", "for", "x", "in", "meta_...
Copy DocstringMeta from another instance.
[ "Copy", "DocstringMeta", "from", "another", "instance", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L44-L56
train
Copy DocstringMeta from another instance.
useblocks/groundwork
groundwork/docstring.py
DocstringParam.arg_name
def arg_name(self): """Return argument name associated with given param.""" if len(self.args) > 2: return self.args[2] elif len(self.args) > 1: return self.args[1] return None
python
def arg_name(self): """Return argument name associated with given param.""" if len(self.args) > 2: return self.args[2] elif len(self.args) > 1: return self.args[1] return None
[ "def", "arg_name", "(", "self", ")", ":", "if", "len", "(", "self", ".", "args", ")", ">", "2", ":", "return", "self", ".", "args", "[", "2", "]", "elif", "len", "(", "self", ".", "args", ")", ">", "1", ":", "return", "self", ".", "args", "["...
Return argument name associated with given param.
[ "Return", "argument", "name", "associated", "with", "given", "param", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L72-L78
train
Return argument name associated with given param.
useblocks/groundwork
groundwork/docstring.py
Docstring.params
def params(self): """Return list of :param meta.""" return [ DocstringParam.from_meta(meta, self.meta) for meta in self.meta if meta.args[0] in { 'param', 'parameter', 'arg', 'argument', 'key', 'keyword' } ]
python
def params(self): """Return list of :param meta.""" return [ DocstringParam.from_meta(meta, self.meta) for meta in self.meta if meta.args[0] in { 'param', 'parameter', 'arg', 'argument', 'key', 'keyword' } ]
[ "def", "params", "(", "self", ")", ":", "return", "[", "DocstringParam", ".", "from_meta", "(", "meta", ",", "self", ".", "meta", ")", "for", "meta", "in", "self", ".", "meta", "if", "meta", ".", "args", "[", "0", "]", "in", "{", "'param'", ",", ...
Return list of :param meta.
[ "Return", "list", "of", ":", "param", "meta", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L114-L122
train
Return list of DocstringParam.
useblocks/groundwork
groundwork/docstring.py
Docstring.raises
def raises(self): """Return list of :raises meta.""" return [ DocstringRaises.from_meta(meta) for meta in self.meta if meta.args[0] in {'raises', 'raise', 'except', 'exception'} ]
python
def raises(self): """Return list of :raises meta.""" return [ DocstringRaises.from_meta(meta) for meta in self.meta if meta.args[0] in {'raises', 'raise', 'except', 'exception'} ]
[ "def", "raises", "(", "self", ")", ":", "return", "[", "DocstringRaises", ".", "from_meta", "(", "meta", ")", "for", "meta", "in", "self", ".", "meta", "if", "meta", ".", "args", "[", "0", "]", "in", "{", "'raises'", ",", "'raise'", ",", "'except'", ...
Return list of :raises meta.
[ "Return", "list", "of", ":", "raises", "meta", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/docstring.py#L125-L131
train
Return list of DocstringRaises.
useblocks/groundwork
groundwork/util.py
gw_get
def gw_get(object_dict, name=None, plugin=None): """ Getter function to retrieve objects from a given object dictionary. Used mainly to provide get() inside patterns. :param object_dict: objects, which must have 'name' and 'plugin' as attribute :type object_dict: dictionary :param name: name o...
python
def gw_get(object_dict, name=None, plugin=None): """ Getter function to retrieve objects from a given object dictionary. Used mainly to provide get() inside patterns. :param object_dict: objects, which must have 'name' and 'plugin' as attribute :type object_dict: dictionary :param name: name o...
[ "def", "gw_get", "(", "object_dict", ",", "name", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "name", "is", "None", ":", "object_list", "=", "{", "}", "for", "key", "in", "object_dict", ".", "k...
Getter function to retrieve objects from a given object dictionary. Used mainly to provide get() inside patterns. :param object_dict: objects, which must have 'name' and 'plugin' as attribute :type object_dict: dictionary :param name: name of the object :type name: str :param plugin: plugin na...
[ "Getter", "function", "to", "retrieve", "objects", "from", "a", "given", "object", "dictionary", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/util.py#L1-L36
train
Get a single object or dict of objects from a given object dictionary.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/httpbakery/_discharge.py
discharge
def discharge(ctx, content, key, locator, checker): '''Handles a discharge request as received by the /discharge endpoint. @param ctx The context passed to the checker {checkers.AuthContext} @param content URL and form parameters {dict} @param locator Locator used to add third party caveats returned...
python
def discharge(ctx, content, key, locator, checker): '''Handles a discharge request as received by the /discharge endpoint. @param ctx The context passed to the checker {checkers.AuthContext} @param content URL and form parameters {dict} @param locator Locator used to add third party caveats returned...
[ "def", "discharge", "(", "ctx", ",", "content", ",", "key", ",", "locator", ",", "checker", ")", ":", "id", "=", "content", ".", "get", "(", "'id'", ")", "if", "id", "is", "not", "None", ":", "id", "=", "id", ".", "encode", "(", "'utf-8'", ")", ...
Handles a discharge request as received by the /discharge endpoint. @param ctx The context passed to the checker {checkers.AuthContext} @param content URL and form parameters {dict} @param locator Locator used to add third party caveats returned by the checker {macaroonbakery.ThirdPartyLocator} ...
[ "Handles", "a", "discharge", "request", "as", "received", "by", "the", "/", "discharge", "endpoint", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/httpbakery/_discharge.py#L7-L37
train
Handles a discharge request from the macaroon server.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
http_error_handler
def http_error_handler(f): """Handle 404 errors returned by the API server """ def hrefs_to_resources(hrefs): for href in hrefs.replace(',', '').split(): type, uuid = href.split('/')[-2:] yield Resource(type, uuid=uuid) def hrefs_list_to_resources(hrefs_list): f...
python
def http_error_handler(f): """Handle 404 errors returned by the API server """ def hrefs_to_resources(hrefs): for href in hrefs.replace(',', '').split(): type, uuid = href.split('/')[-2:] yield Resource(type, uuid=uuid) def hrefs_list_to_resources(hrefs_list): f...
[ "def", "http_error_handler", "(", "f", ")", ":", "def", "hrefs_to_resources", "(", "hrefs", ")", ":", "for", "href", "in", "hrefs", ".", "replace", "(", "','", ",", "''", ")", ".", "split", "(", ")", ":", "type", ",", "uuid", "=", "href", ".", "spl...
Handle 404 errors returned by the API server
[ "Handle", "404", "errors", "returned", "by", "the", "API", "server" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L30-L77
train
Handle 404 errors returned by the API server.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
ResourceBase.href
def href(self): """Return URL of the resource :rtype: str """ url = self.session.base_url + str(self.path) if self.path.is_collection and not self.path.is_root: return url + 's' return url
python
def href(self): """Return URL of the resource :rtype: str """ url = self.session.base_url + str(self.path) if self.path.is_collection and not self.path.is_root: return url + 's' return url
[ "def", "href", "(", "self", ")", ":", "url", "=", "self", ".", "session", ".", "base_url", "+", "str", "(", "self", ".", "path", ")", "if", "self", ".", "path", ".", "is_collection", "and", "not", "self", ".", "path", ".", "is_root", ":", "return",...
Return URL of the resource :rtype: str
[ "Return", "URL", "of", "the", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L205-L213
train
Return the URL of the resource in the base URL.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Collection.filter
def filter(self, field_name, field_value): """Add permanent filter on the collection :param field_name: name of the field to filter on :type field_name: str :param field_value: value to filter on :rtype: Collection """ self.filters.append((field_name, field_valu...
python
def filter(self, field_name, field_value): """Add permanent filter on the collection :param field_name: name of the field to filter on :type field_name: str :param field_value: value to filter on :rtype: Collection """ self.filters.append((field_name, field_valu...
[ "def", "filter", "(", "self", ",", "field_name", ",", "field_value", ")", ":", "self", ".", "filters", ".", "append", "(", "(", "field_name", ",", "field_value", ")", ")", "return", "self" ]
Add permanent filter on the collection :param field_name: name of the field to filter on :type field_name: str :param field_value: value to filter on :rtype: Collection
[ "Add", "permanent", "filter", "on", "the", "collection" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L299-L309
train
Add a permanent filter on the collection
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Collection.fetch
def fetch(self, recursive=1, fields=None, detail=None, filters=None, parent_uuid=None, back_refs_uuid=None): """ Fetch collection from API server :param recursive: level of recursion :type recursive: int :param fields: fetch only listed fields. ...
python
def fetch(self, recursive=1, fields=None, detail=None, filters=None, parent_uuid=None, back_refs_uuid=None): """ Fetch collection from API server :param recursive: level of recursion :type recursive: int :param fields: fetch only listed fields. ...
[ "def", "fetch", "(", "self", ",", "recursive", "=", "1", ",", "fields", "=", "None", ",", "detail", "=", "None", ",", "filters", "=", "None", ",", "parent_uuid", "=", "None", ",", "back_refs_uuid", "=", "None", ")", ":", "params", "=", "self", ".", ...
Fetch collection from API server :param recursive: level of recursion :type recursive: int :param fields: fetch only listed fields. contrail 3.0 required :type fields: [str] :param detail: fetch all fields :type detail: bool :param filters:...
[ "Fetch", "collection", "from", "API", "server" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L346-L393
train
Fetch all the related resources from API server.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.check
def check(self): """Check that the resource exists. :raises ResourceNotFound: if the resource doesn't exists """ if self.fq_name: self['uuid'] = self._check_fq_name(self.fq_name) elif self.uuid: self['fq_name'] = self._check_uuid(self.uuid) return...
python
def check(self): """Check that the resource exists. :raises ResourceNotFound: if the resource doesn't exists """ if self.fq_name: self['uuid'] = self._check_fq_name(self.fq_name) elif self.uuid: self['fq_name'] = self._check_uuid(self.uuid) return...
[ "def", "check", "(", "self", ")", ":", "if", "self", ".", "fq_name", ":", "self", "[", "'uuid'", "]", "=", "self", ".", "_check_fq_name", "(", "self", ".", "fq_name", ")", "elif", "self", ".", "uuid", ":", "self", "[", "'fq_name'", "]", "=", "self"...
Check that the resource exists. :raises ResourceNotFound: if the resource doesn't exists
[ "Check", "that", "the", "resource", "exists", "." ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L488-L497
train
Check that the resource exists.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.fq_name
def fq_name(self): """Return FQDN of the resource :rtype: FQName """ return self.get('fq_name', self.get('to', super(Resource, self).fq_name))
python
def fq_name(self): """Return FQDN of the resource :rtype: FQName """ return self.get('fq_name', self.get('to', super(Resource, self).fq_name))
[ "def", "fq_name", "(", "self", ")", ":", "return", "self", ".", "get", "(", "'fq_name'", ",", "self", ".", "get", "(", "'to'", ",", "super", "(", "Resource", ",", "self", ")", ".", "fq_name", ")", ")" ]
Return FQDN of the resource :rtype: FQName
[ "Return", "FQDN", "of", "the", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L529-L534
train
Return the FQDN of the resource
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.parent
def parent(self): """Return parent resource :rtype: Resource :raises ResourceNotFound: parent resource doesn't exists :raises ResourceMissing: parent resource is not defined """ try: return Resource(self['parent_type'], uuid=self['parent_uuid'], check=True) ...
python
def parent(self): """Return parent resource :rtype: Resource :raises ResourceNotFound: parent resource doesn't exists :raises ResourceMissing: parent resource is not defined """ try: return Resource(self['parent_type'], uuid=self['parent_uuid'], check=True) ...
[ "def", "parent", "(", "self", ")", ":", "try", ":", "return", "Resource", "(", "self", "[", "'parent_type'", "]", ",", "uuid", "=", "self", "[", "'parent_uuid'", "]", ",", "check", "=", "True", ")", "except", "KeyError", ":", "raise", "ResourceMissing", ...
Return parent resource :rtype: Resource :raises ResourceNotFound: parent resource doesn't exists :raises ResourceMissing: parent resource is not defined
[ "Return", "parent", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L537-L547
train
Return parent resource
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.parent
def parent(self, resource): """Set parent resource :param resource: parent resource :type resource: Resource :raises ResourceNotFound: resource not found on the API """ resource.check() self['parent_type'] = resource.type self['parent_uuid'] = resource.u...
python
def parent(self, resource): """Set parent resource :param resource: parent resource :type resource: Resource :raises ResourceNotFound: resource not found on the API """ resource.check() self['parent_type'] = resource.type self['parent_uuid'] = resource.u...
[ "def", "parent", "(", "self", ",", "resource", ")", ":", "resource", ".", "check", "(", ")", "self", "[", "'parent_type'", "]", "=", "resource", ".", "type", "self", "[", "'parent_uuid'", "]", "=", "resource", ".", "uuid" ]
Set parent resource :param resource: parent resource :type resource: Resource :raises ResourceNotFound: resource not found on the API
[ "Set", "parent", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L550-L560
train
Set parent resource
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.created
def created(self): """Return creation date :rtype: datetime :raises ResourceNotFound: resource not found on the API """ if 'id_perms' not in self: self.fetch() created = self['id_perms']['created'] return datetime.strptime(created, '%Y-%m-%dT%H:%M:%S....
python
def created(self): """Return creation date :rtype: datetime :raises ResourceNotFound: resource not found on the API """ if 'id_perms' not in self: self.fetch() created = self['id_perms']['created'] return datetime.strptime(created, '%Y-%m-%dT%H:%M:%S....
[ "def", "created", "(", "self", ")", ":", "if", "'id_perms'", "not", "in", "self", ":", "self", ".", "fetch", "(", ")", "created", "=", "self", "[", "'id_perms'", "]", "[", "'created'", "]", "return", "datetime", ".", "strptime", "(", "created", ",", ...
Return creation date :rtype: datetime :raises ResourceNotFound: resource not found on the API
[ "Return", "creation", "date" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L563-L572
train
Return creation date of the resource in the API.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.save
def save(self): """Save the resource to the API server If the resource doesn't have a uuid the resource will be created. If uuid is present the resource is updated. :rtype: Resource """ if self.path.is_collection: self.session.post_json(self.href, ...
python
def save(self): """Save the resource to the API server If the resource doesn't have a uuid the resource will be created. If uuid is present the resource is updated. :rtype: Resource """ if self.path.is_collection: self.session.post_json(self.href, ...
[ "def", "save", "(", "self", ")", ":", "if", "self", ".", "path", ".", "is_collection", ":", "self", ".", "session", ".", "post_json", "(", "self", ".", "href", ",", "{", "self", ".", "type", ":", "dict", "(", "self", ".", "data", ")", "}", ",", ...
Save the resource to the API server If the resource doesn't have a uuid the resource will be created. If uuid is present the resource is updated. :rtype: Resource
[ "Save", "the", "resource", "to", "the", "API", "server" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L575-L591
train
Save the resource to the API server.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.delete
def delete(self): """Delete resource from the API server """ res = self.session.delete(self.href) self.emit('deleted', self) return res
python
def delete(self): """Delete resource from the API server """ res = self.session.delete(self.href) self.emit('deleted', self) return res
[ "def", "delete", "(", "self", ")", ":", "res", "=", "self", ".", "session", ".", "delete", "(", "self", ".", "href", ")", "self", ".", "emit", "(", "'deleted'", ",", "self", ")", "return", "res" ]
Delete resource from the API server
[ "Delete", "resource", "from", "the", "API", "server" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L594-L599
train
Delete resource from the API server
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.fetch
def fetch(self, recursive=1, exclude_children=False, exclude_back_refs=False): """Fetch resource from the API server :param recursive: level of recursion for fetching resources :type recursive: int :param exclude_children: don't get children references :type exclude_children: bo...
python
def fetch(self, recursive=1, exclude_children=False, exclude_back_refs=False): """Fetch resource from the API server :param recursive: level of recursion for fetching resources :type recursive: int :param exclude_children: don't get children references :type exclude_children: bo...
[ "def", "fetch", "(", "self", ",", "recursive", "=", "1", ",", "exclude_children", "=", "False", ",", "exclude_back_refs", "=", "False", ")", ":", "if", "not", "self", ".", "path", ".", "is_resource", "and", "not", "self", ".", "path", ".", "is_uuid", "...
Fetch resource from the API server :param recursive: level of recursion for fetching resources :type recursive: int :param exclude_children: don't get children references :type exclude_children: bool :param exclude_back_refs: don't get back_refs references :type exclude_...
[ "Fetch", "resource", "from", "the", "API", "server" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L602-L624
train
Fetch the resource from the API server.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.from_dict
def from_dict(self, data, recursive=1): """Populate the resource from a python dict :param recursive: level of recursion for fetching resources :type recursive: int """ # Find other linked resources data = self._encode_resource(data, recursive=recursive) self.dat...
python
def from_dict(self, data, recursive=1): """Populate the resource from a python dict :param recursive: level of recursion for fetching resources :type recursive: int """ # Find other linked resources data = self._encode_resource(data, recursive=recursive) self.dat...
[ "def", "from_dict", "(", "self", ",", "data", ",", "recursive", "=", "1", ")", ":", "# Find other linked resources", "data", "=", "self", ".", "_encode_resource", "(", "data", ",", "recursive", "=", "recursive", ")", "self", ".", "data", "=", "data" ]
Populate the resource from a python dict :param recursive: level of recursion for fetching resources :type recursive: int
[ "Populate", "the", "resource", "from", "a", "python", "dict" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L626-L634
train
Populate the resource from a python dict.
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.remove_ref
def remove_ref(self, ref): """Remove reference from self to ref >>> iip = Resource('instance-ip', uuid='30213cf9-4b03-4afc-b8f9-c9971a216978', fetch=True) >>> for vmi in iip['virtual_machine_interface_refs']: iip.remove_ref(v...
python
def remove_ref(self, ref): """Remove reference from self to ref >>> iip = Resource('instance-ip', uuid='30213cf9-4b03-4afc-b8f9-c9971a216978', fetch=True) >>> for vmi in iip['virtual_machine_interface_refs']: iip.remove_ref(v...
[ "def", "remove_ref", "(", "self", ",", "ref", ")", ":", "self", ".", "session", ".", "remove_ref", "(", "self", ",", "ref", ")", "return", "self", ".", "fetch", "(", ")" ]
Remove reference from self to ref >>> iip = Resource('instance-ip', uuid='30213cf9-4b03-4afc-b8f9-c9971a216978', fetch=True) >>> for vmi in iip['virtual_machine_interface_refs']: iip.remove_ref(vmi) >>> iip['virtual_machine_i...
[ "Remove", "reference", "from", "self", "to", "ref" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L669-L686
train
Remove reference from self to ref
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.set_ref
def set_ref(self, ref, attr=None): """Set reference to resource Can be used to set references on a resource that is not already created. :param ref: reference to add :type ref: Resource :rtype: Resource """ ref_attr = '%s_refs' % ref.type.replace('-', '...
python
def set_ref(self, ref, attr=None): """Set reference to resource Can be used to set references on a resource that is not already created. :param ref: reference to add :type ref: Resource :rtype: Resource """ ref_attr = '%s_refs' % ref.type.replace('-', '...
[ "def", "set_ref", "(", "self", ",", "ref", ",", "attr", "=", "None", ")", ":", "ref_attr", "=", "'%s_refs'", "%", "ref", ".", "type", ".", "replace", "(", "'-'", ",", "'_'", ")", "ref", "=", "{", "'to'", ":", "ref", ".", "fq_name", ",", "'uuid'",...
Set reference to resource Can be used to set references on a resource that is not already created. :param ref: reference to add :type ref: Resource :rtype: Resource
[ "Set", "reference", "to", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L699-L719
train
Set the reference to a resource
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.add_ref
def add_ref(self, ref, attr=None): """Add reference to resource :param ref: reference to add :type ref: Resource :rtype: Resource """ self.session.add_ref(self, ref, attr) return self.fetch()
python
def add_ref(self, ref, attr=None): """Add reference to resource :param ref: reference to add :type ref: Resource :rtype: Resource """ self.session.add_ref(self, ref, attr) return self.fetch()
[ "def", "add_ref", "(", "self", ",", "ref", ",", "attr", "=", "None", ")", ":", "self", ".", "session", ".", "add_ref", "(", "self", ",", "ref", ",", "attr", ")", "return", "self", ".", "fetch", "(", ")" ]
Add reference to resource :param ref: reference to add :type ref: Resource :rtype: Resource
[ "Add", "reference", "to", "resource" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L721-L730
train
Add a reference to the resource
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
Resource.add_back_ref
def add_back_ref(self, back_ref, attr=None): """Add reference from back_ref to self :param back_ref: back_ref to add :type back_ref: Resource :rtype: Resource """ back_ref.add_ref(self, attr) return self.fetch()
python
def add_back_ref(self, back_ref, attr=None): """Add reference from back_ref to self :param back_ref: back_ref to add :type back_ref: Resource :rtype: Resource """ back_ref.add_ref(self, attr) return self.fetch()
[ "def", "add_back_ref", "(", "self", ",", "back_ref", ",", "attr", "=", "None", ")", ":", "back_ref", ".", "add_ref", "(", "self", ",", "attr", ")", "return", "self", ".", "fetch", "(", ")" ]
Add reference from back_ref to self :param back_ref: back_ref to add :type back_ref: Resource :rtype: Resource
[ "Add", "reference", "from", "back_ref", "to", "self" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L732-L741
train
Add reference from back_ref to self
eonpatapon/contrail-api-cli
contrail_api_cli/resource.py
ResourceCache._search
def _search(self, trie, strings, limit=None): """Search in cache :param strings: list of strings to get from the cache :type strings: str list :param limit: limit search results :type limit: int :rtype: [Resource | Collection] """ results = [trie.has_key...
python
def _search(self, trie, strings, limit=None): """Search in cache :param strings: list of strings to get from the cache :type strings: str list :param limit: limit search results :type limit: int :rtype: [Resource | Collection] """ results = [trie.has_key...
[ "def", "_search", "(", "self", ",", "trie", ",", "strings", ",", "limit", "=", "None", ")", ":", "results", "=", "[", "trie", ".", "has_keys_with_prefix", "(", "s", ")", "for", "s", "in", "strings", "]", "if", "not", "any", "(", "results", ")", ":"...
Search in cache :param strings: list of strings to get from the cache :type strings: str list :param limit: limit search results :type limit: int :rtype: [Resource | Collection]
[ "Search", "in", "cache" ]
1571bf523fa054f3d6bf83dba43a224fea173a73
https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L777-L792
train
Search in cache
useblocks/groundwork
groundwork/signals.py
SignalsApplication.register
def register(self, signal, plugin, description=""): """ Registers a new signal. :param signal: Unique name of the signal :param plugin: Plugin, which registers the new signal :param description: Description of the reason or use case, why this signal is needed. ...
python
def register(self, signal, plugin, description=""): """ Registers a new signal. :param signal: Unique name of the signal :param plugin: Plugin, which registers the new signal :param description: Description of the reason or use case, why this signal is needed. ...
[ "def", "register", "(", "self", ",", "signal", ",", "plugin", ",", "description", "=", "\"\"", ")", ":", "if", "signal", "in", "self", ".", "signals", ".", "keys", "(", ")", ":", "raise", "Exception", "(", "\"Signal %s was already registered by %s\"", "%", ...
Registers a new signal. :param signal: Unique name of the signal :param plugin: Plugin, which registers the new signal :param description: Description of the reason or use case, why this signal is needed. Used for documentation.
[ "Registers", "a", "new", "signal", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L48-L62
train
Registers a new signal.
useblocks/groundwork
groundwork/signals.py
SignalsApplication.unregister
def unregister(self, signal): """ Unregisters an existing signal :param signal: Name of the signal """ if signal in self.signals.keys(): del(self.signals[signal]) self.__log.debug("Signal %s unregisterd" % signal) else: self.__log.debu...
python
def unregister(self, signal): """ Unregisters an existing signal :param signal: Name of the signal """ if signal in self.signals.keys(): del(self.signals[signal]) self.__log.debug("Signal %s unregisterd" % signal) else: self.__log.debu...
[ "def", "unregister", "(", "self", ",", "signal", ")", ":", "if", "signal", "in", "self", ".", "signals", ".", "keys", "(", ")", ":", "del", "(", "self", ".", "signals", "[", "signal", "]", ")", "self", ".", "__log", ".", "debug", "(", "\"Signal %s ...
Unregisters an existing signal :param signal: Name of the signal
[ "Unregisters", "an", "existing", "signal" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L64-L74
train
Unregisters an existing signal
useblocks/groundwork
groundwork/signals.py
SignalsApplication.connect
def connect(self, receiver, signal, function, plugin, description="", sender=None): """ Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :para...
python
def connect(self, receiver, signal, function, plugin, description="", sender=None): """ Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :para...
[ "def", "connect", "(", "self", ",", "receiver", ",", "signal", ",", "function", ",", "plugin", ",", "description", "=", "\"\"", ",", "sender", "=", "None", ")", ":", "if", "receiver", "in", "self", ".", "receivers", ".", "keys", "(", ")", ":", "raise...
Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :param function: Callable functions, which shall be executed, of signal is send. :param plugin: The p...
[ "Connect", "a", "receiver", "to", "a", "signal" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L76-L96
train
Connect a receiver to a signal
useblocks/groundwork
groundwork/signals.py
SignalsApplication.disconnect
def disconnect(self, receiver): """ Disconnect a receiver from a signal. Signal and receiver must exist, otherwise an exception is thrown. :param receiver: Name of the receiver """ if receiver not in self.receivers.keys(): raise Exception("No receiver %s was ...
python
def disconnect(self, receiver): """ Disconnect a receiver from a signal. Signal and receiver must exist, otherwise an exception is thrown. :param receiver: Name of the receiver """ if receiver not in self.receivers.keys(): raise Exception("No receiver %s was ...
[ "def", "disconnect", "(", "self", ",", "receiver", ")", ":", "if", "receiver", "not", "in", "self", ".", "receivers", ".", "keys", "(", ")", ":", "raise", "Exception", "(", "\"No receiver %s was registered\"", "%", "receiver", ")", "self", ".", "receivers", ...
Disconnect a receiver from a signal. Signal and receiver must exist, otherwise an exception is thrown. :param receiver: Name of the receiver
[ "Disconnect", "a", "receiver", "from", "a", "signal", ".", "Signal", "and", "receiver", "must", "exist", "otherwise", "an", "exception", "is", "thrown", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L98-L109
train
Disconnect a receiver from a signal.
useblocks/groundwork
groundwork/signals.py
SignalsApplication.send
def send(self, signal, plugin, **kwargs): """ Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if signal not in ...
python
def send(self, signal, plugin, **kwargs): """ Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if signal not in ...
[ "def", "send", "(", "self", ",", "signal", ",", "plugin", ",", "*", "*", "kwargs", ")", ":", "if", "signal", "not", "in", "self", ".", "signals", ".", "keys", "(", ")", ":", "raise", "UnknownSignal", "(", "\"Unknown signal %s\"", "%", "signal", ")", ...
Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern
[ "Sends", "a", "signal", "for", "the", "given", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L111-L124
train
Sends a signal to the given plugin.
useblocks/groundwork
groundwork/signals.py
SignalsApplication.get
def get(self, signal=None, plugin=None): """ Get one or more signals. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is not None: ...
python
def get(self, signal=None, plugin=None): """ Get one or more signals. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is not None: ...
[ "def", "get", "(", "self", ",", "signal", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "signal", "is", "None", ":", "signals_list", "=", "{", "}", "for", "key", "in", "self", ".", "signals", "...
Get one or more signals. :param signal: Name of the signal :type signal: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern
[ "Get", "one", "or", "more", "signals", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L126-L157
train
Get one or more signals.
useblocks/groundwork
groundwork/signals.py
SignalsApplication.get_receiver
def get_receiver(self, receiver=None, plugin=None): """ Get one or more receivers. :param receiver: Name of the signal :type receiver: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is ...
python
def get_receiver(self, receiver=None, plugin=None): """ Get one or more receivers. :param receiver: Name of the signal :type receiver: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern """ if plugin is ...
[ "def", "get_receiver", "(", "self", ",", "receiver", "=", "None", ",", "plugin", "=", "None", ")", ":", "if", "plugin", "is", "not", "None", ":", "if", "receiver", "is", "None", ":", "receiver_list", "=", "{", "}", "for", "key", "in", "self", ".", ...
Get one or more receivers. :param receiver: Name of the signal :type receiver: str :param plugin: Plugin object, under which the signals where registered :type plugin: GwBasePattern
[ "Get", "one", "or", "more", "receivers", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/signals.py#L159-L190
train
Get one or more receivers.
suurjaak/InputScope
inputscope/listener.py
start
def start(inqueue, outqueue=None): """Starts the listener with incoming and outgoing queues.""" conf.init(), db.init(conf.DbPath) Listener(inqueue, outqueue).run()
python
def start(inqueue, outqueue=None): """Starts the listener with incoming and outgoing queues.""" conf.init(), db.init(conf.DbPath) Listener(inqueue, outqueue).run()
[ "def", "start", "(", "inqueue", ",", "outqueue", "=", "None", ")", ":", "conf", ".", "init", "(", ")", ",", "db", ".", "init", "(", "conf", ".", "DbPath", ")", "Listener", "(", "inqueue", ",", "outqueue", ")", ".", "run", "(", ")" ]
Starts the listener with incoming and outgoing queues.
[ "Starts", "the", "listener", "with", "incoming", "and", "outgoing", "queues", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/listener.py#L263-L266
train
Starts the listener with incoming and outgoing queues.
suurjaak/InputScope
inputscope/listener.py
main
def main(): """Entry point for stand-alone execution.""" conf.init(), db.init(conf.DbPath) inqueue = LineQueue(sys.stdin).queue outqueue = type("", (), {"put": lambda self, x: print("\r%s" % x, end=" ")})() if "--quiet" in sys.argv: outqueue = None if conf.MouseEnabled: inqueue.put("mou...
python
def main(): """Entry point for stand-alone execution.""" conf.init(), db.init(conf.DbPath) inqueue = LineQueue(sys.stdin).queue outqueue = type("", (), {"put": lambda self, x: print("\r%s" % x, end=" ")})() if "--quiet" in sys.argv: outqueue = None if conf.MouseEnabled: inqueue.put("mou...
[ "def", "main", "(", ")", ":", "conf", ".", "init", "(", ")", ",", "db", ".", "init", "(", "conf", ".", "DbPath", ")", "inqueue", "=", "LineQueue", "(", "sys", ".", "stdin", ")", ".", "queue", "outqueue", "=", "type", "(", "\"\"", ",", "(", ")",...
Entry point for stand-alone execution.
[ "Entry", "point", "for", "stand", "-", "alone", "execution", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/listener.py#L269-L277
train
Entry point for the script.
suurjaak/InputScope
inputscope/listener.py
KeyHandler._handle_windows
def _handle_windows(self, event): """Windows key event handler.""" vkey = self._keyname(event.GetKey()) if event.Message in self.KEYS_UP + self.KEYS_DOWN: if vkey in self.MODIFIERNAMES: self._realmodifiers[vkey] = event.Message in self.KEYS_DOWN ...
python
def _handle_windows(self, event): """Windows key event handler.""" vkey = self._keyname(event.GetKey()) if event.Message in self.KEYS_UP + self.KEYS_DOWN: if vkey in self.MODIFIERNAMES: self._realmodifiers[vkey] = event.Message in self.KEYS_DOWN ...
[ "def", "_handle_windows", "(", "self", ",", "event", ")", ":", "vkey", "=", "self", ".", "_keyname", "(", "event", ".", "GetKey", "(", ")", ")", "if", "event", ".", "Message", "in", "self", ".", "KEYS_UP", "+", "self", ".", "KEYS_DOWN", ":", "if", ...
Windows key event handler.
[ "Windows", "key", "event", "handler", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/listener.py#L170-L216
train
Handles Windows key events.
suurjaak/InputScope
inputscope/listener.py
KeyHandler._handle_mac
def _handle_mac(self, keycode): """Mac key event handler""" key = self._keyname(unichr(keycode)) self._output(type="keys", key=key, realkey=key)
python
def _handle_mac(self, keycode): """Mac key event handler""" key = self._keyname(unichr(keycode)) self._output(type="keys", key=key, realkey=key)
[ "def", "_handle_mac", "(", "self", ",", "keycode", ")", ":", "key", "=", "self", ".", "_keyname", "(", "unichr", "(", "keycode", ")", ")", "self", ".", "_output", "(", "type", "=", "\"keys\"", ",", "key", "=", "key", ",", "realkey", "=", "key", ")"...
Mac key event handler
[ "Mac", "key", "event", "handler" ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/listener.py#L219-L222
train
Handle mac key events.
suurjaak/InputScope
inputscope/listener.py
KeyHandler._handle_linux
def _handle_linux(self, keycode, character, press): """Linux key event handler.""" if character is None: return key = self._keyname(character, keycode) if key in self.MODIFIERNAMES: self._modifiers[self.MODIFIERNAMES[key]] = press self._realmodifiers[key] = ...
python
def _handle_linux(self, keycode, character, press): """Linux key event handler.""" if character is None: return key = self._keyname(character, keycode) if key in self.MODIFIERNAMES: self._modifiers[self.MODIFIERNAMES[key]] = press self._realmodifiers[key] = ...
[ "def", "_handle_linux", "(", "self", ",", "keycode", ",", "character", ",", "press", ")", ":", "if", "character", "is", "None", ":", "return", "key", "=", "self", ".", "_keyname", "(", "character", ",", "keycode", ")", "if", "key", "in", "self", ".", ...
Linux key event handler.
[ "Linux", "key", "event", "handler", "." ]
245ff045163a1995e8cd5ac558d0a93024eb86eb
https://github.com/suurjaak/InputScope/blob/245ff045163a1995e8cd5ac558d0a93024eb86eb/inputscope/listener.py#L224-L241
train
Linux key event handler.
useblocks/groundwork
groundwork/plugins/gw_documents_info.py
GwDocumentsInfo.activate
def activate(self): """ Activates GwDocumentsInfo by registering: * 2 commands (doc, doc_list) * 1 document (documents_overview) """ self.commands.register("doc_list", "List all documents", self._list_documents) self.commands.register("doc", "Shows the documentat...
python
def activate(self): """ Activates GwDocumentsInfo by registering: * 2 commands (doc, doc_list) * 1 document (documents_overview) """ self.commands.register("doc_list", "List all documents", self._list_documents) self.commands.register("doc", "Shows the documentat...
[ "def", "activate", "(", "self", ")", ":", "self", ".", "commands", ".", "register", "(", "\"doc_list\"", ",", "\"List all documents\"", ",", "self", ".", "_list_documents", ")", "self", ".", "commands", ".", "register", "(", "\"doc\"", ",", "\"Shows the docume...
Activates GwDocumentsInfo by registering: * 2 commands (doc, doc_list) * 1 document (documents_overview)
[ "Activates", "GwDocumentsInfo", "by", "registering", ":" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/plugins/gw_documents_info.py#L45-L76
train
Activates GwDocumentsInfo by registering commands and documents
useblocks/groundwork
groundwork/plugins/gw_documents_info.py
GwDocumentsInfo._store_documentation
def _store_documentation(self, path, html, overwrite, quiet): """ Stores all documents on the file system. Target location is **path**. File name is the lowercase name of the document + .rst. """ echo("Storing groundwork application documents\n") echo("Application: %s" ...
python
def _store_documentation(self, path, html, overwrite, quiet): """ Stores all documents on the file system. Target location is **path**. File name is the lowercase name of the document + .rst. """ echo("Storing groundwork application documents\n") echo("Application: %s" ...
[ "def", "_store_documentation", "(", "self", ",", "path", ",", "html", ",", "overwrite", ",", "quiet", ")", ":", "echo", "(", "\"Storing groundwork application documents\\n\"", ")", "echo", "(", "\"Application: %s\"", "%", "self", ".", "app", ".", "name", ")", ...
Stores all documents on the file system. Target location is **path**. File name is the lowercase name of the document + .rst.
[ "Stores", "all", "documents", "on", "the", "file", "system", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/plugins/gw_documents_info.py#L86-L150
train
Stores all documents on the file system.
useblocks/groundwork
groundwork/plugins/gw_documents_info.py
GwDocumentsInfo._show_documentation
def _show_documentation(self): """ Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning. """ documents = [] for key, document in self.app.documents.get().items(): ...
python
def _show_documentation(self): """ Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning. """ documents = [] for key, document in self.app.documents.get().items(): ...
[ "def", "_show_documentation", "(", "self", ")", ":", "documents", "=", "[", "]", "for", "key", ",", "document", "in", "self", ".", "app", ".", "documents", ".", "get", "(", ")", ".", "items", "(", ")", ":", "if", "key", "!=", "\"main\"", ":", "docu...
Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning.
[ "Shows", "all", "documents", "of", "the", "current", "groundwork", "app", "in", "the", "console", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/plugins/gw_documents_info.py#L152-L202
train
Show all documents of the current groundwork app in the console.
jenisys/parse_type
tasks/_tasklet_cleanup.py
execute_cleanup_tasks
def execute_cleanup_tasks(ctx, cleanup_tasks, dry_run=False): """Execute several cleanup tasks as part of the cleanup. REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks. :param ctx: Context object for the tasks. :param cleanup_tasks: Collection of cleanup tasks (as Colle...
python
def execute_cleanup_tasks(ctx, cleanup_tasks, dry_run=False): """Execute several cleanup tasks as part of the cleanup. REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks. :param ctx: Context object for the tasks. :param cleanup_tasks: Collection of cleanup tasks (as Colle...
[ "def", "execute_cleanup_tasks", "(", "ctx", ",", "cleanup_tasks", ",", "dry_run", "=", "False", ")", ":", "# pylint: disable=redefined-outer-name", "executor", "=", "Executor", "(", "cleanup_tasks", ",", "ctx", ".", "config", ")", "for", "cleanup_task", "in", "cle...
Execute several cleanup tasks as part of the cleanup. REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks. :param ctx: Context object for the tasks. :param cleanup_tasks: Collection of cleanup tasks (as Collection). :param dry_run: Indicates dry-run mode (bool)
[ "Execute", "several", "cleanup", "tasks", "as", "part", "of", "the", "cleanup", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/tasks/_tasklet_cleanup.py#L70-L83
train
Execute several cleanup tasks as part of the cleanup.
jenisys/parse_type
tasks/_tasklet_cleanup.py
cleanup_dirs
def cleanup_dirs(patterns, dry_run=False, workdir="."): """Remove directories (and their contents) recursively. Skips removal if directories does not exist. :param patterns: Directory name patterns, like "**/tmp*" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: ...
python
def cleanup_dirs(patterns, dry_run=False, workdir="."): """Remove directories (and their contents) recursively. Skips removal if directories does not exist. :param patterns: Directory name patterns, like "**/tmp*" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: ...
[ "def", "cleanup_dirs", "(", "patterns", ",", "dry_run", "=", "False", ",", "workdir", "=", "\".\"", ")", ":", "current_dir", "=", "Path", "(", "workdir", ")", "python_basedir", "=", "Path", "(", "Path", "(", "sys", ".", "executable", ")", ".", "dirname",...
Remove directories (and their contents) recursively. Skips removal if directories does not exist. :param patterns: Directory name patterns, like "**/tmp*" (as list). :param dry_run: Dry-run mode indicator (as bool). :param workdir: Current work directory (default=".")
[ "Remove", "directories", "(", "and", "their", "contents", ")", "recursively", ".", "Skips", "removal", "if", "directories", "does", "not", "exist", "." ]
7cad3a67a5ca725cb786da31f656fd473084289f
https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/tasks/_tasklet_cleanup.py#L86-L115
train
Remove directories recursively.
ph4r05/monero-serialize
monero_serialize/xmrtypes.py
get_signature_size
def get_signature_size(msg): """ Returns a signature size for the input :param msg: :return: """ if isinstance(msg, (TxinGen, TxinToScript, TxinToScriptHash)): return 0 elif isinstance(msg, TxinToKey): return len(msg.key_offsets) else: raise ValueError('Unknown tx...
python
def get_signature_size(msg): """ Returns a signature size for the input :param msg: :return: """ if isinstance(msg, (TxinGen, TxinToScript, TxinToScriptHash)): return 0 elif isinstance(msg, TxinToKey): return len(msg.key_offsets) else: raise ValueError('Unknown tx...
[ "def", "get_signature_size", "(", "msg", ")", ":", "if", "isinstance", "(", "msg", ",", "(", "TxinGen", ",", "TxinToScript", ",", "TxinToScriptHash", ")", ")", ":", "return", "0", "elif", "isinstance", "(", "msg", ",", "TxinToKey", ")", ":", "return", "l...
Returns a signature size for the input :param msg: :return:
[ "Returns", "a", "signature", "size", "for", "the", "input", ":", "param", "msg", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrtypes.py#L534-L545
train
Returns a signature size for the input
ph4r05/monero-serialize
monero_serialize/xmrtypes.py
RctSigBase.serialize_rctsig_base
async def serialize_rctsig_base(self, ar, inputs, outputs): """ Custom serialization :param ar: :type ar: x.Archive :return: """ await self._msg_field(ar, idx=0) if self.type == RctType.Null: return if self.type != RctType.Full and self...
python
async def serialize_rctsig_base(self, ar, inputs, outputs): """ Custom serialization :param ar: :type ar: x.Archive :return: """ await self._msg_field(ar, idx=0) if self.type == RctType.Null: return if self.type != RctType.Full and self...
[ "async", "def", "serialize_rctsig_base", "(", "self", ",", "ar", ",", "inputs", ",", "outputs", ")", ":", "await", "self", ".", "_msg_field", "(", "ar", ",", "idx", "=", "0", ")", "if", "self", ".", "type", "==", "RctType", ".", "Null", ":", "return"...
Custom serialization :param ar: :type ar: x.Archive :return:
[ "Custom", "serialization", ":", "param", "ar", ":", ":", "type", "ar", ":", "x", ".", "Archive", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrtypes.py#L315-L366
train
Custom serialization of the RCTSIG base.
ph4r05/monero-serialize
monero_serialize/xmrtypes.py
RctSigPrunable.serialize_rctsig_prunable
async def serialize_rctsig_prunable(self, ar, type, inputs, outputs, mixin): """ Serialize rct sig :param ar: :type ar: x.Archive :param type: :param inputs: :param outputs: :param mixin: :return: """ if type == RctType.Null: ...
python
async def serialize_rctsig_prunable(self, ar, type, inputs, outputs, mixin): """ Serialize rct sig :param ar: :type ar: x.Archive :param type: :param inputs: :param outputs: :param mixin: :return: """ if type == RctType.Null: ...
[ "async", "def", "serialize_rctsig_prunable", "(", "self", ",", "ar", ",", "type", ",", "inputs", ",", "outputs", ",", "mixin", ")", ":", "if", "type", "==", "RctType", ".", "Null", ":", "return", "True", "if", "type", "!=", "RctType", ".", "Full", "and...
Serialize rct sig :param ar: :type ar: x.Archive :param type: :param inputs: :param outputs: :param mixin: :return:
[ "Serialize", "rct", "sig", ":", "param", "ar", ":", ":", "type", "ar", ":", "x", ".", "Archive", ":", "param", "type", ":", ":", "param", "inputs", ":", ":", "param", "outputs", ":", ":", "param", "mixin", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrtypes.py#L402-L497
train
Serialize rct sig.
ph4r05/monero-serialize
monero_serialize/xmrtypes.py
Transaction.serialize_archive
async def serialize_archive(self, ar, version=None): """ Serialize the transaction :param ar: :type ar: x.Archive :return: """ # Transaction prefix serialization first. await ar.message(self, TransactionPrefix) if self.version == 1: aw...
python
async def serialize_archive(self, ar, version=None): """ Serialize the transaction :param ar: :type ar: x.Archive :return: """ # Transaction prefix serialization first. await ar.message(self, TransactionPrefix) if self.version == 1: aw...
[ "async", "def", "serialize_archive", "(", "self", ",", "ar", ",", "version", "=", "None", ")", ":", "# Transaction prefix serialization first.", "await", "ar", ".", "message", "(", "self", ",", "TransactionPrefix", ")", "if", "self", ".", "version", "==", "1",...
Serialize the transaction :param ar: :type ar: x.Archive :return:
[ "Serialize", "the", "transaction", ":", "param", "ar", ":", ":", "type", "ar", ":", "x", ".", "Archive", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrtypes.py#L555-L607
train
Serialize the transaction.
swevm/scaleio-py
scaleiopy/api/scaleio/cluster/storagepool.py
StoragePool.get_storage_pool_by_name
def get_storage_pool_by_name(self, name): """ Get ScaleIO StoragePool object by its name :param name: Name of StoragePool :return: ScaleIO StoragePool object :raise KeyError: No StoragePool with specified name found :rtype: StoragePool object """ for stora...
python
def get_storage_pool_by_name(self, name): """ Get ScaleIO StoragePool object by its name :param name: Name of StoragePool :return: ScaleIO StoragePool object :raise KeyError: No StoragePool with specified name found :rtype: StoragePool object """ for stora...
[ "def", "get_storage_pool_by_name", "(", "self", ",", "name", ")", ":", "for", "storage_pool", "in", "self", ".", "conn", ".", "storage_pools", ":", "if", "storage_pool", ".", "name", "==", "name", ":", "return", "storage_pool", "raise", "KeyError", "(", "\"S...
Get ScaleIO StoragePool object by its name :param name: Name of StoragePool :return: ScaleIO StoragePool object :raise KeyError: No StoragePool with specified name found :rtype: StoragePool object
[ "Get", "ScaleIO", "StoragePool", "object", "by", "its", "name", ":", "param", "name", ":", "Name", "of", "StoragePool", ":", "return", ":", "ScaleIO", "StoragePool", "object", ":", "raise", "KeyError", ":", "No", "StoragePool", "with", "specified", "name", "...
d043a0137cb925987fd5c895a3210968ce1d9028
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/storagepool.py#L23-L34
train
Get ScaleIO StoragePool object by its name
swevm/scaleio-py
scaleiopy/api/scaleio/cluster/storagepool.py
StoragePool.get_storage_pool_by_id
def get_storage_pool_by_id(self, id): """ Get ScaleIO SDS ofbject by its id :param name: Name of StoragePool :return: ScaleIO StoraegPool object :raise KeyError: No StoragePool with specified id found :rtype: StoragePool object """ for storage_pool in self...
python
def get_storage_pool_by_id(self, id): """ Get ScaleIO SDS ofbject by its id :param name: Name of StoragePool :return: ScaleIO StoraegPool object :raise KeyError: No StoragePool with specified id found :rtype: StoragePool object """ for storage_pool in self...
[ "def", "get_storage_pool_by_id", "(", "self", ",", "id", ")", ":", "for", "storage_pool", "in", "self", ".", "conn", ".", "storage_pools", ":", "if", "storage_pool", ".", "id", "==", "id", ":", "return", "storage_pool", "raise", "KeyError", "(", "\"Storage P...
Get ScaleIO SDS ofbject by its id :param name: Name of StoragePool :return: ScaleIO StoraegPool object :raise KeyError: No StoragePool with specified id found :rtype: StoragePool object
[ "Get", "ScaleIO", "SDS", "ofbject", "by", "its", "id", ":", "param", "name", ":", "Name", "of", "StoragePool", ":", "return", ":", "ScaleIO", "StoraegPool", "object", ":", "raise", "KeyError", ":", "No", "StoragePool", "with", "specified", "id", "found", "...
d043a0137cb925987fd5c895a3210968ce1d9028
https://github.com/swevm/scaleio-py/blob/d043a0137cb925987fd5c895a3210968ce1d9028/scaleiopy/api/scaleio/cluster/storagepool.py#L36-L47
train
Get a StoragePool object by its id
dbarsam/python-vsgen
vsgen/util/entrypoints.py
entrypoints
def entrypoints(section): """ Returns the Entry Point for a given Entry Point section. :param str section: The section name in the entry point collection :returns: A dictionary of (Name, Class) pairs stored in the entry point collection. """ return {ep.name: ep.load() for ep in pkg_resources.i...
python
def entrypoints(section): """ Returns the Entry Point for a given Entry Point section. :param str section: The section name in the entry point collection :returns: A dictionary of (Name, Class) pairs stored in the entry point collection. """ return {ep.name: ep.load() for ep in pkg_resources.i...
[ "def", "entrypoints", "(", "section", ")", ":", "return", "{", "ep", ".", "name", ":", "ep", ".", "load", "(", ")", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "section", ")", "}" ]
Returns the Entry Point for a given Entry Point section. :param str section: The section name in the entry point collection :returns: A dictionary of (Name, Class) pairs stored in the entry point collection.
[ "Returns", "the", "Entry", "Point", "for", "a", "given", "Entry", "Point", "section", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/entrypoints.py#L12-L19
train
Returns the Entry Point for a given section.
dbarsam/python-vsgen
vsgen/util/entrypoints.py
entrypoint
def entrypoint(section, option): """ Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available. """ try: ...
python
def entrypoint(section, option): """ Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available. """ try: ...
[ "def", "entrypoint", "(", "section", ",", "option", ")", ":", "try", ":", "return", "entrypoints", "(", "section", ")", "[", "option", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'Cannot resolve type \"{}\" to a recognised vsgen \"{}\" type.'", ".", ...
Returns the the entry point object given a section, option pair. :param str section: The section name in the entry point collection :param str option: The option name in the entry point collection :return: The entry point object if available.
[ "Returns", "the", "the", "entry", "point", "object", "given", "a", "section", "option", "pair", "." ]
640191bb018a1ff7d7b7a4982e0d3c1a423ba878
https://github.com/dbarsam/python-vsgen/blob/640191bb018a1ff7d7b7a4982e0d3c1a423ba878/vsgen/util/entrypoints.py#L22-L33
train
Returns the entry point object given a section and option pair.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_declared.py
infer_declared
def infer_declared(ms, namespace=None): '''Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, th...
python
def infer_declared(ms, namespace=None): '''Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, th...
[ "def", "infer_declared", "(", "ms", ",", "namespace", "=", "None", ")", ":", "conditions", "=", "[", "]", "for", "m", "in", "ms", ":", "for", "cav", "in", "m", ".", "caveats", ":", "if", "cav", ".", "location", "is", "None", "or", "cav", ".", "lo...
Retrieves any declared information from the given macaroons and returns it as a key-value map. Information is declared with a first party caveat as created by declared_caveat. If there are two caveats that declare the same key with different values, the information is omitted from the map. When the...
[ "Retrieves", "any", "declared", "information", "from", "the", "given", "macaroons", "and", "returns", "it", "as", "a", "key", "-", "value", "map", ".", "Information", "is", "declared", "with", "a", "first", "party", "caveat", "as", "created", "by", "declared...
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_declared.py#L15-L32
train
Retrieves any declared information from the given macaroons and returns a key - value map.
go-macaroon-bakery/py-macaroon-bakery
macaroonbakery/checkers/_declared.py
infer_declared_from_conditions
def infer_declared_from_conditions(conds, namespace=None): ''' like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons. ''' conflicts = [] # If we can't resolve that standard namespace, then we'll look for # just bare...
python
def infer_declared_from_conditions(conds, namespace=None): ''' like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons. ''' conflicts = [] # If we can't resolve that standard namespace, then we'll look for # just bare...
[ "def", "infer_declared_from_conditions", "(", "conds", ",", "namespace", "=", "None", ")", ":", "conflicts", "=", "[", "]", "# If we can't resolve that standard namespace, then we'll look for", "# just bare \"declared\" caveats which will work OK for legacy", "# macaroons with no nam...
like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons.
[ "like", "infer_declared", "except", "that", "it", "is", "passed", "a", "set", "of", "first", "party", "caveat", "conditions", "as", "a", "list", "of", "string", "rather", "than", "a", "set", "of", "macaroons", "." ]
63ce1ef1dabe816eb8aaec48fbb46761c34ddf77
https://github.com/go-macaroon-bakery/py-macaroon-bakery/blob/63ce1ef1dabe816eb8aaec48fbb46761c34ddf77/macaroonbakery/checkers/_declared.py#L35-L69
train
like infer_declared except that it is passed a set of first party caveat conditions as a list of string rather than a set of macaroons.
ph4r05/monero-serialize
monero_serialize/xmrjson.py
unescape_json_str
def unescape_json_str(st): """ Unescape Monero json encoded string /monero/external/rapidjson/reader.h :param st: :return: """ c = 0 ln = len(st) escape_chmap = { b'b': b'\b', b'f': b'\f', b'n': b'\n', b'r': b'\r', b't': b'\t', b'\\': ...
python
def unescape_json_str(st): """ Unescape Monero json encoded string /monero/external/rapidjson/reader.h :param st: :return: """ c = 0 ln = len(st) escape_chmap = { b'b': b'\b', b'f': b'\f', b'n': b'\n', b'r': b'\r', b't': b'\t', b'\\': ...
[ "def", "unescape_json_str", "(", "st", ")", ":", "c", "=", "0", "ln", "=", "len", "(", "st", ")", "escape_chmap", "=", "{", "b'b'", ":", "b'\\b'", ",", "b'f'", ":", "b'\\f'", ",", "b'n'", ":", "b'\\n'", ",", "b'r'", ":", "b'\\r'", ",", "b't'", ":...
Unescape Monero json encoded string /monero/external/rapidjson/reader.h :param st: :return:
[ "Unescape", "Monero", "json", "encoded", "string", "/", "monero", "/", "external", "/", "rapidjson", "/", "reader", ".", "h" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrjson.py#L17-L59
train
Unescape Monero json encoded string
ph4r05/monero-serialize
monero_serialize/xmrjson.py
escape_string_json
def escape_string_json(st): """ Escaping string for json /Users/dusanklinec/workspace/monero/external/rapidjson/writer.h :param st: :return: """ ret = [] c = 0 ln = len(st) escape_chmap = { b'\b': b'b', b'\f': b'f', b'\n': b'n', b'\r': b'r', ...
python
def escape_string_json(st): """ Escaping string for json /Users/dusanklinec/workspace/monero/external/rapidjson/writer.h :param st: :return: """ ret = [] c = 0 ln = len(st) escape_chmap = { b'\b': b'b', b'\f': b'f', b'\n': b'n', b'\r': b'r', ...
[ "def", "escape_string_json", "(", "st", ")", ":", "ret", "=", "[", "]", "c", "=", "0", "ln", "=", "len", "(", "st", ")", "escape_chmap", "=", "{", "b'\\b'", ":", "b'b'", ",", "b'\\f'", ":", "b'f'", ",", "b'\\n'", ":", "b'n'", ",", "b'\\r'", ":", ...
Escaping string for json /Users/dusanklinec/workspace/monero/external/rapidjson/writer.h :param st: :return:
[ "Escaping", "string", "for", "json", "/", "Users", "/", "dusanklinec", "/", "workspace", "/", "monero", "/", "external", "/", "rapidjson", "/", "writer", ".", "h", ":", "param", "st", ":", ":", "return", ":" ]
cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42
https://github.com/ph4r05/monero-serialize/blob/cebb3ba2aaf2e9211b1dcc6db2bab02946d06e42/monero_serialize/xmrjson.py#L62-L93
train
Escapes the string for the base64 - encoded unicode object.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
GwBasePattern._pre_activate_injection
def _pre_activate_injection(self): """ Injects functions before the activation routine of child classes gets called """ # Let's be sure that this plugins class is registered and available on application level under # application.plugins.classes. This allows to reuse this class fo...
python
def _pre_activate_injection(self): """ Injects functions before the activation routine of child classes gets called """ # Let's be sure that this plugins class is registered and available on application level under # application.plugins.classes. This allows to reuse this class fo...
[ "def", "_pre_activate_injection", "(", "self", ")", ":", "# Let's be sure that this plugins class is registered and available on application level under", "# application.plugins.classes. This allows to reuse this class for *new* plugins.", "if", "not", "self", ".", "app", ".", "plugins",...
Injects functions before the activation routine of child classes gets called
[ "Injects", "functions", "before", "the", "activation", "routine", "of", "child", "classes", "gets", "called" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L135-L146
train
Injects functions before the activation routine of child classes gets called
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
GwBasePattern._post_activate_injection
def _post_activate_injection(self): """ Injects functions after the activation routine of child classes got called :return: None """ self.active = True self.app.signals.send("plugin_activate_post", self)
python
def _post_activate_injection(self): """ Injects functions after the activation routine of child classes got called :return: None """ self.active = True self.app.signals.send("plugin_activate_post", self)
[ "def", "_post_activate_injection", "(", "self", ")", ":", "self", ".", "active", "=", "True", "self", ".", "app", ".", "signals", ".", "send", "(", "\"plugin_activate_post\"", ",", "self", ")" ]
Injects functions after the activation routine of child classes got called :return: None
[ "Injects", "functions", "after", "the", "activation", "routine", "of", "child", "classes", "got", "called", ":", "return", ":", "None" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L148-L154
train
Injects functions after the activation routine of child classes got called
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
GwBasePattern._post_deactivate_injection
def _post_deactivate_injection(self): """ Injects functions after the deactivation routine of child classes got called :return: None """ # Lets be sure that active is really set to false. self.active = False self.app.signals.send("plugin_deactivate_post", self) ...
python
def _post_deactivate_injection(self): """ Injects functions after the deactivation routine of child classes got called :return: None """ # Lets be sure that active is really set to false. self.active = False self.app.signals.send("plugin_deactivate_post", self) ...
[ "def", "_post_deactivate_injection", "(", "self", ")", ":", "# Lets be sure that active is really set to false.", "self", ".", "active", "=", "False", "self", ".", "app", ".", "signals", ".", "send", "(", "\"plugin_deactivate_post\"", ",", "self", ")", "# After all re...
Injects functions after the deactivation routine of child classes got called :return: None
[ "Injects", "functions", "after", "the", "deactivation", "routine", "of", "child", "classes", "got", "called", ":", "return", ":", "None" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L163-L175
train
Called by the plugin when the deactivation routine of child classes got called.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
GwBasePattern._load_needed_plugins
def _load_needed_plugins(self): """ Checks if this plugins needs other plugins to work and tries to activate them :return: True, if all needed plugins are or got activated. Otherwise False """ global plugin_recursive_store if "plugin_recursive_store" not in globals(): ...
python
def _load_needed_plugins(self): """ Checks if this plugins needs other plugins to work and tries to activate them :return: True, if all needed plugins are or got activated. Otherwise False """ global plugin_recursive_store if "plugin_recursive_store" not in globals(): ...
[ "def", "_load_needed_plugins", "(", "self", ")", ":", "global", "plugin_recursive_store", "if", "\"plugin_recursive_store\"", "not", "in", "globals", "(", ")", ":", "plugin_recursive_store", "=", "[", "]", "if", "self", ".", "name", "in", "plugin_recursive_store", ...
Checks if this plugins needs other plugins to work and tries to activate them :return: True, if all needed plugins are or got activated. Otherwise False
[ "Checks", "if", "this", "plugins", "needs", "other", "plugins", "to", "work", "and", "tries", "to", "activate", "them", ":", "return", ":", "True", "if", "all", "needed", "plugins", "are", "or", "got", "activated", ".", "Otherwise", "False" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L177-L218
train
Checks if this plugins need other plugins to work and tries to activate them if they are not.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.register
def register(self, signal, description): """ Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used fo...
python
def register(self, signal, description): """ Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used fo...
[ "def", "register", "(", "self", ",", "signal", ",", "description", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "register", "(", "signal", ",", "self", ".", "_plugin", ",", "description", ")" ]
Registers a new signal. Only registered signals are allowed to be send. :param signal: Unique name of the signal :param description: Description of the reason or use case, why this signal is needed. Used for documentation.
[ "Registers", "a", "new", "signal", ".", "Only", "registered", "signals", "are", "allowed", "to", "be", "send", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L248-L257
train
Registers a new signal.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.connect
def connect(self, receiver, signal, function, description, sender=None): """ Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :param function:...
python
def connect(self, receiver, signal, function, description, sender=None): """ Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :param function:...
[ "def", "connect", "(", "self", ",", "receiver", ",", "signal", ",", "function", ",", "description", ",", "sender", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "connect", "(", "receiver", ",", "signal", ",", "function", "...
Connect a receiver to a signal :param receiver: Name of the receiver :type receiver: str :param signal: Name of the signal. Must already be registered! :type signal: str :param function: Callable functions, which shall be executed, of signal is send. :param description: ...
[ "Connect", "a", "receiver", "to", "a", "signal" ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L262-L274
train
Connect a receiver to a signal
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.send
def send(self, signal, **kwargs): """ Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str """ return self.__app.signals.send(signal, plugin=self._plugin, **kwargs)
python
def send(self, signal, **kwargs): """ Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str """ return self.__app.signals.send(signal, plugin=self._plugin, **kwargs)
[ "def", "send", "(", "self", ",", "signal", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "send", "(", "signal", ",", "plugin", "=", "self", ".", "_plugin", ",", "*", "*", "kwargs", ")" ]
Sends a signal for the given plugin. :param signal: Name of the signal :type signal: str
[ "Sends", "a", "signal", "for", "the", "given", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L285-L292
train
Sends a signal to the given plugin.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.get
def get(self, signal=None): """ Returns a single signal or a dictionary of signals for this plugin. """ return self.__app.signals.get(signal, self._plugin)
python
def get(self, signal=None): """ Returns a single signal or a dictionary of signals for this plugin. """ return self.__app.signals.get(signal, self._plugin)
[ "def", "get", "(", "self", ",", "signal", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "get", "(", "signal", ",", "self", ".", "_plugin", ")" ]
Returns a single signal or a dictionary of signals for this plugin.
[ "Returns", "a", "single", "signal", "or", "a", "dictionary", "of", "signals", "for", "this", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L294-L298
train
Returns a single signal or a dictionary of signals for this plugin.
useblocks/groundwork
groundwork/patterns/gw_base_pattern.py
SignalsPlugin.get_receiver
def get_receiver(self, receiver=None): """ Returns a single receiver or a dictionary of receivers for this plugin. """ return self.__app.signals.get_receiver(receiver, self._plugin)
python
def get_receiver(self, receiver=None): """ Returns a single receiver or a dictionary of receivers for this plugin. """ return self.__app.signals.get_receiver(receiver, self._plugin)
[ "def", "get_receiver", "(", "self", ",", "receiver", "=", "None", ")", ":", "return", "self", ".", "__app", ".", "signals", ".", "get_receiver", "(", "receiver", ",", "self", ".", "_plugin", ")" ]
Returns a single receiver or a dictionary of receivers for this plugin.
[ "Returns", "a", "single", "receiver", "or", "a", "dictionary", "of", "receivers", "for", "this", "plugin", "." ]
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/patterns/gw_base_pattern.py#L300-L304
train
Returns a single receiver or a dictionary of receivers for this plugin.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.validate
def validate(mcs, bases, attributes): """Check attributes.""" if bases[0] is object: return None mcs.check_model_cls(attributes) mcs.check_include_exclude(attributes) mcs.check_properties(attributes)
python
def validate(mcs, bases, attributes): """Check attributes.""" if bases[0] is object: return None mcs.check_model_cls(attributes) mcs.check_include_exclude(attributes) mcs.check_properties(attributes)
[ "def", "validate", "(", "mcs", ",", "bases", ",", "attributes", ")", ":", "if", "bases", "[", "0", "]", "is", "object", ":", "return", "None", "mcs", ".", "check_model_cls", "(", "attributes", ")", "mcs", ".", "check_include_exclude", "(", "attributes", ...
Check attributes.
[ "Check", "attributes", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L18-L24
train
Check the attributes.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.check_model_cls
def check_model_cls(attributes): """Check __model_cls__ attribute. :type attributes: dict """ model_cls = attributes.get('__model_cls__') if model_cls is None: raise AttributeError("Attribute __model_cls__ is required.") if not issubclass(model_cls, models.D...
python
def check_model_cls(attributes): """Check __model_cls__ attribute. :type attributes: dict """ model_cls = attributes.get('__model_cls__') if model_cls is None: raise AttributeError("Attribute __model_cls__ is required.") if not issubclass(model_cls, models.D...
[ "def", "check_model_cls", "(", "attributes", ")", ":", "model_cls", "=", "attributes", ".", "get", "(", "'__model_cls__'", ")", "if", "model_cls", "is", "None", ":", "raise", "AttributeError", "(", "\"Attribute __model_cls__ is required.\"", ")", "if", "not", "iss...
Check __model_cls__ attribute. :type attributes: dict
[ "Check", "__model_cls__", "attribute", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L27-L38
train
Check __model_cls__ attribute.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.get_prepared_include_exclude
def get_prepared_include_exclude(attributes): """Return tuple with prepared __include__ and __exclude__ attributes. :type attributes: dict :rtype: tuple """ attrs = dict() for attr in ('__include__', '__exclude__'): attrs[attr] = tuple([item.name for item in ...
python
def get_prepared_include_exclude(attributes): """Return tuple with prepared __include__ and __exclude__ attributes. :type attributes: dict :rtype: tuple """ attrs = dict() for attr in ('__include__', '__exclude__'): attrs[attr] = tuple([item.name for item in ...
[ "def", "get_prepared_include_exclude", "(", "attributes", ")", ":", "attrs", "=", "dict", "(", ")", "for", "attr", "in", "(", "'__include__'", ",", "'__exclude__'", ")", ":", "attrs", "[", "attr", "]", "=", "tuple", "(", "[", "item", ".", "name", "for", ...
Return tuple with prepared __include__ and __exclude__ attributes. :type attributes: dict :rtype: tuple
[ "Return", "tuple", "with", "prepared", "__include__", "and", "__exclude__", "attributes", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L41-L51
train
Return tuple with prepared __include__ and __exclude__ attributes.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.check_include_exclude
def check_include_exclude(attributes): """Check __include__ and __exclude__ attributes. :type attributes: dict """ include = attributes.get('__include__', tuple()) exclude = attributes.get('__exclude__', tuple()) if not isinstance(include, tuple): raise Type...
python
def check_include_exclude(attributes): """Check __include__ and __exclude__ attributes. :type attributes: dict """ include = attributes.get('__include__', tuple()) exclude = attributes.get('__exclude__', tuple()) if not isinstance(include, tuple): raise Type...
[ "def", "check_include_exclude", "(", "attributes", ")", ":", "include", "=", "attributes", ".", "get", "(", "'__include__'", ",", "tuple", "(", ")", ")", "exclude", "=", "attributes", ".", "get", "(", "'__exclude__'", ",", "tuple", "(", ")", ")", "if", "...
Check __include__ and __exclude__ attributes. :type attributes: dict
[ "Check", "__include__", "and", "__exclude__", "attributes", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L54-L73
train
Check include and exclude attributes.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.get_properties
def get_properties(attributes): """Return tuple of names of defined properties. :type attributes: dict :rtype: list """ return [key for key, value in six.iteritems(attributes) if isinstance(value, property)]
python
def get_properties(attributes): """Return tuple of names of defined properties. :type attributes: dict :rtype: list """ return [key for key, value in six.iteritems(attributes) if isinstance(value, property)]
[ "def", "get_properties", "(", "attributes", ")", ":", "return", "[", "key", "for", "key", ",", "value", "in", "six", ".", "iteritems", "(", "attributes", ")", "if", "isinstance", "(", "value", ",", "property", ")", "]" ]
Return tuple of names of defined properties. :type attributes: dict :rtype: list
[ "Return", "tuple", "of", "names", "of", "defined", "properties", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L76-L83
train
Return tuple of names of defined properties.
ets-labs/python-domain-models
domain_models/views.py
ContextViewMetaClass.check_properties
def check_properties(mcs, attributes): """Check whether intersections exist. :type attributes: dict """ include, exclude = mcs.get_prepared_include_exclude(attributes) properties = mcs.get_properties(attributes) intersections = list( set(properties).intersect...
python
def check_properties(mcs, attributes): """Check whether intersections exist. :type attributes: dict """ include, exclude = mcs.get_prepared_include_exclude(attributes) properties = mcs.get_properties(attributes) intersections = list( set(properties).intersect...
[ "def", "check_properties", "(", "mcs", ",", "attributes", ")", ":", "include", ",", "exclude", "=", "mcs", ".", "get_prepared_include_exclude", "(", "attributes", ")", "properties", "=", "mcs", ".", "get_properties", "(", "attributes", ")", "intersections", "=",...
Check whether intersections exist. :type attributes: dict
[ "Check", "whether", "intersections", "exist", "." ]
7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9
https://github.com/ets-labs/python-domain-models/blob/7de1816ba0338f20fdb3e0f57fad0ffd5bea13f9/domain_models/views.py#L86-L103
train
Checks whether intersections exist.
useblocks/groundwork
groundwork/configuration/configmanager.py
ConfigManager.load
def load(self, config_files): """ Creates a configuration instance from class :class:`~groundwork.configuration.configmanager.Config` from all files in self.files and set the dictionary items as attributes of of this instance. :return: Instance of :class:`~groundwork.configuration.confi...
python
def load(self, config_files): """ Creates a configuration instance from class :class:`~groundwork.configuration.configmanager.Config` from all files in self.files and set the dictionary items as attributes of of this instance. :return: Instance of :class:`~groundwork.configuration.confi...
[ "def", "load", "(", "self", ",", "config_files", ")", ":", "config", "=", "Config", "(", ")", "for", "config_file", "in", "config_files", ":", "if", "not", "os", ".", "path", ".", "isabs", "(", "config_file", ")", ":", "config_file", "=", "os", ".", ...
Creates a configuration instance from class :class:`~groundwork.configuration.configmanager.Config` from all files in self.files and set the dictionary items as attributes of of this instance. :return: Instance of :class:`~groundwork.configuration.configmanager.Config`
[ "Creates", "a", "configuration", "instance", "from", "class", ":", "class", ":", "~groundwork", ".", "configuration", ".", "configmanager", ".", "Config", "from", "all", "files", "in", "self", ".", "files", "and", "set", "the", "dictionary", "items", "as", "...
d34fce43f54246ca4db0f7b89e450dcdc847c68c
https://github.com/useblocks/groundwork/blob/d34fce43f54246ca4db0f7b89e450dcdc847c68c/groundwork/configuration/configmanager.py#L52-L80
train
Loads a configuration from a list of all the configuration files.