INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Dumps blob message. Supports both blob and raw value. | async def dump_blob(elem, elem_type=None):
"""
Dumps blob message.
Supports both blob and raw value.
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_is_blob = isinstance(elem, x.BlobType)
data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_bl... |
Serializes container as popo | async def dump_container(obj, container, container_type, params=None, field_archiver=None):
"""
Serializes container as popo
:param obj:
:param container:
:param container_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_archiver ... |
Loads container of elements from the object representation. Supports the container ref. Returns loaded container. | async def load_container(obj, container_type, params=None, container=None, field_archiver=None):
"""
Loads container of elements from the object representation. Supports the container ref.
Returns loaded container.
:param reader:
:param container_type:
:param params:
:param container:
:... |
Dumps a message field to the object. Field is defined by the message field specification. | async def dump_message_field(obj, msg, field, field_archiver=None):
"""
Dumps a message field to the object. Field is defined by the message field specification.
:param obj:
:param msg:
:param field:
:param field_archiver:
:return:
"""
fname, ftype, params = field[0], field[1], fiel... |
Loads message field from the object. Field is defined by the message field specification. Returns loaded value supports field reference. | async def load_message_field(obj, msg, field, field_archiver=None):
"""
Loads message field from the object. Field is defined by the message field specification.
Returns loaded value, supports field reference.
:param reader:
:param msg:
:param field:
:param field_archiver:
:return:
... |
Dumps message to the object. Returns message popo representation. | async def dump_message(obj, msg, field_archiver=None):
"""
Dumps message to the object.
Returns message popo representation.
:param obj:
:param msg:
:param field_archiver:
:return:
"""
mtype = msg.__class__
fields = mtype.f_specs()
obj = collections.OrderedDict() if obj is ... |
Loads message if the given type from the object. Supports reading directly to existing message. | async def load_message(obj, msg_type, msg=None, field_archiver=None):
"""
Loads message if the given type from the object.
Supports reading directly to existing message.
:param obj:
:param msg_type:
:param msg:
:param field_archiver:
:return:
"""
msg = msg_type() if msg is None ... |
Transform variant to the popo object representation. | async def dump_variant(obj, elem, elem_type=None, params=None, field_archiver=None):
"""
Transform variant to the popo object representation.
:param obj:
:param elem:
:param elem_type:
:param params:
:param field_archiver:
:return:
"""
field_archiver = field_archiver if field_ar... |
Loads variant from the obj representation: param obj:: param elem:: param elem_type:: param params:: param field_archiver:: param wrapped:: return: | async def load_variant(obj, elem, elem_type=None, params=None, field_archiver=None, wrapped=None):
"""
Loads variant from the obj representation
:param obj:
:param elem:
:param elem_type:
:param params:
:param field_archiver:
:param wrapped:
:return:
"""
field_archiver = fiel... |
Dumps generic field to the popo object representation according to the element specification. General multiplexer. | async def dump_field(obj, elem, elem_type, params=None):
"""
Dumps generic field to the popo object representation, according to the element specification.
General multiplexer.
:param obj:
:param elem:
:param elem_type:
:param params:
:return:
"""
if isinstance(elem, (int, bool)... |
Loads a field from the reader based on the field type specification. Demultiplexer. | async def load_field(obj, elem_type, params=None, elem=None):
"""
Loads a field from the reader, based on the field type specification. Demultiplexer.
:param obj:
:param elem_type:
:param params:
:param elem:
:return:
"""
if issubclass(elem_type, x.UVarintType) or issubclass(elem_ty... |
Extend the given: class: jsonschema. IValidator with the Seep layer. | def extend(validator_cls):
"""
Extend the given :class:`jsonschema.IValidator` with the Seep layer.
"""
Validator = jsonschema.validators.extend(
validator_cls, {
"properties": _properties_with_defaults(validator_cls),
}
)
class Blueprinter(Validator):
def ... |
Instantiate the given data using the blueprinter. | def instantiate(data, blueprint):
"""
Instantiate the given data using the blueprinter.
Arguments
---------
blueprint (collections.Mapping):
a blueprint (JSON Schema with Seep properties)
"""
Validator = jsonschema.validators.validator_for(blueprint)
blueprinter = ext... |
The entry point of the script. | def main(argv=None):
"""
The entry point of the script.
"""
from vsgen import VSGSuite
from vsgen import VSGLogger
# Special case to use the sys.argv when main called without a list.
if argv is None:
argv = sys.argv
# Initialize the application logger
pylogger = VSGLogger()... |
Parse model fields. | def parse_fields(attributes):
"""Parse model fields."""
return tuple(field.bind_name(name)
for name, field in six.iteritems(attributes)
if isinstance(field, fields.Field)) |
Prepare model fields attribute. | def prepare_fields_attribute(attribute_name, attributes, class_name):
"""Prepare model fields attribute."""
attribute = attributes.get(attribute_name)
if not attribute:
attribute = tuple()
elif isinstance(attribute, std_collections.Iterable):
attribute = tuple(att... |
Bind fields to model class. | def bind_fields_to_model_cls(cls, model_fields):
"""Bind fields to model class."""
return dict(
(field.name, field.bind_model_cls(cls)) for field in model_fields) |
Bind collection to model s class. | def bind_collection_to_model_cls(cls):
"""Bind collection to model's class.
If collection was not specialized in process of model's declaration,
subclass of collection will be created.
"""
cls.Collection = type('{0}.Collection'.format(cls.__name__),
... |
Checklist for releasing this project. | def checklist(ctx):
"""Checklist for releasing this project."""
checklist = """PRE-RELEASE CHECKLIST:
[ ] Everything is checked in
[ ] All tests pass w/ tox
RELEASE CHECKLIST:
[{x1}] Bump version to new-version and tag repository (via bump_version)
[{x2}] Build packages (sdist, bdist_wheel via prepare)
[{x... |
Bump version ( to prepare a new release ). | def bump_version(ctx, new_version, version_part=None, dry_run=False):
"""Bump version (to prepare a new release)."""
version_part = version_part or "minor"
if dry_run:
ctx = DryRunContext(ctx)
ctx.run("bumpversion --new-version={} {}".format(new_version,
... |
Build packages for this release. | def build_packages(ctx, hide=False):
"""Build packages for this release."""
print("build_packages:")
ctx.run("python setup.py sdist bdist_wheel", echo=True, hide=hide) |
Prepare the release: bump version build packages... | def prepare(ctx, new_version=None, version_part=None, hide=True,
dry_run=False):
"""Prepare the release: bump version, build packages, ..."""
if new_version is not None:
bump_version(ctx, new_version, version_part=version_part,
dry_run=dry_run)
build_packages(ctx, hi... |
Register release ( packages ) in artifact - store/ repository. | def register_packages(ctx, repo=None, dry_run=False):
"""Register release (packages) in artifact-store/repository."""
original_ctx = ctx
if repo is None:
repo = ctx.project.repo or "pypi"
if dry_run:
ctx = DryRunContext(ctx)
packages = ensure_packages_exist(original_ctx)
print_p... |
Register a new thread. | def register(self, name, function, description=None):
"""
Register a new thread.
:param function: Function, which gets called for the new thread
:type function: function
:param name: Unique name of the thread for documentation purposes.
:param description: Short descript... |
Registers a new document. | def register(self, name, function, plugin, description=None):
"""
Registers a new document.
.. warning: You can not use any relative links inside a given document.
For instance, sphinx's toctree, image, figure or include statements do not work.
:param function: Func... |
Unregisters an existing thread so that this thread is no longer available. | def unregister(self, thread):
"""
Unregisters an existing thread, so that this thread is no longer available.
This function is mainly used during plugin deactivation.
:param thread: Name of the thread
"""
if thread not in self.threads.keys():
self.log.warnin... |
Get one or more threads. | def get(self, thread=None, plugin=None):
"""
Get one or more threads.
:param thread: Name of the thread
:type thread: str
:param plugin: Plugin object, under which the thread was registered
:type plugin: GwBasePattern
"""
if plugin is not None:
... |
Create and fill the schema from a directory which contains xsd files. It calls fill_schema_from_xsd_file for each xsd file found. | def create_schema_from_xsd_directory(directory, version):
"""Create and fill the schema from a directory which contains xsd
files. It calls fill_schema_from_xsd_file for each xsd file
found.
"""
schema = Schema(version)
for f in _get_xsd_from_directory(directory):
logger.info("Loading s... |
From an xsd file it fills the schema by creating needed Resource. The generateds idl_parser is used to parse ifmap statements in the xsd file. | def fill_schema_from_xsd_file(filename, schema):
"""From an xsd file, it fills the schema by creating needed
Resource. The generateds idl_parser is used to parse ifmap
statements in the xsd file.
"""
ifmap_statements = _parse_xsd_file(filename)
properties_all = []
for v in ifmap_statements... |
Decorator to split files into manageable chunks as not to exceed the windows cmd limit | def split_ls(func):
"""Decorator to split files into manageable chunks as not to exceed the windows cmd limit
:param func: Function to call for each chunk
:type func: :py:class:Function
"""
@wraps(func)
def wrapper(self, files, silent=True, exclude_deleted=False):
if not isinstance(file... |
Parses the P4 env vars using set p4 | def __getVariables(self):
"""Parses the P4 env vars using 'set p4'"""
try:
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = subprocess.check_ou... |
The client used in perforce queries | def client(self):
"""The client used in perforce queries"""
if isinstance(self._client, six.string_types):
self._client = Client(self._client, self)
return self._client |
The status of the connection to perforce | def status(self):
"""The status of the connection to perforce"""
try:
# -- Check client
res = self.run(['info'])
if res[0]['clientName'] == '*unknown*':
return ConnectionStatus.INVALID_CLIENT
# -- Trigger an auth error if not logged in
... |
Runs a p4 command and returns a list of dictionary objects | def run(self, cmd, stdin=None, marshal_output=True, **kwargs):
"""Runs a p4 command and returns a list of dictionary objects
:param cmd: Command to run
:type cmd: list
:param stdin: Standard Input to send to the process
:type stdin: str
:param marshal_output: Whether or ... |
List files | def ls(self, files, silent=True, exclude_deleted=False):
"""List files
:param files: Perforce file spec
:type files: list
:param silent: Will not raise error for invalid files or files not under the client
:type silent: bool
:param exclude_deleted: Exclude deleted files ... |
Gets or creates a Changelist object with a description | def findChangelist(self, description=None):
"""Gets or creates a Changelist object with a description
:param description: The description to set or lookup
:type description: str
:returns: :class:`.Changelist`
"""
if description is None:
change = Default(self)... |
Adds a new file to a changelist | def add(self, filename, change=None):
"""Adds a new file to a changelist
:param filename: File path to add
:type filename: str
:param change: Changelist to add the file to
:type change: int
:returns: :class:`.Revision`
"""
try:
if not self.can... |
Determines if a filename can be added to the depot under the current client | def canAdd(self, filename):
"""Determines if a filename can be added to the depot under the current client
:param filename: File path to add
:type filename: str
"""
try:
result = self.run(['add', '-n', '-t', 'text', filename])[0]
except errors.CommandError as... |
Saves the state of the changelist | def save(self):
"""Saves the state of the changelist"""
if not self._dirty:
return
fields = []
formdata = dict(self._p4dict)
del formdata['code']
for key, value in six.iteritems(formdata):
match = re.search('\d$', key)
if match:
... |
Queries the depot to get the current status of the changelist | def query(self, files=True):
"""Queries the depot to get the current status of the changelist"""
if self._change:
cl = str(self._change)
self._p4dict = {camel_case(k): v for k, v in six.iteritems(self._connection.run(['change', '-o', cl])[0])}
if files:
self.... |
Adds a: py: class: Revision to this changelist and adds or checks it out if needed | def append(self, rev):
"""Adds a :py:class:Revision to this changelist and adds or checks it out if needed
:param rev: Revision to add
:type rev: :class:`.Revision`
"""
if not isinstance(rev, Revision):
results = self._connection.ls(rev)
if not results:
... |
Removes a revision from this changelist | def remove(self, rev, permanent=False):
"""Removes a revision from this changelist
:param rev: Revision to remove
:type rev: :class:`.Revision`
:param permanent: Whether or not we need to set the changelist to default
:type permanent: bool
"""
if not isinstance(r... |
Revert all files in this changelist | def revert(self, unchanged_only=False):
"""Revert all files in this changelist
:param unchanged_only: Only revert unchanged files
:type unchanged_only: bool
:raises: :class:`.ChangelistError`
"""
if self._reverted:
raise errors.ChangelistError('This changelis... |
Saves the state of the changelist | def save(self):
"""Saves the state of the changelist"""
self._connection.run(['change', '-i'], stdin=format(self), marshal_output=False)
self._dirty = False |
Submits a chagelist to the depot | def submit(self):
"""Submits a chagelist to the depot"""
if self._dirty:
self.save()
self._connection.run(['submit', '-c', str(self._change)], marshal_output=False) |
Reverts all files in this changelist then deletes the changelist from perforce | def delete(self):
"""Reverts all files in this changelist then deletes the changelist from perforce"""
try:
self.revert()
except errors.ChangelistError:
pass
self._connection.run(['change', '-d', str(self._change)]) |
Creates a new changelist | def create(description='<Created by Python>', connection=None):
"""Creates a new changelist
:param connection: Connection to use to create the changelist
:type connection: :class:`.Connection`
:param description: Description for new changelist
:type description: str
:ret... |
Saves the state of the changelist | def save(self):
"""Saves the state of the changelist"""
files = [f.depotFile for f in self._files]
cmd = ['reopen', '-c', 'default']
self._connection.run(cmd + files)
self._dirty = False |
Runs an fstat for this file and repopulates the data | def query(self):
"""Runs an fstat for this file and repopulates the data"""
self._p4dict = self._connection.run(['fstat', '-m', '1', self._p4dict['depotFile']])[0]
self._head = HeadRevision(self._p4dict)
self._filename = self.depotFile |
Checks out the file | def edit(self, changelist=0):
"""Checks out the file
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
command = 'reopen' if self.action in ('add', 'edit') else 'edit'
if int(changelist):
self._connect... |
Locks or unlocks the file | def lock(self, lock=True, changelist=0):
"""Locks or unlocks the file
:param lock: Lock or unlock the file
:type lock: bool
:param changelist: Optional changelist to checkout the file into
:type changelist: :class:`.Changelist`
"""
cmd = 'lock' if lock else 'unl... |
Syncs the file at the current revision | def sync(self, force=False, safe=True, revision=0, changelist=0):
"""Syncs the file at the current revision
:param force: Force the file to sync
:type force: bool
:param safe: Don't sync files that were changed outside perforce
:type safe: bool
:param revision: Sync to a... |
Reverts any file changes | def revert(self, unchanged=False):
"""Reverts any file changes
:param unchanged: Only revert if the file is unchanged
:type unchanged: bool
"""
cmd = ['revert']
if unchanged:
cmd.append('-a')
wasadd = self.action == 'add'
cmd.append(self.dep... |
Shelves the file if it is in a changelist | def shelve(self, changelist=None):
"""Shelves the file if it is in a changelist
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
if changelist is None and self.changelist.description == 'default':
raise errors.ShelveError('U... |
Renames/ moves the file to dest | def move(self, dest, changelist=0, force=False):
"""Renames/moves the file to dest
:param dest: Destination to move the file to
:type dest: str
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
:param force: Force the move to an exis... |
Marks the file for delete | def delete(self, changelist=0):
"""Marks the file for delete
:param changelist: Changelist to add the move to
:type changelist: :class:`.Changelist`
"""
cmd = ['delete']
if changelist:
cmd += ['-c', str(changelist)]
cmd.append(self.depotFile)
... |
The hash value of the current revision | def hash(self):
"""The hash value of the current revision"""
if 'digest' not in self._p4dict:
self._p4dict = self._connection.run(['fstat', '-m', '1', '-Ol', self.depotFile])[0]
return self._p4dict['digest'] |
Revision number | def revision(self):
"""Revision number"""
rev = self._p4dict.get('haveRev', -1)
if rev == 'none':
rev = 0
return int(rev) |
Which: class:. Changelist is this revision in | def changelist(self):
"""Which :class:`.Changelist` is this revision in"""
if self._changelist:
return self._changelist
if self._p4dict['change'] == 'default':
return Default(connection=self._connection)
else:
return Changelist(str(self._p4dict['chang... |
A list of view specs | def view(self):
"""A list of view specs"""
spec = []
for k, v in six.iteritems(self._p4dict):
if k.startswith('view'):
match = RE_FILESPEC.search(v)
if match:
spec.append(FileSpec(v[:match.end() - 1], v[match.end():]))
retu... |
Which stream if any the client is under | def stream(self):
"""Which stream, if any, the client is under"""
stream = self._p4dict.get('stream')
if stream:
return Stream(stream, self._connection) |
Monero portable_binary_archive boost integer serialization: param reader:: return: | async def load_uvarint(reader):
"""
Monero portable_binary_archive boost integer serialization
:param reader:
:return:
"""
buffer = _UVARINT_BUFFER
await reader.areadinto(buffer)
size = buffer[0]
if size == 0:
return 0
negative = size < 0
size = -size if negative els... |
Monero portable_binary_archive boost integer serialization: param writer:: param n:: return: | async def dump_uvarint(writer, n):
"""
Monero portable_binary_archive boost integer serialization
:param writer:
:param n:
:return:
"""
buffer = _UVARINT_BUFFER
if n == 0:
buffer[0] = 0
return await writer.awrite(buffer)
negative = n < 0
ll = -n if negative else ... |
Determines if type is in the database: param tp:: return: | def type_in_db(self, tp, params):
"""
Determines if type is in the database
:param tp:
:return:
"""
tw = TypeWrapper(tp, params)
return self.version_db.is_versioned(tw) |
Loads version from the stream/ version database # TODO: instance vs. tp. | async def get_version(self, tp, params):
"""
Loads version from the stream / version database
# TODO: instance vs. tp.
:param tp:
:param params:
:return:
"""
tw = TypeWrapper(tp, params)
if not tw.is_versioned():
# self.registry.set_tr... |
Stores version to the stream if not stored yet | async def set_version(self, tp, params, version=None, elem=None):
"""
Stores version to the stream if not stored yet
:param tp:
:param params:
:param version:
:param elem:
:return:
"""
self.registry.set_tr(None)
tw = TypeWrapper(tp, params... |
Symmetric version management | async def version(self, tp, params, version=None, elem=None):
"""
Symmetric version management
:param tp:
:param params:
:param version:
:return:
"""
if self.writing:
return await self.set_version(tp, params, version, elem)
else:
... |
Uvarint: param elem:: return: | async def uvarint(self, elem):
"""
Uvarint
:param elem:
:return:
"""
if self.writing:
return await dump_uvarint(self.iobj, elem)
else:
return await load_uvarint(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:
"""
one_b_type = x.is_type(elem_type, (x.Int8, x.UInt8))
if self.writing:
return (await x.dump_uint(self.iobj, ... |
Unicode type: param elem:: return: | async def unicode_type(self, elem):
"""
Unicode type
:param elem:
:return:
"""
if self.writing:
await dump_uvarint(self.iobj, len(elem))
await self.iobj.awrite(bytes(elem, 'utf8'))
else:
ivalue = await load_uvarint(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__
version = await self.version(elem_type, params, elem=elem)
if self.is_tracked():
return self.get_tra... |
Dumps blob message to the writer. Supports both blob and raw value. | async def blob_dump(self, elem, elem_type, params=None):
"""
Dumps blob message to the writer.
Supports both blob and raw value.
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_is_blob = isinstance(elem, x.Bl... |
Loads blob from reader to the element. Returns the loaded blob. | async def blob_load(self, 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_uvarint(self.iobj)
... |
Loads/ dumps container: return: | async def container(self, container=None, container_type=None, params=None):
"""
Loads/dumps container
:return:
"""
# Container versioning is a bit tricky, primitive type containers are not versioned.
elem_type = x.container_elem_type(container_type, params)
raw_c... |
Container size: param container_len:: param container_type:: param params:: return: | async def container_size(self, container_len=None, container_type=None, params=None):
"""
Container size
:param container_len:
:param container_type:
:param params:
:return:
"""
if hasattr(container_type, 'boost_serialize'):
raise ValueError('n... |
Single cont value: param elem:: param container_type:: param params:: param field_archiver:: return: | async def container_val(self, elem, container_type, params=None):
"""
Single cont value
:param elem:
:param container_type:
:param params:
:param field_archiver:
:return:
"""
if hasattr(container_type, 'boost_serialize'):
raise ValueErr... |
Dumps container of elements to the writer. | async def container_dump(self, container, container_type, params=None):
"""
Dumps container of elements to the writer.
:param writer:
:param container:
:param container_type:
:param params:
:param field_archiver:
:return:
"""
await self.co... |
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):
"""
Loads container of elements from the reader. Supports the container ref.
Returns loaded container.
:param container_type:
:param params:
:param container:
:param field_archiver:
... |
Loads/ dumps tuple: return: | async def tuple(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps tuple
:return:
"""
version = await self.version(elem_type, params, elem=elem)
if self.is_tracked():
return self.get_tracked()
if hasattr(elem_type, 'boost_serialize'):
... |
Dumps tuple of elements to the writer. | async def dump_tuple(self, elem, elem_type, params=None):
"""
Dumps tuple of elements to the writer.
:param elem:
:param elem_type:
:param params:
:return:
"""
if len(elem) != len(elem_type.f_specs()):
raise ValueError('Fixed size tuple has no... |
Loads/ dumps variant type: param elem:: param elem_type:: param params:: return: | async def variant(self, elem=None, elem_type=None, params=None):
"""
Loads/dumps variant type
:param elem:
:param elem_type:
:param params:
:return:
"""
elem_type = elem_type if elem_type else elem.__class__
version = await self.version(elem_type, ... |
Dumps variant type to the writer. Supports both wrapped and raw variant. | async def dump_variant(self, elem, elem_type=None, params=None):
"""
Dumps variant type to the writer.
Supports both wrapped and raw variant.
:param writer:
:param elem:
:param elem_type:
:param params:
:return:
"""
if isinstance(elem, x.V... |
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):
"""
Loads variant type from the reader.
Supports both wrapped and raw variant.
:param reader:
:param elem_type:
:param params:
:param elem:
:param wrapped:
:return:
... |
Root level init: return: | async def root(self):
"""
Root level init
:return:
"""
if self.writing:
await self.iobj.awrite(binascii.unhexlify(b'011673657269616c697a6174696f6e3a3a617263686976650000'))
else:
hdr = bytearray(2)
await self.iobj.areadinto(hdr)
... |
Root - level message. First entry in the archive. Archive headers processing | async def root_message(self, msg, msg_type=None):
"""
Root-level message. First entry in the archive.
Archive headers processing
:return:
"""
await self.root()
await self.message(msg, msg_type) |
Loads/ dumps message: param msg:: param msg_type:: param use_version:: return: | async def message(self, msg, msg_type=None, use_version=None):
"""
Loads/dumps message
:param msg:
:param msg_type:
:param use_version:
:return:
"""
elem_type = msg_type if msg_type is not None else msg.__class__
version = await self.version(elem_t... |
Load/ dump individual message fields: param msg:: param fields:: param field_archiver:: return: | async def message_fields(self, msg, fields):
"""
Load/dump individual message fields
:param msg:
:param fields:
:param field_archiver:
:return:
"""
for field in fields:
try:
self.tracker.push_field(field[0])
awai... |
Dumps message to the writer. | async def dump_message(self, msg, msg_type=None):
"""
Dumps message to the writer.
:param msg:
:param msg_type:
:return:
"""
mtype = msg.__class__ if msg_type is None else msg_type
fields = mtype.f_specs()
for field in fields:
await se... |
Loads message if the given type from the reader. Supports reading directly to existing message. | async def load_message(self, msg_type, msg=None):
"""
Loads message if the given type from the reader.
Supports reading directly to existing message.
:param msg_type:
:param msg:
:return:
"""
msg = msg_type() if msg is None else msg
fields = msg_t... |
: param resource: Resource ( not necessary fetched ): param next_resource_name: string: rtype: ( resource_type resource_path ) | def _get_next_resource(self, resource, next_resource_name, selectors):
"""
:param resource: Resource (not necessary fetched)
:param next_resource_name: string
:rtype: (resource_type, resource_path)
"""
# don't fetch twice
if 'id_perms' not in resource:
... |
Handle HTTP errors returned by the API server | def contrail_error_handler(f):
"""Handle HTTP errors returned by the API server
"""
@wraps(f)
def wrapper(*args, **kwargs):
try:
return f(*args, **kwargs)
except HttpError as e:
# Replace message by details to provide a
# meaningful message
... |
Initialize a session to Contrail API server | def make(self, host="localhost", port=8082, protocol="http", base_uri="", os_auth_type="http", **kwargs):
"""Initialize a session to Contrail API server
:param os_auth_type: auth plugin to use:
- http: basic HTTP authentification
- v2password: keystone v2 auth
- v3pa... |
POST data to the api - server | def post_json(self, url, data, cls=None, **kwargs):
"""
POST data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kw... |
PUT data to the api - server | def put_json(self, url, data, cls=None, **kwargs):
"""
PUT data to the api-server
:param url: resource location (eg: "/type/uuid")
:type url: str
:param cls: JSONEncoder class
:type cls: JSONEncoder
"""
kwargs['data'] = to_json(data, cls=cls)
kwar... |
Return uuid for fq_name | def fqname_to_id(self, fq_name, type):
"""
Return uuid for fq_name
:param fq_name: resource fq name
:type fq_name: FQName
:param type: resource type
:type type: str
:rtype: UUIDv4 str
:raises HttpError: fq_name not found
"""
data = {
... |
Return fq_name and type for uuid | def id_to_fqname(self, uuid, type=None):
"""
Return fq_name and type for uuid
If `type` is provided check that uuid is actually
a resource of type `type`. Raise HttpError if it's
not the case.
:param uuid: resource uuid
:type uuid: UUIDv4 str
:param type... |
Search for a key in the key - value store.: param key: string: rtype: string | def search_kv_store(self, key):
"""Search for a key in the key-value store.
:param key: string
:rtype: string
"""
data = {
'operation': 'RETRIEVE',
'key': key
}
return self.post_json(self.make_url("/useragent-kv"), data)['value'] |
Add a key - value store entry. | def add_kv_store(self, key, value):
"""Add a key-value store entry.
:param key: string
:param value: string
"""
data = {
'operation': 'STORE',
'key': key,
'value': value
}
return self.post(self.make_url("/useragent-kv"), data=t... |
Remove a key - value store entry. | def remove_kv_store(self, key):
"""Remove a key-value store entry.
:param key: string
"""
data = {
'operation': 'DELETE',
'key': key
}
return self.post(self.make_url("/useragent-kv"), data=to_json(data),
headers=self.defau... |
Returns the given operations array sorted with duplicates removed. | def canonical_ops(ops):
''' Returns the given operations array sorted with duplicates removed.
@param ops checker.Ops
@return: checker.Ops
'''
new_ops = sorted(set(ops), key=lambda x: (x.entity, x.action))
return new_ops |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.