Search is not available for this dataset
text stringlengths 75 104k |
|---|
def colAdd(self,name="",desc="",unit="",comment="",coltype=0,data=[],pos=None):
"""
column types:
0: Y
1: Disregard
2: Y Error
3: X
4: Label
5: Z
6: X Error
"""
if pos is None:
pos=len(self.co... |
def colDelete(self,colI=-1):
"""delete a column at a single index. Negative numbers count from the end."""
# print("DELETING COLUMN: [%d] %s"%(colI,self.colDesc[colI]))
self.colNames.pop(colI)
self.colDesc.pop(colI)
self.colUnits.pop(colI)
self.colComments.pop(colI)
... |
def onex(self):
"""
delete all X columns except the first one.
"""
xCols=[i for i in range(self.nCols) if self.colTypes[i]==3]
if len(xCols)>1:
for colI in xCols[1:][::-1]:
self.colDelete(colI) |
def alignXY(self):
"""aligns XY pairs (or XYYY etc) by X value."""
# figure out what data we have and will align to
xVals=[]
xCols=[x for x in range(self.nCols) if self.colTypes[x]==3]
yCols=[x for x in range(self.nCols) if self.colTypes[x]==0]
xCols,yCols=np.array(xCols... |
def wiggle(self,noiseLevel=.1):
"""Slightly changes value of every cell in the worksheet. Used for testing."""
noise=(np.random.rand(*self.data.shape))-.5
self.data=self.data+noise*noiseLevel |
def pull(self,bookName=None,sheetName=None):
"""pull data into this OR.SHEET from a real book/sheet in Origin"""
# tons of validation
if bookName is None and self.bookName: bookName=self.bookName
if sheetName is None and self.sheetName: sheetName=self.sheetName
if bookName is No... |
def push(self,bookName=None,sheetName=None,overwrite=False):
"""pull this OR.SHEET into a real book/sheet in Origin"""
# tons of validation
if bookName: self.bookName=bookName
if sheetName: self.sheetName=sheetName
if not self.sheetName in OR.sheetNames(bookName):
pri... |
def nRows(self):
"""returns maximum number of rows based on the longest colData"""
if self.nCols: return max([len(x) for x in self.colData])
else: return 0 |
def data(self):
"""return all of colData as a 2D numpy array."""
data=np.empty((self.nRows,self.nCols),dtype=np.float)
data[:]=np.nan # make everything nan by default
for colNum,colData in enumerate(self.colData):
validIs=np.where([np.isreal(v) for v in colData])[0]
... |
def data(self,data):
"""Given a 2D numpy array, fill colData with it."""
assert type(data) is np.ndarray
assert data.shape[1] == self.nCols
for i in range(self.nCols):
self.colData[i]=data[:,i].tolist() |
def focusout(self, event):
"""Change style on focus out events."""
bc = self.style.lookup("TEntry", "bordercolor", ("!focus",))
dc = self.style.lookup("TEntry", "darkcolor", ("!focus",))
lc = self.style.lookup("TEntry", "lightcolor", ("!focus",))
self.style.configure("%s.spinbox.... |
def focusin(self, event):
"""Change style on focus in events."""
self.old_value = self.get()
bc = self.style.lookup("TEntry", "bordercolor", ("focus",))
dc = self.style.lookup("TEntry", "darkcolor", ("focus",))
lc = self.style.lookup("TEntry", "lightcolor", ("focus",))
se... |
def open(self):
"""
Obtains the lvm handle. Usually you would never need to use this method unless
you are trying to do operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if not self.handle:
try:
... |
def close(self):
"""
Closes the lvm handle. Usually you would never need to use this method unless
you are trying to do operations using the ctypes function wrappers in conversion.py
*Raises:*
* HandleError
"""
if self.handle:
q = lvm_quit(self... |
def get_vg(self, name, mode="r"):
"""
Returns an instance of VolumeGroup. The name parameter should be an existing
volume group. By default, all volume groups are open in "read" mode::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg")
To open... |
def create_vg(self, name, devices):
"""
Returns a new instance of VolumeGroup with the given name and added physycal
volumes (devices)::
from lvm2py import *
lvm = LVM()
vg = lvm.create_vg("myvg", ["/dev/sdb1", "/dev/sdb2"])
*Args:*
* ... |
def remove_vg(self, vg):
"""
Removes a volume group::
from lvm2py import *
lvm = LVM()
vg = lvm.get_vg("myvg", "w")
lvm.remove_vg(vg)
*Args:*
* vg (obj): A VolumeGroup instance.
*Raises:*
* HandleErro... |
def vgscan(self):
"""
Probes the system for volume groups and returns a list of VolumeGroup
instances::
from lvm2py import *
lvm = LVM()
vgs = lvm.vgscan()
*Raises:*
* HandleError
"""
vg_list = []
self.open()
... |
def from_file(cls, path):
"""
Create a text from a file.
Args:
path (str): The file path.
"""
with open(path, 'r', errors='replace') as f:
return cls(f.read()) |
def load_stopwords(self, path):
"""
Load a set of stopwords.
Args:
path (str): The stopwords file path.
"""
if path:
with open(path) as f:
self.stopwords = set(f.read().splitlines())
else:
self.stopwords = set(
... |
def tokenize(self):
"""
Tokenize the text.
"""
self.tokens = []
self.terms = OrderedDict()
# Generate tokens.
for token in utils.tokenize(self.text):
# Ignore stopwords.
if token['unstemmed'] in self.stopwords:
self.toke... |
def term_counts(self):
"""
Returns:
OrderedDict: An ordered dictionary of term counts.
"""
counts = OrderedDict()
for term in self.terms:
counts[term] = len(self.terms[term])
return utils.sort_dict(counts) |
def term_count_buckets(self):
"""
Returns:
dict: A dictionary that maps occurrence counts to the terms that
appear that many times in the text.
"""
buckets = {}
for term, count in self.term_counts().items():
if count in buckets: buckets[count... |
def most_frequent_terms(self, depth):
"""
Get the X most frequent terms in the text, and then probe down to get
any other terms that have the same count as the last term.
Args:
depth (int): The number of terms.
Returns:
set: The set of frequent terms.
... |
def unstem(self, term):
"""
Given a stemmed term, get the most common unstemmed variant.
Args:
term (str): A stemmed term.
Returns:
str: The unstemmed token.
"""
originals = []
for i in self.terms[term]:
originals.append(sel... |
def kde(self, term, bandwidth=2000, samples=1000, kernel='gaussian'):
"""
Estimate the kernel density of the instances of term in the text.
Args:
term (str): A stemmed term.
bandwidth (int): The kernel bandwidth.
samples (int): The number of evenly-spaced sa... |
def score_intersect(self, term1, term2, **kwargs):
"""
Compute the geometric area of the overlap between the kernel density
estimates of two terms.
Args:
term1 (str)
term2 (str)
Returns: float
"""
t1_kde = self.kde(term1, **kwargs)
... |
def score_cosine(self, term1, term2, **kwargs):
"""
Compute a weighting score based on the cosine distance between the
kernel density estimates of two terms.
Args:
term1 (str)
term2 (str)
Returns: float
"""
t1_kde = self.kde(term1, **kw... |
def score_braycurtis(self, term1, term2, **kwargs):
"""
Compute a weighting score based on the "City Block" distance between
the kernel density estimates of two terms.
Args:
term1 (str)
term2 (str)
Returns: float
"""
t1_kde = self.kde(t... |
def plot_term_kdes(self, words, **kwargs):
"""
Plot kernel density estimates for multiple words.
Args:
words (list): A list of unstemmed terms.
"""
stem = PorterStemmer().stem
for word in words:
kde = self.kde(stem(word), **kwargs)
... |
def generate(self, field_name, field):
"""Tries to lookup a matching formfield generator (lowercase
field-classname) and raises a NotImplementedError of no generator
can be found.
"""
if hasattr(self, 'generate_%s' % field.__class__.__name__.lower()):
generator = get... |
def _fixIndex(self, index, truncate=False):
"""
@param truncate: If true, negative indices which go past the
beginning of the list will be evaluated as zero.
For example::
>>> L = List([1,2,3,4,5])
>>> l... |
def overlapping(startAttribute, # X
endAttribute, # Y
startValue, # A
endValue, # B
):
"""
Return an L{axiom.iaxiom.IComparison} (an object that can be passed as the
'comparison' argument to Store.query/.sum/.count) which will const... |
def _tupleCompare(tuple1, ineq, tuple2,
eq=lambda a,b: (a==b),
ander=AND,
orer=OR):
"""
Compare two 'in-database tuples'. Useful when sorting by a compound key
and slicing into the middle of that query.
"""
orholder = []
for limit in range(len... |
def truncate_rationale(rationale, max_length=MAX_RATIONALE_SIZE_IN_EVENT):
"""
Truncates the rationale for analytics event emission if necessary
Args:
rationale (string): the string value of the rationale
max_length (int): the max length for truncation
Returns:
truncated_value ... |
def validate_options(options):
"""
Validate the options that course author set up and return errors in a dict if there is any
"""
errors = []
if int(options['rationale_size']['min']) < 1:
errors.append(_('Minimum Characters'))
if int(options['rationale_size']['max']) < 0 or int(options[... |
def get_student_item_dict(self, anonymous_user_id=None):
"""Create a student_item_dict from our surrounding context.
See also: submissions.api for details.
Args:
anonymous_user_id(str): A unique anonymous_user_id for (user, course) pair.
Returns:
(dict): The stu... |
def get_answers_for_student(student_item):
"""
Retrieve answers from backend for a student and question
Args:
student_item (dict): The location of the problem this submission is
associated with, as defined by a course, student, and item.
Returns:
Answers: answers for the st... |
def add_answer_for_student(student_item, vote, rationale):
"""
Add an answer for a student to the backend
Args:
student_item (dict): The location of the problem this submission is
associated with, as defined by a course, student, and item.
vote (int): the option that student vot... |
def _safe_get(self, revision, key):
"""
Get an answer data (vote or rationale) by revision
Args:
revision (int): the revision number for student answer, could be
0 (original) or 1 (revised)
key (str); key for retrieve answer data, could be VOTE_KEY or
... |
def add_answer(self, vote, rationale):
"""
Add an answer
Args:
vote (int): the option that student voted for
rationale (str): the reason why the student vote for the option
"""
self.raw_answers.append({
VOTE_KEY: vote,
RATIONALE_KE... |
def exceptionToString(e,silent=False):
"""when you "except Exception as e", give me the e and I'll give you a string."""
exc_type, exc_obj, exc_tb = sys.exc_info()
s=("\n"+"="*50+"\n")
s+="EXCEPTION THROWN UNEXPECTEDLY\n"
s+=" FILE: %s\n"%os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
s+=... |
def createNew(cls, store, pathSegments):
"""
Create a new SubStore, allocating a new file space for it.
"""
if isinstance(pathSegments, basestring):
raise ValueError(
'Received %r instead of a sequence' % (pathSegments,))
if store.dbdir is None:
... |
def createStore(self, debug, journalMode=None):
"""
Create the actual Store this Substore represents.
"""
if self.storepath is None:
self.store._memorySubstores.append(self) # don't fall out of cache
if self.store.filesdir is None:
filesdir = None
... |
def upgradeCatalog1to2(oldCatalog):
"""
Create _TagName instances which version 2 of Catalog automatically creates
for use in determining the tagNames result, but which version 1 of Catalog
did not create.
"""
newCatalog = oldCatalog.upgradeVersion('tag_catalog', 1, 2,
... |
def tagNames(self):
"""
Return an iterator of unicode strings - the unique tag names which have
been applied objects in this catalog.
"""
return self.store.query(_TagName, _TagName.catalog == self).getColumn("name") |
def tagsOf(self, obj):
"""
Return an iterator of unicode strings - the tag names which apply to
the given object.
"""
return self.store.query(
Tag,
AND(Tag.catalog == self,
Tag.object == obj)).getColumn("name") |
def loaded(self, oself, dbval):
"""
This method is invoked when the item is loaded from the database, and
when a transaction is reverted which restores this attribute's value.
@param oself: an instance of an item which has this attribute.
@param dbval: the underlying database v... |
def _convertPyval(self, oself, pyval):
"""
Convert a Python value to a value suitable for inserting into the
database.
@param oself: The object on which this descriptor is an attribute.
@param pyval: The value to be converted.
@return: A value legal for this column in th... |
def _queryContainer(self, store):
"""
Generate and cache the subselect SQL and its arguments. Return the
subselect SQL.
"""
if self._subselectSQL is None:
sql, args = self.container._sqlAndArgs('SELECT',
self.contain... |
def _sequenceContainer(self, store):
"""
Smash whatever we got into a list and save the result in case we are
executed multiple times. This keeps us from tripping up over
generators and the like.
"""
if self._sequence is None:
self._sequence = list(self.conta... |
def _sequenceArgs(self, store):
"""
Filter each element of the data using the attribute type being
tested for containment and hand back the resulting list.
"""
self._sequenceContainer(store) # Force _sequence to be valid
return [self.attribute.infilter(pyval, None, store)... |
def prepareInsert(self, oself, store):
"""
Prepare for insertion into the database by making the dbunderlying
attribute of the item a relative pathname with respect to the store
rather than an absolute pathname.
"""
if self.relative:
fspath = self.__get__(osel... |
def restore(self, time=None):
"""
Undeletes the object. Returns True if undeleted, False if it was already not deleted
"""
if self.deleted:
time = time if time else self.deleted_at
if time == self.deleted_at:
self.deleted = False
se... |
def full_restore(self, using=None):
using = using or router.db_for_write(self.__class__, instance=self)
restore_counter = Counter()
if self.deleted:
time = self.deleted_at
else:
return restore_counter
self.collector = models.deletion.Collector(using=using)... |
def connect_to_ec2(region='us-east-1', access_key=None, secret_key=None):
""" Connect to AWS ec2
:type region: str
:param region: AWS region to connect to
:type access_key: str
:param access_key: AWS access key id
:type secret_key: str
:param secret_key: AWS secret access key
:returns: ... |
def parse(self, output):
"""
Find stems for a given text.
"""
output = self._get_lines_with_stems(output)
words = self._make_unique(output)
return self._parse_for_simple_stems(words) |
def validlocations(configuration=None):
# type: () -> List[Dict]
"""
Read valid locations from HDX
Args:
configuration (Optional[Configuration]): HDX configuration. Defaults to global configuration.
Returns:
List[Dict]: A list of valid locations
... |
def get_location_from_HDX_code(code, locations=None, configuration=None):
# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]
"""Get location from HDX location code
Args:
code (str): code for which to get location name
locations (Optional[List[D... |
def get_HDX_code_from_location(location, locations=None, configuration=None):
# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Optional[str]
"""Get HDX code for location
Args:
location (str): Location for which to get HDX code
locations (Optional[List[Dict... |
def get_HDX_code_from_location_partial(location, locations=None, configuration=None):
# type: (str, Optional[List[Dict]], Optional[Configuration]) -> Tuple[Optional[str], bool]
"""Get HDX code for location
Args:
location (str): Location for which to get HDX code
location... |
def Main():
"""The main program function.
Returns:
bool: True if successful or False if not.
"""
argument_parser = argparse.ArgumentParser(
description='Validates dtFabric format definitions.')
argument_parser.add_argument(
'source', nargs='?', action='store', metavar='PATH', default=None,
... |
def CheckDirectory(self, path, extension='yaml'):
"""Validates definition files in a directory.
Args:
path (str): path of the definition file.
extension (Optional[str]): extension of the filenames to read.
Returns:
bool: True if the directory contains valid definitions.
"""
resul... |
def CheckFile(self, path):
"""Validates the definition in a file.
Args:
path (str): path of the definition file.
Returns:
bool: True if the file contains valid definitions.
"""
print('Checking: {0:s}'.format(path))
definitions_registry = registry.DataTypeDefinitionsRegistry()
... |
def styleattribute(self, element):
"""
returns css.CSSStyleDeclaration of inline styles, for html: @style
"""
css_text = element.get('style')
if css_text:
return cssutils.css.CSSStyleDeclaration(cssText=css_text)
else:
return None |
def get_configuration(filename):
""" Read configuration file
:type filename: str
:param filename: Path to the configuration file
"""
logger.debug('Reading configuration from {}'.format(filename))
conf = SafeConfigParser()
conf.read(filename)
if not conf:
logger.error('Configura... |
def inline_css(html_message, encoding='unicode'):
"""
Inlines all CSS in an HTML string
Given an HTML document with CSS declared in the HEAD, inlines it into the
applicable elements. Used primarily in the preparation of styled emails.
Arguments:
html_message -- a string of HTML, including ... |
def _CheckByteStreamSize(self, byte_stream, byte_offset, data_type_size):
"""Checks if the byte stream is large enough for the data type.
Args:
byte_stream (bytes): byte stream.
byte_offset (int): offset into the byte stream where to start.
data_type_size (int): data type size.
Raises:
... |
def _GetByteStreamOperation(self):
"""Retrieves the byte stream operation.
Returns:
ByteStreamOperation: byte stream operation or None if unable to determine.
"""
byte_order_string = self.GetStructByteOrderString()
format_string = self.GetStructFormatString() # pylint: disable=assignment-fro... |
def GetStructByteOrderString(self):
"""Retrieves the Python struct format string.
Returns:
str: format string as used by Python struct or None if format string
cannot be determined.
"""
if not self._data_type_definition:
return None
return self._BYTE_ORDER_STRINGS.get(
... |
def FoldByteStream(self, mapped_value, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream.
"""
... |
def MapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps the data type on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContext]): data type... |
def FoldValue(self, value):
"""Folds the data type into a value.
Args:
value (object): value.
Returns:
object: folded value.
Raises:
ValueError: if the data type definition cannot be folded into the value.
"""
if value is False and self._data_type_definition.false_value is n... |
def GetStructFormatString(self):
"""Retrieves the Python struct format string.
Returns:
str: format string as used by Python struct or None if format string
cannot be determined.
"""
if self._data_type_definition.format == definitions.FORMAT_UNSIGNED:
return self._FORMAT_STRINGS_U... |
def FoldByteStream(self, mapped_value, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream.
"""
... |
def MapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps the data type on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContext]): data type... |
def _CalculateElementsDataSize(self, context):
"""Calculates the elements data size.
Args:
context (Optional[DataTypeMapContext]): data type map context, used to
determine the size hint.
Returns:
int: the elements data size or None if not available.
"""
elements_data_size = N... |
def _EvaluateElementsDataSize(self, context):
"""Evaluates elements data size.
Args:
context (DataTypeMapContext): data type map context.
Returns:
int: elements data size.
Raises:
MappingError: if the elements data size cannot be determined.
"""
elements_data_size = None
... |
def _EvaluateNumberOfElements(self, context):
"""Evaluates number of elements.
Args:
context (DataTypeMapContext): data type map context.
Returns:
int: number of elements.
Raises:
MappingError: if the number of elements cannot be determined.
"""
number_of_elements = None
... |
def _GetElementDataTypeDefinition(self, data_type_definition):
"""Retrieves the element data type definition.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
DataTypeDefinition: element data type definition.
Raises:
FormatError: if the element data ty... |
def GetSizeHint(self, context=None, **unused_kwargs):
"""Retrieves a hint about the size.
Args:
context (Optional[DataTypeMapContext]): data type map context, used to
determine the size hint.
Returns:
int: hint of the number of bytes needed from the byte stream or None.
"""
c... |
def _CompositeMapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps a sequence of composite data types on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[... |
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream.
"... |
def _LinearMapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps a data type sequence on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContex... |
def GetStructFormatString(self):
"""Retrieves the Python struct format string.
Returns:
str: format string as used by Python struct or None if format string
cannot be determined.
"""
if not self._element_data_type_map:
return None
number_of_elements = None
if self._data_t... |
def FoldByteStream(self, mapped_value, context=None, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
context (Optional[DataTypeMapContext]): data type map context.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the... |
def MapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps the data type on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContext]): data type... |
def MapByteStream(self, byte_stream, byte_offset=0, **unused_kwargs):
"""Maps the data type on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
Returns:
object: mapped value.
Raises:
MappingError: i... |
def FoldByteStream(self, mapped_value, **kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream.
"""
try:
... |
def MapByteStream(self, byte_stream, byte_offset=0, **kwargs):
"""Maps the data type on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
Returns:
str: mapped values.
Raises:
MappingError: if the dat... |
def _CheckCompositeMap(self, data_type_definition):
"""Determines if the data type definition needs a composite map.
Args:
data_type_definition (DataTypeDefinition): structure data type definition.
Returns:
bool: True if a composite map is needed, False otherwise.
Raises:
FormatErro... |
def _CompositeFoldByteStream(
self, mapped_value, context=None, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
context (Optional[DataTypeMapContext]): data type map context.
Returns:
bytes: byte stream.
Raises:
Fol... |
def _CompositeMapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps a sequence of composite data types on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[... |
def _GetAttributeNames(self, data_type_definition):
"""Determines the attribute (or field) names of the members.
Args:
data_type_definition (DataTypeDefinition): data type definition.
Returns:
list[str]: attribute names.
Raises:
FormatError: if the attribute names cannot be determin... |
def _GetMemberDataTypeMaps(self, data_type_definition, data_type_map_cache):
"""Retrieves the member data type maps.
Args:
data_type_definition (DataTypeDefinition): data type definition.
data_type_map_cache (dict[str, DataTypeMap]): cached data type maps.
Returns:
list[DataTypeMap]: mem... |
def _LinearFoldByteStream(self, mapped_value, **unused_kwargs):
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded into
the byte stream.
"... |
def _LinearMapByteStream(
self, byte_stream, byte_offset=0, context=None, **unused_kwargs):
"""Maps a data type sequence on a byte stream.
Args:
byte_stream (bytes): byte stream.
byte_offset (Optional[int]): offset into the byte stream where to start.
context (Optional[DataTypeMapContex... |
def GetSizeHint(self, context=None, **unused_kwargs):
"""Retrieves a hint about the size.
Args:
context (Optional[DataTypeMapContext]): data type map context, used to
determine the size hint.
Returns:
int: hint of the number of bytes needed from the byte stream or None.
"""
c... |
def GetStructFormatString(self):
"""Retrieves the Python struct format string.
Returns:
str: format string as used by Python struct or None if format string
cannot be determined.
"""
if self._format_string is None and self._data_type_maps:
format_strings = []
for member_data... |
def FoldByteStream(self, mapped_value, **unused_kwargs): # pylint: disable=redundant-returns-doc
"""Folds the data type into a byte stream.
Args:
mapped_value (object): mapped value.
Returns:
bytes: byte stream.
Raises:
FoldingError: if the data type definition cannot be folded int... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.