INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Parses a text representation of a protocol message into a message. | def Parse(text,
message,
allow_unknown_extension=False,
allow_field_number=False,
descriptor_pool=None):
"""Parses a text representation of a protocol message into a message.
Args:
text: Message text representation.
message: A protocol buffer message to merge into.
... |
Skips over contents ( value or message ) of a field. | def _SkipFieldContents(tokenizer):
"""Skips over contents (value or message) of a field.
Args:
tokenizer: A tokenizer to parse the field name and values.
"""
# Try to guess the type of this field.
# If this field is not a message, there should be a ":" between the
# field name and the field value and a... |
Skips over a complete field ( name and value/ message ). | def _SkipField(tokenizer):
"""Skips over a complete field (name and value/message).
Args:
tokenizer: A tokenizer to parse the field name and values.
"""
if tokenizer.TryConsume('['):
# Consume extension name.
tokenizer.ConsumeIdentifier()
while tokenizer.TryConsume('.'):
tokenizer.Consume... |
Skips over a field message. | def _SkipFieldMessage(tokenizer):
"""Skips over a field message.
Args:
tokenizer: A tokenizer to parse the field name and values.
"""
if tokenizer.TryConsume('<'):
delimiter = '>'
else:
tokenizer.Consume('{')
delimiter = '}'
while not tokenizer.LookingAt('>') and not tokenizer.LookingAt('... |
Skips over a field value. | def _SkipFieldValue(tokenizer):
"""Skips over a field value.
Args:
tokenizer: A tokenizer to parse the field name and values.
Raises:
ParseError: In case an invalid field value is found.
"""
# String/bytes tokens can come in multiple adjacent string literals.
# If we can consume one, consume as ma... |
Consumes an integer number from tokenizer. | def _ConsumeInteger(tokenizer, is_signed=False, is_long=False):
"""Consumes an integer number from tokenizer.
Args:
tokenizer: A tokenizer used to parse the number.
is_signed: True if a signed integer must be parsed.
is_long: True if a long integer must be parsed.
Returns:
The integer parsed.
... |
Parses an integer. | def ParseInteger(text, is_signed=False, is_long=False):
"""Parses an integer.
Args:
text: The text to parse.
is_signed: True if a signed integer must be parsed.
is_long: True if a long integer must be parsed.
Returns:
The integer value.
Raises:
ValueError: Thrown Iff the text is not a val... |
Parses an integer without checking size/ signedness. | def _ParseAbstractInteger(text, is_long=False):
"""Parses an integer without checking size/signedness.
Args:
text: The text to parse.
is_long: True if the value should be returned as a long integer.
Returns:
The integer value.
Raises:
ValueError: Thrown Iff the text is not a valid integer.
... |
Parse a floating point number. | def ParseFloat(text):
"""Parse a floating point number.
Args:
text: Text to parse.
Returns:
The number parsed.
Raises:
ValueError: If a floating point number couldn't be parsed.
"""
try:
# Assume Python compatible syntax.
return float(text)
except ValueError:
# Check alternative... |
Parse an enum value. | def ParseEnum(field, value):
"""Parse an enum value.
The value can be specified by a number (the enum value), or by
a string literal (the enum name).
Args:
field: Enum field descriptor.
value: String value.
Returns:
Enum value number.
Raises:
ValueError: If the enum value could not be pa... |
Serializes if message is a google. protobuf. Any field. | def _TryPrintAsAnyMessage(self, message):
"""Serializes if message is a google.protobuf.Any field."""
packed_message = _BuildMessageFromTypeName(message.TypeName(),
self.descriptor_pool)
if packed_message:
packed_message.MergeFromString(message.value)
... |
Convert protobuf message to text format. | def PrintMessage(self, message):
"""Convert protobuf message to text format.
Args:
message: The protocol buffers message.
"""
if (message.DESCRIPTOR.full_name == _ANY_FULL_TYPE_NAME and
self.descriptor_pool and self._TryPrintAsAnyMessage(message)):
return
fields = message.ListFi... |
Print a single field name/ value pair. | def PrintField(self, field, value):
"""Print a single field name/value pair."""
out = self.out
out.write(' ' * self.indent)
if self.use_field_number:
out.write(str(field.number))
else:
if field.is_extension:
out.write('[')
if (field.containing_type.GetOptions().message_se... |
Parses a text representation of a protocol message into a message. | def ParseFromString(self, text, message):
"""Parses a text representation of a protocol message into a message."""
if not isinstance(text, str):
text = text.decode('utf-8')
return self.ParseLines(text.split('\n'), message) |
Parses a text representation of a protocol message into a message. | def ParseLines(self, lines, message):
"""Parses a text representation of a protocol message into a message."""
self._allow_multiple_scalars = False
self._ParseOrMerge(lines, message)
return message |
Merges a text representation of a protocol message into a message. | def MergeLines(self, lines, message):
"""Merges a text representation of a protocol message into a message."""
self._allow_multiple_scalars = True
self._ParseOrMerge(lines, message)
return message |
Converts a text representation of a protocol message into a message. | def _ParseOrMerge(self, lines, message):
"""Converts a text representation of a protocol message into a message.
Args:
lines: Lines of a message's text representation.
message: A protocol buffer message to merge into.
Raises:
ParseError: On text parsing problems.
"""
tokenizer = ... |
Merges a single protocol message field into a message. | def _MergeField(self, tokenizer, message):
"""Merges a single protocol message field into a message.
Args:
tokenizer: A tokenizer to parse the field name and values.
message: A protocol message to record the data.
Raises:
ParseError: In case of text parsing problems.
"""
message_... |
Consumes a google. protobuf. Any type URL and returns the type name. | def _ConsumeAnyTypeUrl(self, tokenizer):
"""Consumes a google.protobuf.Any type URL and returns the type name."""
# Consume "type.googleapis.com/".
tokenizer.ConsumeIdentifier()
tokenizer.Consume('.')
tokenizer.ConsumeIdentifier()
tokenizer.Consume('.')
tokenizer.ConsumeIdentifier()
toke... |
Merges a single scalar field into a message. | def _MergeMessageField(self, tokenizer, message, field):
"""Merges a single scalar field into a message.
Args:
tokenizer: A tokenizer to parse the field value.
message: The message of which field is a member.
field: The descriptor of the field to be merged.
Raises:
ParseError: In c... |
Merges a single scalar field into a message. | def _MergeScalarField(self, tokenizer, message, field):
"""Merges a single scalar field into a message.
Args:
tokenizer: A tokenizer to parse the field value.
message: A protocol message to record the data.
field: The descriptor of the field to be merged.
Raises:
ParseError: In cas... |
Tries to consume a given piece of text. | def TryConsume(self, token):
"""Tries to consume a given piece of text.
Args:
token: Text to consume.
Returns:
True iff the text was consumed.
"""
if self.token == token:
self.NextToken()
return True
return False |
Consumes a comment returns a 2 - tuple ( trailing bool comment str ). | def ConsumeCommentOrTrailingComment(self):
"""Consumes a comment, returns a 2-tuple (trailing bool, comment str)."""
# Tokenizer initializes _previous_line and _previous_column to 0. As the
# tokenizer starts, it looks like there is a previous token on the line.
just_started = self._line == 0 and self.... |
Consumes protocol message field identifier. | def ConsumeIdentifier(self):
"""Consumes protocol message field identifier.
Returns:
Identifier string.
Raises:
ParseError: If an identifier couldn't be consumed.
"""
result = self.token
if not self._IDENTIFIER.match(result):
raise self.ParseError('Expected identifier.')
... |
Consumes protocol message field identifier. | def ConsumeIdentifierOrNumber(self):
"""Consumes protocol message field identifier.
Returns:
Identifier string.
Raises:
ParseError: If an identifier couldn't be consumed.
"""
result = self.token
if not self._IDENTIFIER_OR_NUMBER.match(result):
raise self.ParseError('Expected ... |
Consumes an integer number. | def ConsumeInteger(self, is_long=False):
"""Consumes an integer number.
Args:
is_long: True if the value should be returned as a long integer.
Returns:
The integer parsed.
Raises:
ParseError: If an integer couldn't be consumed.
"""
try:
result = _ParseAbstractInteger(se... |
Consumes a string value. | def ConsumeString(self):
"""Consumes a string value.
Returns:
The string parsed.
Raises:
ParseError: If a string value couldn't be consumed.
"""
the_bytes = self.ConsumeByteString()
try:
return six.text_type(the_bytes, 'utf-8')
except UnicodeDecodeError as e:
raise ... |
Consumes a byte array value. | def ConsumeByteString(self):
"""Consumes a byte array value.
Returns:
The array parsed (as a string).
Raises:
ParseError: If a byte array value couldn't be consumed.
"""
the_list = [self._ConsumeSingleByteString()]
while self.token and self.token[0] in _QUOTES:
the_list.appen... |
Reads the next meaningful token. | def NextToken(self):
"""Reads the next meaningful token."""
self._previous_line = self._line
self._previous_column = self._column
self._column += len(self.token)
self._SkipWhitespace()
if not self._more_lines:
self.token = ''
return
match = self._TOKEN.match(self._current_line... |
Create a: class: ~turicreate. decision_tree_regression. DecisionTreeRegression to predict a scalar target variable using one or more features. In addition to standard numeric and categorical types features can also be extracted automatically from list - or dictionary - type SFrame columns. | def create(dataset, target,
features=None,
validation_set='auto',
max_depth=6,
min_loss_reduction=0.0, min_child_weight=0.1,
verbose=True,
random_seed = None,
metric = 'auto',
**kwargs):
"""
Create a :class:`~turicreate.deci... |
Evaluate the model on the given dataset. | def evaluate(self, dataset, metric='auto', missing_value_action='auto'):
"""
Evaluate the model on the given dataset.
Parameters
----------
dataset : SFrame
Dataset in the same format used for training. The columns names and
types of the dataset must be t... |
Predict the target column of the given dataset. | def predict(self, dataset, missing_value_action='auto'):
"""
Predict the target column of the given dataset.
The target column is provided during
:func:`~turicreate.decision_tree_regression.create`. If the target column is in the
`dataset` it will be ignored.
Parameters... |
Compute the value of a composite distance function on two dictionaries typically SFrame rows. | def compute_composite_distance(distance, x, y):
"""
Compute the value of a composite distance function on two dictionaries,
typically SFrame rows.
Parameters
----------
distance : list[list]
A composite distance function. Composite distance functions are a
weighted sum of standa... |
Check that composite distance function is in valid form. Don t modify the composite distance in any way. | def _validate_composite_distance(distance):
"""
Check that composite distance function is in valid form. Don't modify the
composite distance in any way.
"""
if not isinstance(distance, list):
raise TypeError("Input 'distance' must be a composite distance.")
if len(distance) < 1:
... |
Remove feature names from the feature lists in a composite distance function. | def _scrub_composite_distance_features(distance, feature_blacklist):
"""
Remove feature names from the feature lists in a composite distance
function.
"""
dist_out = []
for i, d in enumerate(distance):
ftrs, dist, weight = d
new_ftrs = [x for x in ftrs if x not in feature_blackl... |
Convert function names in a composite distance function into function handles. | def _convert_distance_names_to_functions(distance):
"""
Convert function names in a composite distance function into function
handles.
"""
dist_out = _copy.deepcopy(distance)
for i, d in enumerate(distance):
_, dist, _ = d
if isinstance(dist, str):
try:
... |
Construct a composite distance appropriate for matching address data. NOTE: this utility function does not guarantee that the output composite distance will work with a particular dataset and model. When the composite distance is applied in a particular context the feature types and individual distance functions must b... | def build_address_distance(number=None, street=None, city=None, state=None,
zip_code=None):
"""
Construct a composite distance appropriate for matching address data. NOTE:
this utility function does not guarantee that the output composite distance
will work with a particular d... |
Builds a dictionary of all the messages available in a set of files. | def GetMessages(file_protos):
"""Builds a dictionary of all the messages available in a set of files.
Args:
file_protos: A sequence of file protos to build messages out of.
Returns:
A dictionary mapping proto names to the message classes. This will include
any dependent messages as well as any messa... |
Builds a proto2 message class based on the passed in descriptor. | def GetPrototype(self, descriptor):
"""Builds a proto2 message class based on the passed in descriptor.
Passing a descriptor with a fully qualified name matching a previous
invocation will cause the same class to be returned.
Args:
descriptor: The descriptor to build from.
Returns:
A ... |
Gets all the messages from a specified file. | def GetMessages(self, files):
"""Gets all the messages from a specified file.
This will find and resolve dependencies, failing if the descriptor
pool cannot satisfy them.
Args:
files: The file names to extract messages from.
Returns:
A dictionary mapping proto names to the message cla... |
for if statements in list comprehension | def refactor_ifs(stmnt, ifs):
'''
for if statements in list comprehension
'''
if isinstance(stmnt, _ast.BoolOp):
test, right = stmnt.values
if isinstance(stmnt.op, _ast.Or):
test = _ast.UnaryOp(op=_ast.Not(), operand=test, lineno=0, col_offset=0)
ifs.append(test)
... |
NOP | def MAP_ADD(self, instr):
key = self.ast_stack.pop()
value = self.ast_stack.pop()
self.ast_stack.append((key, value))
'NOP' |
Initializes an MpsGraphAPI for object detection. | def _get_mps_od_net(input_image_shape, batch_size, output_size, anchors,
config, weights={}):
"""
Initializes an MpsGraphAPI for object detection.
"""
network = _MpsGraphAPI(network_id=_MpsGraphNetworkType.kODGraphNet)
c_in, h_in, w_in = input_image_shape
c_out = output_siz... |
Create a: class: ObjectDetector model. | def create(dataset, annotations=None, feature=None, model='darknet-yolo',
classes=None, batch_size=0, max_iterations=0, verbose=True,
**kwargs):
"""
Create a :class:`ObjectDetector` model.
Parameters
----------
dataset : SFrame
Input data. The columns named by the ``fe... |
Predict with options for what kind of SFrame should be returned. | def _predict_with_options(self, dataset, with_ground_truth,
postprocess=True, confidence_threshold=0.001,
iou_threshold=None,
verbose=True):
"""
Predict with options for what kind of SFrame should be returned.
... |
Takes input and returns tuple of the input in canonical form ( SFrame ) along with an unpack callback function that can be applied to prediction results to undo the canonization. | def _canonize_input(self, dataset):
"""
Takes input and returns tuple of the input in canonical form (SFrame)
along with an unpack callback function that can be applied to
prediction results to "undo" the canonization.
"""
unpack = lambda x: x
if isinstance(datase... |
Predict object instances in an sframe of images. | def predict(self, dataset, confidence_threshold=0.25, iou_threshold=None, verbose=True):
"""
Predict object instances in an sframe of images.
Parameters
----------
dataset : SFrame | SArray | turicreate.Image
The images on which to perform object detection.
... |
Evaluate the model by making predictions and comparing these to ground truth bounding box annotations. | def evaluate(self, dataset, metric='auto',
output_type='dict', iou_threshold=None,
confidence_threshold=None, verbose=True):
"""
Evaluate the model by making predictions and comparing these to ground
truth bounding box annotations.
Parameters
----------
... |
Save the model in Core ML format. The Core ML model takes an image of fixed size as input and produces two output arrays: confidence and coordinates. | def export_coreml(self, filename,
include_non_maximum_suppression = True,
iou_threshold = None,
confidence_threshold = None):
"""
Save the model in Core ML format. The Core ML model takes an image of
fixed size as input and produces two output arrays: `confid... |
Parse a document title as the first line starting in [ A - Za - z0 - 9< ] or fall back to the document basename if no such line exists. The cmake -- help - * - list commands also depend on this convention. Return the title or False if the document file does not exist. | def parse_title(self, docname):
"""Parse a document title as the first line starting in [A-Za-z0-9<]
or fall back to the document basename if no such line exists.
The cmake --help-*-list commands also depend on this convention.
Return the title or False if the document file does... |
Register a Python written function to for error reporting. The function is called back as f ( ctx error ). | def registerErrorHandler(f, ctx):
"""Register a Python written function to for error reporting.
The function is called back as f(ctx, error). """
import sys
if 'libxslt' not in sys.modules:
# normal behaviour when libxslt is not imported
ret = libxml2mod.xmlRegisterErrorHandler(f,ctx)... |
Intermediate callback to wrap the locator | def _xmlTextReaderErrorFunc(xxx_todo_changeme,msg,severity,locator):
"""Intermediate callback to wrap the locator"""
(f,arg) = xxx_todo_changeme
return f(arg,msg,severity,xmlTextReaderLocator(locator)) |
Create a parser context for an HTML in - memory document. | def htmlCreateMemoryParserCtxt(buffer, size):
"""Create a parser context for an HTML in-memory document. """
ret = libxml2mod.htmlCreateMemoryParserCtxt(buffer, size)
if ret is None:raise parserError('htmlCreateMemoryParserCtxt() failed')
return parserCtxt(_obj=ret) |
parse an HTML in - memory document and build a tree. | def htmlParseDoc(cur, encoding):
"""parse an HTML in-memory document and build a tree. """
ret = libxml2mod.htmlParseDoc(cur, encoding)
if ret is None:raise parserError('htmlParseDoc() failed')
return xmlDoc(_obj=ret) |
parse an HTML file and build a tree. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. | def htmlParseFile(filename, encoding):
"""parse an HTML file and build a tree. Automatic support for
ZLIB/Compress compressed document is provided by default if
found at compile-time. """
ret = libxml2mod.htmlParseFile(filename, encoding)
if ret is None:raise parserError('htmlParseFile() failed... |
parse an XML in - memory document and build a tree. | def htmlReadDoc(cur, URL, encoding, options):
"""parse an XML in-memory document and build a tree. """
ret = libxml2mod.htmlReadDoc(cur, URL, encoding, options)
if ret is None:raise treeError('htmlReadDoc() failed')
return xmlDoc(_obj=ret) |
parse an XML from a file descriptor and build a tree. | def htmlReadFd(fd, URL, encoding, options):
"""parse an XML from a file descriptor and build a tree. """
ret = libxml2mod.htmlReadFd(fd, URL, encoding, options)
if ret is None:raise treeError('htmlReadFd() failed')
return xmlDoc(_obj=ret) |
parse an XML file from the filesystem or the network. | def htmlReadFile(filename, encoding, options):
"""parse an XML file from the filesystem or the network. """
ret = libxml2mod.htmlReadFile(filename, encoding, options)
if ret is None:raise treeError('htmlReadFile() failed')
return xmlDoc(_obj=ret) |
parse an XML in - memory document and build a tree. | def htmlReadMemory(buffer, size, URL, encoding, options):
"""parse an XML in-memory document and build a tree. """
ret = libxml2mod.htmlReadMemory(buffer, size, URL, encoding, options)
if ret is None:raise treeError('htmlReadMemory() failed')
return xmlDoc(_obj=ret) |
Creates a new HTML document | def htmlNewDoc(URI, ExternalID):
"""Creates a new HTML document """
ret = libxml2mod.htmlNewDoc(URI, ExternalID)
if ret is None:raise treeError('htmlNewDoc() failed')
return xmlDoc(_obj=ret) |
Creates a new HTML document without a DTD node if | def htmlNewDocNoDtD(URI, ExternalID):
"""Creates a new HTML document without a DTD node if @URI and
@ExternalID are None """
ret = libxml2mod.htmlNewDocNoDtD(URI, ExternalID)
if ret is None:raise treeError('htmlNewDocNoDtD() failed')
return xmlDoc(_obj=ret) |
Add an entry in the catalog it may overwrite existing but different entries. If called before any other catalog routine allows to override the default shared catalog put in place by xmlInitializeCatalog () ; | def catalogAdd(type, orig, replace):
"""Add an entry in the catalog, it may overwrite existing but
different entries. If called before any other catalog
routine, allows to override the default shared catalog put
in place by xmlInitializeCatalog(); """
ret = libxml2mod.xmlCatalogAdd(type, orig... |
Load the catalog and build the associated data structures. This can be either an XML Catalog or an SGML Catalog It will recurse in SGML CATALOG entries. On the other hand XML Catalogs are not handled recursively. | def loadACatalog(filename):
"""Load the catalog and build the associated data structures.
This can be either an XML Catalog or an SGML Catalog It
will recurse in SGML CATALOG entries. On the other hand XML
Catalogs are not handled recursively. """
ret = libxml2mod.xmlLoadACatalog(filename)
... |
Load an SGML super catalog. It won t expand CATALOG or DELEGATE references. This is only needed for manipulating SGML Super Catalogs like adding and removing CATALOG or DELEGATE entries. | def loadSGMLSuperCatalog(filename):
"""Load an SGML super catalog. It won't expand CATALOG or
DELEGATE references. This is only needed for manipulating
SGML Super Catalogs like adding and removing CATALOG or
DELEGATE entries. """
ret = libxml2mod.xmlLoadSGMLSuperCatalog(filename)
if ret i... |
create a new Catalog. | def newCatalog(sgml):
"""create a new Catalog. """
ret = libxml2mod.xmlNewCatalog(sgml)
if ret is None:raise treeError('xmlNewCatalog() failed')
return catalog(_obj=ret) |
parse an XML file and build a tree. It s like xmlParseFile () except it bypass all catalog lookups. | def parseCatalogFile(filename):
"""parse an XML file and build a tree. It's like
xmlParseFile() except it bypass all catalog lookups. """
ret = libxml2mod.xmlParseCatalogFile(filename)
if ret is None:raise parserError('xmlParseCatalogFile() failed')
return xmlDoc(_obj=ret) |
Dumps informations about the string shorten it if necessary | def debugDumpString(output, str):
"""Dumps informations about the string, shorten it if necessary """
if output is not None: output.flush()
libxml2mod.xmlDebugDumpString(output, str) |
Check whether this name is an predefined entity. | def predefinedEntity(name):
"""Check whether this name is an predefined entity. """
ret = libxml2mod.xmlGetPredefinedEntity(name)
if ret is None:raise treeError('xmlGetPredefinedEntity() failed')
return xmlEntity(_obj=ret) |
Setup the FTP proxy informations. This can also be done by using ftp_proxy ftp_proxy_user and ftp_proxy_password environment variables. | def nanoFTPProxy(host, port, user, passwd, type):
"""Setup the FTP proxy informations. This can also be done by
using ftp_proxy ftp_proxy_user and ftp_proxy_password
environment variables. """
libxml2mod.xmlNanoFTPProxy(host, port, user, passwd, type) |
Creates a parser context for an XML in - memory document. | def createDocParserCtxt(cur):
"""Creates a parser context for an XML in-memory document. """
ret = libxml2mod.xmlCreateDocParserCtxt(cur)
if ret is None:raise parserError('xmlCreateDocParserCtxt() failed')
return parserCtxt(_obj=ret) |
Load and parse an external subset. | def parseDTD(ExternalID, SystemID):
"""Load and parse an external subset. """
ret = libxml2mod.xmlParseDTD(ExternalID, SystemID)
if ret is None:raise parserError('xmlParseDTD() failed')
return xmlDtd(_obj=ret) |
parse an XML in - memory document and build a tree. | def parseDoc(cur):
"""parse an XML in-memory document and build a tree. """
ret = libxml2mod.xmlParseDoc(cur)
if ret is None:raise parserError('xmlParseDoc() failed')
return xmlDoc(_obj=ret) |
parse an XML external entity out of context and build a tree. [ 78 ] extParsedEnt:: = TextDecl? content This correspond to a Well Balanced chunk | def parseEntity(filename):
"""parse an XML external entity out of context and build a
tree. [78] extParsedEnt ::= TextDecl? content This
correspond to a "Well Balanced" chunk """
ret = libxml2mod.xmlParseEntity(filename)
if ret is None:raise parserError('xmlParseEntity() failed')
return x... |
parse an XML file and build a tree. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. | def parseFile(filename):
"""parse an XML file and build a tree. Automatic support for
ZLIB/Compress compressed document is provided by default if
found at compile-time. """
ret = libxml2mod.xmlParseFile(filename)
if ret is None:raise parserError('xmlParseFile() failed')
return xmlDoc(_obj=r... |
parse an XML in - memory block and build a tree. | def parseMemory(buffer, size):
"""parse an XML in-memory block and build a tree. """
ret = libxml2mod.xmlParseMemory(buffer, size)
if ret is None:raise parserError('xmlParseMemory() failed')
return xmlDoc(_obj=ret) |
parse an XML in - memory document and build a tree. | def readDoc(cur, URL, encoding, options):
"""parse an XML in-memory document and build a tree. """
ret = libxml2mod.xmlReadDoc(cur, URL, encoding, options)
if ret is None:raise treeError('xmlReadDoc() failed')
return xmlDoc(_obj=ret) |
parse an XML from a file descriptor and build a tree. NOTE that the file descriptor will not be closed when the reader is closed or reset. | def readFd(fd, URL, encoding, options):
"""parse an XML from a file descriptor and build a tree. NOTE
that the file descriptor will not be closed when the reader
is closed or reset. """
ret = libxml2mod.xmlReadFd(fd, URL, encoding, options)
if ret is None:raise treeError('xmlReadFd() failed')
... |
parse an XML file from the filesystem or the network. | def readFile(filename, encoding, options):
"""parse an XML file from the filesystem or the network. """
ret = libxml2mod.xmlReadFile(filename, encoding, options)
if ret is None:raise treeError('xmlReadFile() failed')
return xmlDoc(_obj=ret) |
parse an XML in - memory document and build a tree. | def readMemory(buffer, size, URL, encoding, options):
"""parse an XML in-memory document and build a tree. """
ret = libxml2mod.xmlReadMemory(buffer, size, URL, encoding, options)
if ret is None:raise treeError('xmlReadMemory() failed')
return xmlDoc(_obj=ret) |
parse an XML in - memory document and build a tree. In the case the document is not Well Formed a attempt to build a tree is tried anyway | def recoverDoc(cur):
"""parse an XML in-memory document and build a tree. In the
case the document is not Well Formed, a attempt to build a
tree is tried anyway """
ret = libxml2mod.xmlRecoverDoc(cur)
if ret is None:raise treeError('xmlRecoverDoc() failed')
return xmlDoc(_obj=ret) |
parse an XML file and build a tree. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. In the case the document is not Well Formed it attempts to build a tree anyway | def recoverFile(filename):
"""parse an XML file and build a tree. Automatic support for
ZLIB/Compress compressed document is provided by default if
found at compile-time. In the case the document is not Well
Formed, it attempts to build a tree anyway """
ret = libxml2mod.xmlRecoverFile(filena... |
parse an XML in - memory block and build a tree. In the case the document is not Well Formed an attempt to build a tree is tried anyway | def recoverMemory(buffer, size):
"""parse an XML in-memory block and build a tree. In the case
the document is not Well Formed, an attempt to build a tree
is tried anyway """
ret = libxml2mod.xmlRecoverMemory(buffer, size)
if ret is None:raise treeError('xmlRecoverMemory() failed')
return x... |
append the char value in the array | def copyChar(len, out, val):
"""append the char value in the array """
ret = libxml2mod.xmlCopyChar(len, out, val)
return ret |
Create a parser context for an external entity Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. | def createEntityParserCtxt(URL, ID, base):
"""Create a parser context for an external entity Automatic
support for ZLIB/Compress compressed document is provided
by default if found at compile-time. """
ret = libxml2mod.xmlCreateEntityParserCtxt(URL, ID, base)
if ret is None:raise parserError('x... |
Create a parser context for a file content. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. | def createFileParserCtxt(filename):
"""Create a parser context for a file content. Automatic
support for ZLIB/Compress compressed document is provided
by default if found at compile-time. """
ret = libxml2mod.xmlCreateFileParserCtxt(filename)
if ret is None:raise parserError('xmlCreateFileParse... |
Create a parser context for an XML in - memory document. | def createMemoryParserCtxt(buffer, size):
"""Create a parser context for an XML in-memory document. """
ret = libxml2mod.xmlCreateMemoryParserCtxt(buffer, size)
if ret is None:raise parserError('xmlCreateMemoryParserCtxt() failed')
return parserCtxt(_obj=ret) |
Create a parser context for a file or URL content. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time and for file accesses | def createURLParserCtxt(filename, options):
"""Create a parser context for a file or URL content.
Automatic support for ZLIB/Compress compressed document is
provided by default if found at compile-time and for file
accesses """
ret = libxml2mod.xmlCreateURLParserCtxt(filename, options)
if... |
Create a parser context for a file content. Automatic support for ZLIB/ Compress compressed document is provided by default if found at compile - time. | def htmlCreateFileParserCtxt(filename, encoding):
"""Create a parser context for a file content. Automatic
support for ZLIB/Compress compressed document is provided
by default if found at compile-time. """
ret = libxml2mod.htmlCreateFileParserCtxt(filename, encoding)
if ret is None:raise parser... |
Pops the top element name from the name stack | def namePop(ctxt):
"""Pops the top element name from the name stack """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.namePop(ctxt__o)
return ret |
Pushes a new element name on top of the name stack | def namePush(ctxt, value):
"""Pushes a new element name on top of the name stack """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.namePush(ctxt__o, value)
return ret |
Pops the top element node from the node stack | def nodePop(ctxt):
"""Pops the top element node from the node stack """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
ret = libxml2mod.nodePop(ctxt__o)
if ret is None:raise treeError('nodePop() failed')
return xmlNode(_obj=ret) |
Pushes a new element node on top of the node stack | def nodePush(ctxt, value):
"""Pushes a new element node on top of the node stack """
if ctxt is None: ctxt__o = None
else: ctxt__o = ctxt._o
if value is None: value__o = None
else: value__o = value._o
ret = libxml2mod.nodePush(ctxt__o, value__o)
return ret |
Create a libxml2 input buffer from a Python file | def createInputBuffer(file, encoding):
"""Create a libxml2 input buffer from a Python file """
ret = libxml2mod.xmlCreateInputBuffer(file, encoding)
if ret is None:raise treeError('xmlCreateInputBuffer() failed')
return inputBuffer(_obj=ret) |
Create a libxml2 output buffer from a Python file | def createOutputBuffer(file, encoding):
"""Create a libxml2 output buffer from a Python file """
ret = libxml2mod.xmlCreateOutputBuffer(file, encoding)
if ret is None:raise treeError('xmlCreateOutputBuffer() failed')
return outputBuffer(_obj=ret) |
Create a progressive XML parser context to build either an event flow if the SAX object is not None or a DOM tree otherwise. | def createPushParser(SAX, chunk, size, URI):
"""Create a progressive XML parser context to build either an
event flow if the SAX object is not None, or a DOM tree
otherwise. """
ret = libxml2mod.xmlCreatePushParser(SAX, chunk, size, URI)
if ret is None:raise parserError('xmlCreatePushParser() f... |
Create a progressive HTML parser context to build either an event flow if the SAX object is not None or a DOM tree otherwise. | def htmlCreatePushParser(SAX, chunk, size, URI):
"""Create a progressive HTML parser context to build either an
event flow if the SAX object is not None, or a DOM tree
otherwise. """
ret = libxml2mod.htmlCreatePushParser(SAX, chunk, size, URI)
if ret is None:raise parserError('htmlCreatePushPar... |
Create a new Node | def newNode(name):
"""Create a new Node """
ret = libxml2mod.xmlNewNode(name)
if ret is None:raise treeError('xmlNewNode() failed')
return xmlNode(_obj=ret) |
Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file. | def relaxNGNewMemParserCtxt(buffer, size):
"""Create an XML RelaxNGs parse context for that memory buffer
expected to contain an XML RelaxNGs file. """
ret = libxml2mod.xmlRelaxNGNewMemParserCtxt(buffer, size)
if ret is None:raise parserError('xmlRelaxNGNewMemParserCtxt() failed')
return relaxNgP... |
Create an XML RelaxNGs parse context for that file/ resource expected to contain an XML RelaxNGs file. | def relaxNGNewParserCtxt(URL):
"""Create an XML RelaxNGs parse context for that file/resource
expected to contain an XML RelaxNGs file. """
ret = libxml2mod.xmlRelaxNGNewParserCtxt(URL)
if ret is None:raise parserError('xmlRelaxNGNewParserCtxt() failed')
return relaxNgParserCtxt(_obj=ret) |
Builds the QName | def buildQName(ncname, prefix, memory, len):
"""Builds the QName @prefix:@ncname in @memory if there is
enough space and prefix is not None nor empty, otherwise
allocate a new string. If prefix is None or empty it
returns ncname. """
ret = libxml2mod.xmlBuildQName(ncname, prefix, memory, len)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.