INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Loads agent authentication information from the specified content string as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor.
def read_auth_info(agent_file_content): '''Loads agent authentication information from the specified content string, as read from an agents file. The returned information is suitable for passing as an argument to the AgentInteractor constructor. @param agent_file_content The agent file content (str)...
Implement Interactor. interact by obtaining obtaining a macaroon from the discharger discharging it with the local private key using the discharged macaroon as a discharge token
def interact(self, client, location, interaction_required_err): '''Implement Interactor.interact by obtaining obtaining a macaroon from the discharger, discharging it with the local private key using the discharged macaroon as a discharge token''' p = interaction_required_err.int...
Finds an appropriate agent entry for the given location.: return Agent
def _find_agent(self, location): ''' Finds an appropriate agent entry for the given location. :return Agent ''' for a in self._auth_info.agents: # Don't worry about trailing slashes if a.url.rstrip('/') == location.rstrip('/'): return a rai...
Implement LegacyInteractor. legacy_interact by obtaining the discharge macaroon using the client s private key
def legacy_interact(self, client, location, visit_url): '''Implement LegacyInteractor.legacy_interact by obtaining the discharge macaroon using the client's private key ''' agent = self._find_agent(location) # Shallow-copy the client so that we don't unexpectedly side-effect ...
Returns the minimum time of any time - before caveats found in the given macaroons or None if no such caveats were found.: param ns: a Namespace used to resolve caveats.: param ms: a list of pymacaroons. Macaroon: return: datetime. DateTime or None.
def macaroons_expiry_time(ns, ms): ''' Returns the minimum time of any time-before caveats found in the given macaroons or None if no such caveats were found. :param ns: a Namespace, used to resolve caveats. :param ms: a list of pymacaroons.Macaroon :return: datetime.DateTime or None. ''' t ...
Returns the minimum time of any time - before caveats found in the given list or None if no such caveats were found.
def expiry_time(ns, cavs): ''' Returns the minimum time of any time-before caveats found in the given list or None if no such caveats were found. The ns parameter is :param ns: used to determine the standard namespace prefix - if the standard namespace is not found, the empty prefix is assumed. ...
Connect to the server.: param str url: server URL.
def connect(self, url): """Connect to the server. :param str url: server URL. """ headers = httputil.HTTPHeaders({'Content-Type': APPLICATION_JSON}) request = httpclient.HTTPRequest(url=url, connect_timeout=self.connect_timeout, ...
Send message to the server: param str data: message.
def send(self, data): """Send message to the server :param str data: message. """ if not self._ws_connection: raise RuntimeError('Web socket connection is closed.') self._ws_connection.write_message(json.dumps(data))
Replace multiple strings in a text.
def replace_all(text, replace_dict): """ Replace multiple strings in a text. .. note:: Replacements are made successively, without any warranty on the order \ in which they are made. :param text: Text to replace in. :param replace_dict: Dictionary mapping strings to replace with ...
Map the function on param or apply it depending whether param \ is a list or an item.
def map_or_apply(function, param): """ Map the function on ``param``, or apply it, depending whether ``param`` \ is a list or an item. :param function: The function to apply. :param param: The parameter to feed the function with (list or item). :returns: The computed value or ``None``. ...
Get items from a sequence a batch at a time.
def batch(iterable, size): """ Get items from a sequence a batch at a time. .. note: Adapted from https://code.activestate.com/recipes/303279-getting-items-in-batches/. .. note: All batches must be exhausted immediately. :params iterable: An iterable to get batches from...
Normalizes string converts to lowercase removes non - alpha characters and converts spaces to hyphens to have nice filenames.
def slugify(value): """ Normalizes string, converts to lowercase, removes non-alpha characters, and converts spaces to hyphens to have nice filenames. From Django's "django/template/defaultfilters.py". >>> slugify("El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su q...
Get the citations of a given preprint in plain text.
def get_plaintext_citations(arxiv_id): """ Get the citations of a given preprint, in plain text. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1...
Get the DOIs of the papers cited in a. bbl file.
def get_cited_dois(arxiv_id): """ Get the DOIs of the papers cited in a .bbl file. .. note:: Bulk download of sources from arXiv is not permitted by their API. \ You should have a look at http://arxiv.org/help/bulk_data_s3. :param arxiv_id: The arXiv id (e.g. ``1401.2910`` or ...
Get subcommand options from global parsed arguments.
def get_subcommand_kwargs(mgr, name, namespace): """Get subcommand options from global parsed arguments. """ subcmd = mgr.get(name) subcmd_kwargs = {} for opt in list(subcmd.args.values()) + list(subcmd.options.values()): if hasattr(namespace, opt.dest): subcmd_kwargs[opt.des...
Parse a plaintext file to get a clean list of plaintext citations. The \ file should have one citation per line.
def get_plaintext_citations(file): """ Parse a plaintext file to get a clean list of plaintext citations. The \ file should have one citation per line. :param file: Either the path to the plaintext file or the content of a \ plaintext file. :returns: A list of cleaned plaintext...
Get the DOIs of the papers cited in a plaintext file. The file should \ have one citation per line.
def get_cited_dois(file): """ Get the DOIs of the papers cited in a plaintext file. The file should \ have one citation per line. .. note:: This function is also used as a backend tool by most of the others \ citations processors, to factorize the code. :param file: Either...
Set name for SDC: param name: Name of SDC: param sdcObj: ScaleIO SDC object: return: POST request response: rtype: Requests POST response object
def set_sdc_name(self, name, sdcObj): """ Set name for SDC :param name: Name of SDC :param sdcObj: ScaleIO SDC object :return: POST request response :rtype: Requests POST response object """ # TODO: # Check if object parameters are the correct ones...
Get ScaleIO SDC object by its name: param name: Name of SDC: return: ScaleIO SDC object: raise KeyError: No SDC with specified name found: rtype: SDC object
def get_sdc_by_name(self, name): """ Get ScaleIO SDC object by its name :param name: Name of SDC :return: ScaleIO SDC object :raise KeyError: No SDC with specified name found :rtype: SDC object """ for sdc in self.sdc: if sdc.name == name: ...
Get ScaleIO SDC object by its id: param name: id of SDC: return: ScaleIO SDC object: raise KeyError: No SDC with specified id found: rtype: SDC object
def get_sdc_by_id(self, id): """ Get ScaleIO SDC object by its id :param name: id of SDC :return: ScaleIO SDC object :raise KeyError: No SDC with specified id found :rtype: SDC object """ for sdc in self.sdc: if sdc.id == id: re...
Get ScaleIO SDC object by its id: param name: guid of SDC: return: ScaleIO SDC object: raise KeyError: No SDC with specified id found: rtype: SDC object
def get_sdc_by_guid(self, guid): """ Get ScaleIO SDC object by its id :param name: guid of SDC :return: ScaleIO SDC object :raise KeyError: No SDC with specified id found :rtype: SDC object """ for sdc in self.sdc: if sdc.guid == guid: ...
Get ScaleIO SDC object by its ip: param name: IP address of SDC: return: ScaleIO SDC object: raise KeyError: No SDC with specified IP found: rtype: SDC object
def get_sdc_by_ip(self, ip): """ Get ScaleIO SDC object by its ip :param name: IP address of SDC :return: ScaleIO SDC object :raise KeyError: No SDC with specified IP found :rtype: SDC object """ if self.conn.is_ip_addr(ip): for sdc in self.sdc...
Unregister SDC from MDM/ SIO Cluster: param sdcObj: ScaleIO SDC object: return: POST request response: rtype: Requests POST response object
def unregisterSdc(self, sdcObj): """ Unregister SDC from MDM/SIO Cluster :param sdcObj: ScaleIO SDC object :return: POST request response :rtype: Requests POST response object """ # TODO: # Add code that unmap volume if mapped self.conn.connection....
Command execution.
def run(self): """Command execution.""" self.run_command('sdist') self.run_command('upload') os.system('git tag -a {0} -m \'version {0}\''.format(version)) os.system('git push --tags')
Check that a given string is a valid ISBN.
def is_valid(isbn_id): """ Check that a given string is a valid ISBN. :param isbn_id: the isbn to be checked. :returns: boolean indicating whether the isbn is valid or not. >>> is_valid("978-3-16-148410-0") True >>> is_valid("9783161484100") True >>> is_valid("9783161484100aa") ...
Extract ISBNs from a text.
def extract_from_text(text): """ Extract ISBNs from a text. :param text: Some text. :returns: A list of canonical ISBNs found in the text. >>> extract_from_text("978-3-16-148410-0 9783161484100 9783161484100aa abcd 0136091814 0136091812 9780136091817 123456789X") ['9783161484100', '97831614841...
Get a BibTeX string for the given ISBN.
def get_bibtex(isbn_identifier): """ Get a BibTeX string for the given ISBN. :param isbn_identifier: ISBN to fetch BibTeX entry for. :returns: A BibTeX string or ``None`` if could not fetch it. >>> get_bibtex('9783161484100') '@book{9783161484100,\\n title = {Berkeley, Oakland: Albany, Eme...
Return options already used in the command line
def used_options(self): """Return options already used in the command line rtype: command.Option generator """ for option_str in filter(lambda c: c.startswith('-'), self.words): for option in list(self.cmd.options.values()): if option_str in option.op...
Return options that can be used given the current cmd line
def available_options(self): """Return options that can be used given the current cmd line rtype: command.Option generator """ for option in list(self.cmd.options.values()): if (option.is_multiple or option not in list(self.used_options)): ...
Return args already used in the command line
def used_args(self): """Return args already used in the command line rtype: command.Arg generator """ # get all arguments values from the command line values = [] for idx, c in enumerate(self.words[1:]): if c.startswith('-'): continue ...
Return args that can be used given the current cmd line
def available_args(self): """Return args that can be used given the current cmd line rtype: command.Arg generator """ used = list(self.used_args) logger.debug('Found used args: %s' % used) for arg in list(self.cmd.args.values()): if (arg.is_multiple o...
Returns true if the elem_ref is an element reference
def is_elem_ref(elem_ref): """ Returns true if the elem_ref is an element reference :param elem_ref: :return: """ return ( elem_ref and isinstance(elem_ref, tuple) and len(elem_ref) == 3 and (elem_ref[0] == ElemRefObj or elem_ref[0] == ElemRefArr) )
Has element?: param elem_ref:: return:
def has_elem(elem_ref): """ Has element? :param elem_ref: :return: """ if not is_elem_ref(elem_ref): return False elif elem_ref[0] == ElemRefObj: return hasattr(elem_ref[1], elem_ref[2]) elif elem_ref[0] == ElemRefArr: return elem_ref[2] in elem_ref[1]
Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference.
def get_elem(elem_ref, default=None): """ Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference. :param elem_ref: :param default: :return: """ if not is_elem_ref(elem_ref): return elem_ref elif elem_ref[0] == ElemRefObj: return g...
Sets element referenced by the elem_ref. Returns the elem.
def set_elem(elem_ref, elem): """ Sets element referenced by the elem_ref. Returns the elem. :param elem_ref: :param elem: :return: """ if elem_ref is None or elem_ref == elem or not is_elem_ref(elem_ref): return elem elif elem_ref[0] == ElemRefObj: setattr(elem_ref[1],...
Returns element reference: param obj:: param key:: param is_assoc:: return:
def eref(obj, key, is_assoc=None): """ Returns element reference :param obj: :param key: :param is_assoc: :return: """ if obj is None: return None if isinstance(key, int) or (is_assoc is not None and is_assoc): return ElemRefArr, get_elem(obj), key else: r...
Revise wording to match canonical and expected forms.
def _preprocess(inp): """Revise wording to match canonical and expected forms.""" inp = re.sub(r'(\b)a(\b)', r'\g<1>one\g<2>', inp) inp = re.sub(r'to the (.*) power', r'to \g<1>', inp) inp = re.sub(r'to the (.*?)(\b)', r'to \g<1>\g<2>', inp) inp = re.sub(r'log of', r'log', inp) ...
Calculates a final value given a set of numbers and symbols.
def _calculate(numbers, symbols): """Calculates a final value given a set of numbers and symbols.""" if len(numbers) is 1: return numbers[0] precedence = [[pow], [mul, div], [add, sub]] # Find most important operation for op_group in precedence: for i, o...
Solves the equation specified by the input string.
def parseEquation(self, inp): """Solves the equation specified by the input string. Args: inp (str): An equation, specified in words, containing some combination of numbers, binary, and unary operations. Returns: The floating-point result of carrying out...
Registers a new command for a plugin.
def register(self, command, description, function, params=[]): """ Registers a new command for a plugin. :param command: Name of the command :param description: Description of the command. Is used as help message on cli :param function: function reference, which gets invoked if ...
Returns commands which can be filtered by name.
def get(self, name=None): """ Returns commands, which can be filtered by name. :param name: name of the command :type name: str :return: None, single command or dict of commands """ return self.app.commands.get(name, self.plugin)
Returns commands which can be filtered by name or plugin.
def get(self, name=None, plugin=None): """ Returns commands, which can be filtered by name or plugin. :param name: name of the command :type name: str :param plugin: plugin object, which registers the commands :type plugin: instance of GwBasePattern :return: None...
Registers a new command which can be used on a command line interface ( cli ).
def register(self, command, description, function, params=[], plugin=None): """ Registers a new command, which can be used on a command line interface (cli). :param command: Name of the command :param description: Description of the command. Is used as help message on cli :param...
Unregisters an existing command so that this command is no longer available on the command line interface.
def unregister(self, command): """ Unregisters an existing command, so that this command is no longer available on the command line interface. This function is mainly used during plugin deactivation. :param command: Name of the command """ if command not in self._comman...
SMTP rcpt command -- indicates 1 recipient for this mail.
def rcpt(self, recip, options=[]): """SMTP 'rcpt' command -- indicates 1 recipient for this mail.""" optionlist = '' if options and self.does_esmtp: optionlist = ' ' + ' '.join(options) code, msg = yield self.docmd(b"rcpt", ("TO:%s%s" % (smtplib.quoteaddr(recip), optionlist))...
SMTP DATA command -- sends message data to server.
def data(self, msg): """SMTP 'DATA' command -- sends message data to server. """ (code, repl) = yield self.docmd(b"data") if code != 354: raise smtplib.SMTPDataError(code, repl) else: if isinstance(msg, str): msg = smtplib._fix_eols(msg).encode('...
Returns a declared caveat asserting that the given key is set to the given value.
def declared_caveat(key, value): '''Returns a "declared" caveat asserting that the given key is set to the given value. If a macaroon has exactly one first party caveat asserting the value of a particular key, then infer_declared will be able to infer the value, and then the check will allow the de...
Helper for allow_caveat and deny_caveat.
def _operation_caveat(cond, ops): ''' Helper for allow_caveat and deny_caveat. It checks that all operation names are valid before creating the caveat. ''' for op in ops: if op.find(' ') != -1: return error_caveat('invalid operation name "{}"'.format(op)) return _first_party(con...
Return a caveat that specifies that the time that it is checked at should be before t.: param t is a a UTC date in - use datetime. utcnow not datetime. now
def time_before_caveat(t): '''Return a caveat that specifies that the time that it is checked at should be before t. :param t is a a UTC date in - use datetime.utcnow, not datetime.now ''' return _first_party(COND_TIME_BEFORE, pyrfc3339.generate(t, accept_naive=True, ...
Parses a caveat into an identifier identifying the checker that should be used and the argument to the checker ( the rest of the string ).
def parse_caveat(cav): ''' Parses a caveat into an identifier, identifying the checker that should be used, and the argument to the checker (the rest of the string). The identifier is taken from all the characters before the first space character. :return two string, identifier and arg ''' ...
Return s as a bytes type using utf - 8 encoding if necessary.
def to_bytes(s): '''Return s as a bytes type, using utf-8 encoding if necessary. @param s string or bytes @return bytes ''' if isinstance(s, six.binary_type): return s if isinstance(s, six.string_types): return s.encode('utf-8') raise TypeError('want string or bytes, got {}',...
Base64 decodes a base64 - encoded string in URL - safe or normal format with or without padding. The argument may be string or bytes.
def b64decode(s): '''Base64 decodes a base64-encoded string in URL-safe or normal format, with or without padding. The argument may be string or bytes. @param s bytes decode @return bytes decoded @raises ValueError on failure ''' # add padding if necessary. s = to_bytes(s) if no...
Base64 encode using URL - safe encoding with padding removed.
def raw_urlsafe_b64encode(b): '''Base64 encode using URL-safe encoding with padding removed. @param b bytes to decode @return bytes decoded ''' b = to_bytes(b) b = base64.urlsafe_b64encode(b) b = b.rstrip(b'=') # strip padding return b
Return a new Cookie using a slightly more friendly API than that provided by six. moves. http_cookiejar
def cookie( url, name, value, expires=None): '''Return a new Cookie using a slightly more friendly API than that provided by six.moves.http_cookiejar @param name The cookie name {str} @param value The cookie value {str} @param url The URL path of the cookie {str} ...
LOGIN CAN ONLY BE DONE BY POSTING TO A HTTP FORM. A COOKIE IS THEN USED FOR INTERACTING WITH THE API
def _login(self): """ LOGIN CAN ONLY BE DONE BY POSTING TO A HTTP FORM. A COOKIE IS THEN USED FOR INTERACTING WITH THE API """ self.logger.debug("Logging into " + "{}/{}".format(self._im_api_url, "j_spring_security_check")) self._im_session.headers.update({'Content-Type':...
Convinient method for GET requests Returns http request status value from a POST request
def _do_get(self, uri, **kwargs): """ Convinient method for GET requests Returns http request status value from a POST request """ #TODO: # Add error handling. Check for HTTP status here would be much more conveinent than in each calling method scaleioapi_get_head...
Convinient method for POST requests Returns http request status value from a POST request
def _do_put(self, uri, **kwargs): """ Convinient method for POST requests Returns http request status value from a POST request """ #TODO: # Add error handling. Check for HTTP status here would be much more conveinent than in each calling method scaleioapi_put_hea...
Convinient method for POST requests Returns http request status value from a POST request
def _do_post(self, url, **kwargs): """ Convinient method for POST requests Returns http request status value from a POST request """ #TODO: # Add error handling. Check for HTTP status here would be much more conveinent than in each calling method scaleioapi_post_h...
Method to set Abort state if something goes wrong during provisioning Method also used to finish provisioning process when all is completed Method: POST
def set_abort_pending(self, newstate): """ Method to set Abort state if something goes wrong during provisioning Method also used to finish provisioning process when all is completed Method: POST """ self.logger.debug("set_abort_pending(" + "{})".format(newstate)) ...
Method push cached ScaleIO cluster configuration to IM ( reconfigurations that have been made to cached configuration are committed using IM ) Method: POST Attach JSON cluster configuration as request payload ( data ). Add MDM and LIA passwords )
def push_cached_cluster_configuration(self, mdmPassword, liaPassword, noUpload = False, noInstall= False, noConfigure = False): """ Method push cached ScaleIO cluster configuration to IM (reconfigurations that have been made to cached configuration are committed using IM) Method: POST At...
Using IM this method create a 3 - node ScaleIO cluster with 2xMDM 1xTB 3x SDS ( using/ dev/ sdb ) 3x SDC
def create_minimal_scaleio_cluster(self, mdmPassword, liaPassword): """ Using IM this method create a 3-node ScaleIO cluster with 2xMDM, 1xTB, 3x SDS (using /dev/sdb), 3x SDC """ """ self.read_cluster_config_from_disk("minimal-cluster.json") #self._cluster_config_cached.s...
Method push cached ScaleIO cluster configuration to IM ( reconfigurations that have been made to cached configuration are committed using IM ) Method: POST Attach JSON cluster configuration as request payload ( data ). Add MDM and LIA passwords )
def push_cluster_configuration(self, scaleioobj, noUpload = False, noInstall= False, noConfigure = False): """ Method push cached ScaleIO cluster configuration to IM (reconfigurations that have been made to cached configuration are committed using IM) Method: POST Attach JSON cluster con...
Not working. Am not able ot figure out how to upload. IT return status 200OK with this code but do not store the files. In tomcat. log ( IM ) there?s a complaint about character encoding whn uploading file. Not sure how to rectiy it in requests post call though
def uploadPackages(self, directory): """ Not working. Am not able ot figure out how to upload. IT return status 200OK with this code but do not store the files. In tomcat.log (IM) there?s a complaint about character encoding whn uploading file. Not sure how to rectiy it in requests post ...
Parameters as they look in the form for uploading packages to IM
def uploadFileToIM (self, directory, filename, title): """ Parameters as they look in the form for uploading packages to IM """ self.logger.debug("uploadFileToIM(" + "{},{},{})".format(directory, filename, title)) parameters = {'data-filename-placement':'inside', ...
NOT NEEDED. JSON can be POSTed to IM instead of sending a CSV that is locally parsed and converted to JSON. Remote Address: 192. 168. 100. 51: 443 Request URL: https:// 192. 168. 100. 51/ types/ Configuration/ instances/ actions/ parseFromCSV Request Method: POST Status Code: 200 OK Request Headersview source Accept: *...
def uploadCsvConfiguration(self, conf_filename): """ NOT NEEDED. JSON can be POSTed to IM instead of sending a CSV that is locally parsed and converted to JSON. Remote Address:192.168.100.51:443 Request URL:https://192.168.100.51/types/Configuration/instances/actions/parseFromCS...
Binary dump of the integer of given type
async def dump_varint_t(writer, type_or, pv): """ Binary dump of the integer of given type :param writer: :param type_or: :param pv: :return: """ width = int_mark_to_size(type_or) n = (pv << 2) | type_or buffer = _UINT_BUFFER for _ in range(width): buffer[0] = n & 0...
Binary dump of the variable size integer
async def dump_varint(writer, val): """ Binary dump of the variable size integer :param writer: :param val: :return: """ if val <= 63: return await dump_varint_t(writer, PortableRawSizeMark.BYTE, val) elif val <= 16383: return await dump_varint_t(writer, PortableRawSizeM...
Binary load of variable size integer serialized by dump_varint
async def load_varint(reader): """ Binary load of variable size integer serialized by dump_varint :param reader: :return: """ buffer = _UINT_BUFFER await reader.areadinto(buffer) width = int_mark_to_size(buffer[0] & PortableRawSizeMark.MASK) result = buffer[0] shift = 8 fo...
Binary string dump
async def dump_string(writer, val): """ Binary string dump :param writer: :param val: :return: """ await dump_varint(writer, len(val)) await writer.awrite(val)
Loads string from binary stream
async def load_string(reader): """ Loads string from binary stream :param reader: :return: """ ivalue = await load_varint(reader) fvalue = bytearray(ivalue) await reader.areadinto(fvalue) return bytes(fvalue)
Dumps blob to a binary stream
async def dump_blob(writer, elem, elem_type, params=None): """ Dumps blob to a binary stream :param writer: :param elem: :param elem_type: :param params: :return: """ elem_is_blob = isinstance(elem, x.BlobType) data = bytes(getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob els...
Loads blob from reader to the element. Returns the loaded blob.
async def load_blob(reader, elem_type, params=None, elem=None): """ Loads blob from reader to the element. Returns the loaded blob. :param reader: :param elem_type: :param params: :param elem: :return: """ ivalue = await load_varint(reader) fvalue = bytearray(ivalue) await r...
Root level init: return:
async def root(self): """ Root level init :return: """ if self.writing: await x.dump_uint(self.iobj, PortableStorageConsts.SIGNATUREA, 4) await x.dump_uint(self.iobj, PortableStorageConsts.SIGNATUREB, 4) await x.dump_uint(self.iobj, PortableSto...
Section/ dict serialization: return:
async def section(self, sec=None): """ Section / dict serialization :return: """ if self.writing: await dump_varint(self.iobj, len(sec)) for key in sec: await self.section_name(key) await self.storage_entry(sec[key]) ...
Section name: param sec_name:: return:
async def section_name(self, sec_name=None): """ Section name :param sec_name: :return: """ if self.writing: fvalue = sec_name.encode('ascii') await x.dump_uint(self.iobj, len(fvalue), 1) await self.iobj.awrite(bytearray(fvalue)) ...
Uvarint untouched: param elem:: return:
async def uvarint(self, elem): """ Uvarint untouched :param elem: :return: """ if self.writing: return await dump_varint(self.iobj, elem) else: return await load_varint(self.iobj)
Integer types: param elem:: param elem_type:: param params:: return:
async def uint(self, elem, elem_type, params=None): """ Integer types :param elem: :param elem_type: :param params: :return: """ if self.writing: return await x.dump_uint(self.iobj, elem, elem_type.WIDTH) else: return await ...
Unicode type: param elem:: return:
async def unicode_type(self, elem): """ Unicode type :param elem: :return: """ if self.writing: return await x.dump_unicode(self.iobj, elem) else: return await x.load_unicode(self.iobj)
Loads/ dumps blob: return:
async def blob(self, elem=None, elem_type=None, params=None): """ Loads/dumps blob :return: """ elem_type = elem_type if elem_type else elem.__class__ if hasattr(elem_type, 'blob_serialize'): elem = elem_type() if elem is None else elem return awai...
Loads/ dumps container: return:
async def container(self, container=None, container_type=None, params=None): """ Loads/dumps container :return: """ if hasattr(container_type, 'blob_serialize'): container = container_type() if container is None else container return await container.blob_s...
Determines element size after blob serialization. Can be quite tricky for complicated structures - another object required to implement sizeof ()
async def get_element_size(self, elem_type, elem=None, params=None): """ Determines element size after blob serialization. Can be quite tricky for complicated structures - another object required to implement sizeof() :param elem_type: :param elem: :param params: ...
Loads container of elements from the reader. Supports the container ref. Returns loaded container. Blob array writer as in XMRRPC is serialized without size serialization.
async def container_load(self, container_type, params=None, container=None, obj=None): """ Loads container of elements from the reader. Supports the container ref. Returns loaded container. Blob array writer as in XMRRPC is serialized without size serialization. :param container...
Loads/ dumps tuple: return:
async def tuple(self, elem=None, elem_type=None, params=None): """ Loads/dumps tuple :return: """ if hasattr(elem_type, 'blob_serialize'): container = elem_type() if elem is None else elem return await container.blob_serialize(self, elem=elem, elem_type=el...
Loads/ dumps variant type: param elem:: param elem_type:: param params:: param obj:: return:
async def variant(self, elem=None, elem_type=None, params=None): """ Loads/dumps variant type :param elem: :param elem_type: :param params: :param obj: :return: """ elem_type = elem_type if elem_type else elem.__class__ if hasattr(elem_typ...
Loads/ dumps message: param msg:: param msg_type:: param obj:: return:
async def message(self, msg, msg_type=None): """ Loads/dumps message :param msg: :param msg_type: :param obj: :return: """ elem_type = msg_type if msg_type is not None else msg.__class__ if hasattr(elem_type, 'blob_serialize'): msg = e...
Dumps/ Loads message field: param msg:: param field:: param fvalue: explicit value for dump: param obj:: return:
async def message_field(self, msg, field, fvalue=None, obj=None): """ Dumps/Loads message field :param msg: :param field: :param fvalue: explicit value for dump :param obj: :return: """ fname, ftype, params = field[0], field[1], field[2:] t...
Load/ dump individual message fields: param msg:: param fields:: param obj:: return:
async def message_fields(self, msg, fields, obj=None): """ Load/dump individual message fields :param msg: :param fields: :param obj: :return: """ for field in fields: await self.message_field(msg, field, obj) return msg
Archive field: param elem:: param elem_type:: param params:: return:
async def field(self, elem=None, elem_type=None, params=None): """ Archive field :param elem: :param elem_type: :param params: :return: """ elem_type = elem_type if elem_type else elem.__class__ fvalue = None src = elem if issubcla...
Main blobbing: param elem:: param elem_type:: param params:: return:
async def blobize(self, elem=None, elem_type=None, params=None): """ Main blobbing :param elem: :param elem_type: :param params: :return: """ if self.writing: await self.field(elem=elem, elem_type=elem_type, params=params) return by...
Integer types: param elem:: param elem_type:: param params:: return:
async def uint(self, elem, elem_type, params=None): """ Integer types :param elem: :param elem_type: :param params: :return: """ if self.writing: return IntegerModel(elem, elem_type.WIDTH) if self.modelize else elem else: re...
Loads/ dumps blob: return:
async def blob(self, elem=None, elem_type=None, params=None): """ Loads/dumps blob :return: """ elem_type = elem_type if elem_type else elem.__class__ if hasattr(elem_type, 'kv_serialize'): elem = elem_type() if elem is None else elem return await ...
Loads/ dumps container: return:
async def container(self, container=None, container_type=None, params=None, obj=None): """ Loads/dumps container :return: """ if hasattr(container_type, 'kv_serialize'): container = container_type() if container is None else container return await containe...
Dumps container of elements to the writer.
async def container_dump(self, container, container_type, params=None, obj=None): """ Dumps container of elements to the writer. :param container: :param container_type: :param params: :param obj: :return: """ elem_type = x.container_elem_type(con...
Loads container of elements from the reader. Supports the container ref. Returns loaded container.
async def container_load(self, container_type, params=None, container=None, obj=None): """ Loads container of elements from the reader. Supports the container ref. Returns loaded container. :param container_type: :param params: :param container: :param obj: ...
Loads/ dumps tuple: return:
async def tuple(self, elem=None, elem_type=None, params=None, obj=None): """ Loads/dumps tuple :return: """ if hasattr(elem_type, 'kv_serialize'): container = elem_type() if elem is None else elem return await container.kv_serialize(self, elem=elem, elem_t...
Dumps tuple of elements to the writer.
async def dump_tuple(self, elem, elem_type, params=None, obj=None): """ Dumps tuple of elements to the writer. :param elem: :param elem_type: :param params: :param obj: :return: """ if len(elem) != len(elem_type.f_specs()): raise Value...
Loads tuple of elements from the reader. Supports the tuple ref. Returns loaded tuple.
async def load_tuple(self, elem_type, params=None, elem=None, obj=None): """ Loads tuple of elements from the reader. Supports the tuple ref. Returns loaded tuple. :param elem_type: :param params: :param elem: :param obj: :return: """ if o...
Loads/ dumps variant type: param elem:: param elem_type:: param params:: param obj:: return:
async def variant(self, elem=None, elem_type=None, params=None, obj=None): """ Loads/dumps variant type :param elem: :param elem_type: :param params: :param obj: :return: """ elem_type = elem_type if elem_type else elem.__class__ if hasatt...
Dumps variant type to the writer. Supports both wrapped and raw variant.
async def dump_variant(self, elem, elem_type=None, params=None, obj=None): """ Dumps variant type to the writer. Supports both wrapped and raw variant. :param elem: :param elem_type: :param params: :param obj: :return: """ fvalue = None ...
Loads variant type from the reader. Supports both wrapped and raw variant.
async def load_variant(self, elem_type, params=None, elem=None, wrapped=None, obj=None): """ Loads variant type from the reader. Supports both wrapped and raw variant. :param elem_type: :param params: :param elem: :param wrapped: :param obj: :retu...