index
int64 0
731k
| package
stringlengths 2
98
⌀ | name
stringlengths 1
76
| docstring
stringlengths 0
281k
⌀ | code
stringlengths 4
1.07M
⌀ | signature
stringlengths 2
42.8k
⌀ |
---|---|---|---|---|---|
62,478 |
plyfile
|
write
|
Write PLY data to a writeable file-like object or filename.
Parameters
----------
stream : str or writeable open file
Raises
------
ValueError
If `stream` is open in text mode and the file to be written
is binary-format.
|
def write(self, stream):
"""
Write PLY data to a writeable file-like object or filename.
Parameters
----------
stream : str or writeable open file
Raises
------
ValueError
If `stream` is open in text mode and the file to be written
is binary-format.
"""
(must_close, stream) = _open_stream(stream, 'write')
try:
try:
stream.write(b'')
binary_stream = True
except TypeError:
binary_stream = False
if binary_stream:
stream.write(self.header.encode('ascii'))
stream.write(b'\n')
else:
if not self.text:
raise ValueError("can't write binary-format PLY to "
"text stream")
stream.write(self.header)
stream.write('\n')
for elt in self:
elt._write(stream, self.text, self.byte_order)
finally:
if must_close:
stream.close()
|
(self, stream)
|
62,479 |
plyfile
|
PlyElement
|
PLY file element.
Creating a `PlyElement` instance is generally done in one of two
ways: as a byproduct of `PlyData.read` (when reading a PLY file) and
by `PlyElement.describe` (before writing a PLY file).
Attributes
----------
name : str
count : int
data : numpy.ndarray
properties : list of PlyProperty
comments : list of str
header : str
PLY header block for this element.
|
class PlyElement(object):
"""
PLY file element.
Creating a `PlyElement` instance is generally done in one of two
ways: as a byproduct of `PlyData.read` (when reading a PLY file) and
by `PlyElement.describe` (before writing a PLY file).
Attributes
----------
name : str
count : int
data : numpy.ndarray
properties : list of PlyProperty
comments : list of str
header : str
PLY header block for this element.
"""
def __init__(self, name, properties, count, comments=[]):
"""
This is not part of the public interface. The preferred methods
of obtaining `PlyElement` instances are `PlyData.read` (to read
from a file) and `PlyElement.describe` (to construct from a
`numpy` array).
Parameters
----------
name : str
properties : list of PlyProperty
count : str
comments : list of str
"""
_check_name(name)
self._name = str(name)
self._count = count
self._properties = tuple(properties)
self._index()
self.comments = comments
self._have_list = any(isinstance(p, PlyListProperty)
for p in self.properties)
@property
def count(self):
return self._count
def _get_data(self):
return self._data
def _set_data(self, data):
self._data = data
self._count = len(data)
self._check_sanity()
data = property(_get_data, _set_data)
def _check_sanity(self):
for prop in self.properties:
if prop.name not in self._data.dtype.fields:
raise ValueError("dangling property %r" % prop.name)
def _get_properties(self):
return self._properties
def _set_properties(self, properties):
self._properties = tuple(properties)
self._check_sanity()
self._index()
properties = property(_get_properties, _set_properties)
def _get_comments(self):
return list(self._comments)
def _set_comments(self, comments):
_check_comments(comments)
self._comments = list(comments)
comments = property(_get_comments, _set_comments)
def _index(self):
self._property_lookup = dict((prop.name, prop)
for prop in self._properties)
if len(self._property_lookup) != len(self._properties):
raise ValueError("two properties with same name")
def ply_property(self, name):
"""
Look up property by name.
Parameters
----------
name : str
Returns
-------
PlyProperty
Raises
------
KeyError
If the property can't be found.
"""
return self._property_lookup[name]
@property
def name(self):
return self._name
def dtype(self, byte_order='='):
"""
Return the `numpy.dtype` description of the in-memory
representation of the data. (If there are no list properties,
and the PLY format is binary, then this also accurately
describes the on-disk representation of the element.)
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
numpy.dtype
"""
return _np.dtype([(prop.name, prop.dtype(byte_order))
for prop in self.properties])
@staticmethod
def describe(data, name, len_types={}, val_types={},
comments=[]):
"""
Construct a `PlyElement` instance from an array's metadata.
Parameters
----------
data : numpy.ndarray
Structured `numpy` array.
len_types : dict, optional
Mapping from list property names to type strings
(`numpy`-style like `'u1'`, `'f4'`, etc., or PLY-style like
`'int8'`, `'float32'`, etc.), which will be used to encode
the length of the list in binary-format PLY files. Defaults
to `'u1'` (8-bit integer) for all list properties.
val_types : dict, optional
Mapping from list property names to type strings as for
`len_types`, but is used to encode the list elements in
binary-format PLY files. Defaults to `'i4'` (32-bit
integer) for all list properties.
comments : list of str
Comments between the "element" line and first property
definition in the header.
Returns
-------
PlyElement
Raises
------
TypeError, ValueError
"""
if not isinstance(data, _np.ndarray):
raise TypeError("only numpy arrays are supported")
if len(data.shape) != 1:
raise ValueError("only one-dimensional arrays are "
"supported")
count = len(data)
properties = []
descr = data.dtype.descr
for t in descr:
if not isinstance(t[1], str):
raise ValueError("nested records not supported")
if not t[0]:
raise ValueError("field with empty name")
if len(t) != 2 or t[1][1] == 'O':
# non-scalar field, which corresponds to a list
# property in PLY.
if t[1][1] == 'O':
if len(t) != 2:
raise ValueError("non-scalar object fields not "
"supported")
len_str = _data_type_reverse[len_types.get(t[0], 'u1')]
if t[1][1] == 'O':
val_type = val_types.get(t[0], 'i4')
val_str = _lookup_type(val_type)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyListProperty(t[0], len_str, val_str)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyProperty(t[0], val_str)
properties.append(prop)
elt = PlyElement(name, properties, count, comments)
elt.data = data
return elt
def _read(self, stream, text, byte_order, mmap,
known_list_len={}):
"""
Read the actual data from a PLY file.
Parameters
----------
stream : readable open file
text : bool
byte_order : {'<', '>', '='}
mmap : bool
known_list_len : dict
"""
if text:
self._read_txt(stream)
else:
list_prop_names = set(p.name for p in self.properties
if isinstance(p, PlyListProperty))
can_mmap_lists = list_prop_names <= set(known_list_len)
if mmap and _can_mmap(stream) and can_mmap_lists:
# Loading the data is straightforward. We will memory
# map the file in copy-on-write mode.
self._read_mmap(stream, byte_order, known_list_len)
else:
# A simple load is impossible.
self._read_bin(stream, byte_order)
self._check_sanity()
def _write(self, stream, text, byte_order):
"""
Write the data to a PLY file.
Parameters
----------
stream : writeable open file
text : bool
byte_order : {'<', '>', '='}
"""
if text:
self._write_txt(stream)
else:
if self._have_list:
# There are list properties, so serialization is
# slightly complicated.
self._write_bin(stream, byte_order)
else:
# no list properties, so serialization is
# straightforward.
stream.write(self.data.astype(self.dtype(byte_order),
copy=False).data)
def _read_mmap(self, stream, byte_order, known_list_len):
"""
Memory-map an input file as `self.data`.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
known_list_len : dict
"""
list_len_props = {}
# update the dtype to include the list length and list dtype
new_dtype = []
for p in self.properties:
if isinstance(p, PlyListProperty):
len_dtype, val_dtype = p.list_dtype(byte_order)
# create new dtype for the list length
new_dtype.append((p.name + "\nlen", len_dtype))
# a new dtype with size for the list values themselves
new_dtype.append((p.name, val_dtype,
(known_list_len[p.name],)))
list_len_props[p.name] = p.name + "\nlen"
else:
new_dtype.append((p.name, p.dtype(byte_order)))
dtype = _np.dtype(new_dtype)
num_bytes = self.count * dtype.itemsize
offset = stream.tell()
stream.seek(0, 2)
max_bytes = stream.tell() - offset
if max_bytes < num_bytes:
raise PlyElementParseError("early end-of-file", self,
max_bytes // dtype.itemsize)
self._data = _np.memmap(stream, dtype, 'c', offset, self.count)
# Fix stream position
stream.seek(offset + self.count * dtype.itemsize)
# remove any extra properties added
for prop in list_len_props:
field = list_len_props[prop]
len_check = self._data[field] == known_list_len[prop]
if not len_check.all():
row = _np.flatnonzero(len_check ^ True)[0]
raise PlyElementParseError(
"unexpected list length",
self, row, self.ply_property(prop))
props = [p.name for p in self.properties]
self._data = self._data[props]
def _read_txt(self, stream):
"""
Load a PLY element from an ASCII-format PLY file. The element
may contain list properties.
Parameters
----------
stream : readable open file
"""
self._data = _np.empty(self.count, dtype=self.dtype())
k = 0
for line in _islice(iter(stream.readline, ''), self.count):
fields = iter(line.strip().split())
for prop in self.properties:
try:
self._data[prop.name][k] = prop._from_fields(fields)
except StopIteration:
raise PlyElementParseError("early end-of-line",
self, k, prop)
except ValueError:
raise PlyElementParseError("malformed input",
self, k, prop)
try:
next(fields)
except StopIteration:
pass
else:
raise PlyElementParseError("expected end-of-line",
self, k)
k += 1
if k < self.count:
del self._data
raise PlyElementParseError("early end-of-file", self, k)
def _write_txt(self, stream):
"""
Save a PLY element to an ASCII-format PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
"""
for rec in self.data:
fields = []
for prop in self.properties:
fields.extend(prop._to_fields(rec[prop.name]))
_np.savetxt(stream, [fields], '%.18g', newline='\n')
def _read_bin(self, stream, byte_order):
"""
Load a PLY element from a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
"""
self._data = _np.empty(self.count, dtype=self.dtype(byte_order))
for k in range(self.count):
for prop in self.properties:
try:
self._data[prop.name][k] = \
prop._read_bin(stream, byte_order)
except StopIteration:
raise PlyElementParseError("early end-of-file",
self, k, prop)
def _write_bin(self, stream, byte_order):
"""
Save a PLY element to a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
byte_order : {'<', '>', '='}
"""
for rec in self.data:
for prop in self.properties:
prop._write_bin(rec[prop.name], stream, byte_order)
@property
def header(self):
lines = ['element %s %d' % (self.name, self.count)]
# Some information is lost here, since all comments are placed
# between the 'element' line and the first property definition.
for c in self.comments:
lines.append('comment ' + c)
lines.extend(list(map(str, self.properties)))
return '\n'.join(lines)
def __len__(self):
"""
Return the number of rows in the element.
"""
return self.count
def __contains__(self, name):
"""
Determine if a property with the given name exists.
"""
return name in self._property_lookup
def __getitem__(self, key):
"""
Proxy to `self.data.__getitem__` for convenience.
"""
return self.data[key]
def __setitem__(self, key, value):
"""
Proxy to `self.data.__setitem__` for convenience.
"""
self.data[key] = value
def __str__(self):
return self.header
def __repr__(self):
return ('PlyElement(%r, %r, count=%d, comments=%r)' %
(self.name, self.properties, self.count,
self.comments))
|
(name, properties, count, comments=[])
|
62,480 |
plyfile
|
__contains__
|
Determine if a property with the given name exists.
|
def __contains__(self, name):
"""
Determine if a property with the given name exists.
"""
return name in self._property_lookup
|
(self, name)
|
62,481 |
plyfile
|
__getitem__
|
Proxy to `self.data.__getitem__` for convenience.
|
def __getitem__(self, key):
"""
Proxy to `self.data.__getitem__` for convenience.
"""
return self.data[key]
|
(self, key)
|
62,482 |
plyfile
|
__init__
|
This is not part of the public interface. The preferred methods
of obtaining `PlyElement` instances are `PlyData.read` (to read
from a file) and `PlyElement.describe` (to construct from a
`numpy` array).
Parameters
----------
name : str
properties : list of PlyProperty
count : str
comments : list of str
|
def __init__(self, name, properties, count, comments=[]):
"""
This is not part of the public interface. The preferred methods
of obtaining `PlyElement` instances are `PlyData.read` (to read
from a file) and `PlyElement.describe` (to construct from a
`numpy` array).
Parameters
----------
name : str
properties : list of PlyProperty
count : str
comments : list of str
"""
_check_name(name)
self._name = str(name)
self._count = count
self._properties = tuple(properties)
self._index()
self.comments = comments
self._have_list = any(isinstance(p, PlyListProperty)
for p in self.properties)
|
(self, name, properties, count, comments=[])
|
62,483 |
plyfile
|
__len__
|
Return the number of rows in the element.
|
def __len__(self):
"""
Return the number of rows in the element.
"""
return self.count
|
(self)
|
62,484 |
plyfile
|
__repr__
| null |
def __repr__(self):
return ('PlyElement(%r, %r, count=%d, comments=%r)' %
(self.name, self.properties, self.count,
self.comments))
|
(self)
|
62,485 |
plyfile
|
__setitem__
|
Proxy to `self.data.__setitem__` for convenience.
|
def __setitem__(self, key, value):
"""
Proxy to `self.data.__setitem__` for convenience.
"""
self.data[key] = value
|
(self, key, value)
|
62,487 |
plyfile
|
_check_sanity
| null |
def _check_sanity(self):
for prop in self.properties:
if prop.name not in self._data.dtype.fields:
raise ValueError("dangling property %r" % prop.name)
|
(self)
|
62,489 |
plyfile
|
_get_data
| null |
def _get_data(self):
return self._data
|
(self)
|
62,490 |
plyfile
|
_get_properties
| null |
def _get_properties(self):
return self._properties
|
(self)
|
62,491 |
plyfile
|
_index
| null |
def _index(self):
self._property_lookup = dict((prop.name, prop)
for prop in self._properties)
if len(self._property_lookup) != len(self._properties):
raise ValueError("two properties with same name")
|
(self)
|
62,492 |
plyfile
|
_read
|
Read the actual data from a PLY file.
Parameters
----------
stream : readable open file
text : bool
byte_order : {'<', '>', '='}
mmap : bool
known_list_len : dict
|
def _read(self, stream, text, byte_order, mmap,
known_list_len={}):
"""
Read the actual data from a PLY file.
Parameters
----------
stream : readable open file
text : bool
byte_order : {'<', '>', '='}
mmap : bool
known_list_len : dict
"""
if text:
self._read_txt(stream)
else:
list_prop_names = set(p.name for p in self.properties
if isinstance(p, PlyListProperty))
can_mmap_lists = list_prop_names <= set(known_list_len)
if mmap and _can_mmap(stream) and can_mmap_lists:
# Loading the data is straightforward. We will memory
# map the file in copy-on-write mode.
self._read_mmap(stream, byte_order, known_list_len)
else:
# A simple load is impossible.
self._read_bin(stream, byte_order)
self._check_sanity()
|
(self, stream, text, byte_order, mmap, known_list_len={})
|
62,493 |
plyfile
|
_read_bin
|
Load a PLY element from a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
|
def _read_bin(self, stream, byte_order):
"""
Load a PLY element from a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
"""
self._data = _np.empty(self.count, dtype=self.dtype(byte_order))
for k in range(self.count):
for prop in self.properties:
try:
self._data[prop.name][k] = \
prop._read_bin(stream, byte_order)
except StopIteration:
raise PlyElementParseError("early end-of-file",
self, k, prop)
|
(self, stream, byte_order)
|
62,494 |
plyfile
|
_read_mmap
|
Memory-map an input file as `self.data`.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
known_list_len : dict
|
def _read_mmap(self, stream, byte_order, known_list_len):
"""
Memory-map an input file as `self.data`.
Parameters
----------
stream : readable open file
byte_order : {'<', '>', '='}
known_list_len : dict
"""
list_len_props = {}
# update the dtype to include the list length and list dtype
new_dtype = []
for p in self.properties:
if isinstance(p, PlyListProperty):
len_dtype, val_dtype = p.list_dtype(byte_order)
# create new dtype for the list length
new_dtype.append((p.name + "\nlen", len_dtype))
# a new dtype with size for the list values themselves
new_dtype.append((p.name, val_dtype,
(known_list_len[p.name],)))
list_len_props[p.name] = p.name + "\nlen"
else:
new_dtype.append((p.name, p.dtype(byte_order)))
dtype = _np.dtype(new_dtype)
num_bytes = self.count * dtype.itemsize
offset = stream.tell()
stream.seek(0, 2)
max_bytes = stream.tell() - offset
if max_bytes < num_bytes:
raise PlyElementParseError("early end-of-file", self,
max_bytes // dtype.itemsize)
self._data = _np.memmap(stream, dtype, 'c', offset, self.count)
# Fix stream position
stream.seek(offset + self.count * dtype.itemsize)
# remove any extra properties added
for prop in list_len_props:
field = list_len_props[prop]
len_check = self._data[field] == known_list_len[prop]
if not len_check.all():
row = _np.flatnonzero(len_check ^ True)[0]
raise PlyElementParseError(
"unexpected list length",
self, row, self.ply_property(prop))
props = [p.name for p in self.properties]
self._data = self._data[props]
|
(self, stream, byte_order, known_list_len)
|
62,495 |
plyfile
|
_read_txt
|
Load a PLY element from an ASCII-format PLY file. The element
may contain list properties.
Parameters
----------
stream : readable open file
|
def _read_txt(self, stream):
"""
Load a PLY element from an ASCII-format PLY file. The element
may contain list properties.
Parameters
----------
stream : readable open file
"""
self._data = _np.empty(self.count, dtype=self.dtype())
k = 0
for line in _islice(iter(stream.readline, ''), self.count):
fields = iter(line.strip().split())
for prop in self.properties:
try:
self._data[prop.name][k] = prop._from_fields(fields)
except StopIteration:
raise PlyElementParseError("early end-of-line",
self, k, prop)
except ValueError:
raise PlyElementParseError("malformed input",
self, k, prop)
try:
next(fields)
except StopIteration:
pass
else:
raise PlyElementParseError("expected end-of-line",
self, k)
k += 1
if k < self.count:
del self._data
raise PlyElementParseError("early end-of-file", self, k)
|
(self, stream)
|
62,497 |
plyfile
|
_set_data
| null |
def _set_data(self, data):
self._data = data
self._count = len(data)
self._check_sanity()
|
(self, data)
|
62,498 |
plyfile
|
_set_properties
| null |
def _set_properties(self, properties):
self._properties = tuple(properties)
self._check_sanity()
self._index()
|
(self, properties)
|
62,499 |
plyfile
|
_write
|
Write the data to a PLY file.
Parameters
----------
stream : writeable open file
text : bool
byte_order : {'<', '>', '='}
|
def _write(self, stream, text, byte_order):
"""
Write the data to a PLY file.
Parameters
----------
stream : writeable open file
text : bool
byte_order : {'<', '>', '='}
"""
if text:
self._write_txt(stream)
else:
if self._have_list:
# There are list properties, so serialization is
# slightly complicated.
self._write_bin(stream, byte_order)
else:
# no list properties, so serialization is
# straightforward.
stream.write(self.data.astype(self.dtype(byte_order),
copy=False).data)
|
(self, stream, text, byte_order)
|
62,500 |
plyfile
|
_write_bin
|
Save a PLY element to a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
byte_order : {'<', '>', '='}
|
def _write_bin(self, stream, byte_order):
"""
Save a PLY element to a binary PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
byte_order : {'<', '>', '='}
"""
for rec in self.data:
for prop in self.properties:
prop._write_bin(rec[prop.name], stream, byte_order)
|
(self, stream, byte_order)
|
62,501 |
plyfile
|
_write_txt
|
Save a PLY element to an ASCII-format PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
|
def _write_txt(self, stream):
"""
Save a PLY element to an ASCII-format PLY file. The element may
contain list properties.
Parameters
----------
stream : writeable open file
"""
for rec in self.data:
fields = []
for prop in self.properties:
fields.extend(prop._to_fields(rec[prop.name]))
_np.savetxt(stream, [fields], '%.18g', newline='\n')
|
(self, stream)
|
62,502 |
plyfile
|
describe
|
Construct a `PlyElement` instance from an array's metadata.
Parameters
----------
data : numpy.ndarray
Structured `numpy` array.
len_types : dict, optional
Mapping from list property names to type strings
(`numpy`-style like `'u1'`, `'f4'`, etc., or PLY-style like
`'int8'`, `'float32'`, etc.), which will be used to encode
the length of the list in binary-format PLY files. Defaults
to `'u1'` (8-bit integer) for all list properties.
val_types : dict, optional
Mapping from list property names to type strings as for
`len_types`, but is used to encode the list elements in
binary-format PLY files. Defaults to `'i4'` (32-bit
integer) for all list properties.
comments : list of str
Comments between the "element" line and first property
definition in the header.
Returns
-------
PlyElement
Raises
------
TypeError, ValueError
|
@staticmethod
def describe(data, name, len_types={}, val_types={},
comments=[]):
"""
Construct a `PlyElement` instance from an array's metadata.
Parameters
----------
data : numpy.ndarray
Structured `numpy` array.
len_types : dict, optional
Mapping from list property names to type strings
(`numpy`-style like `'u1'`, `'f4'`, etc., or PLY-style like
`'int8'`, `'float32'`, etc.), which will be used to encode
the length of the list in binary-format PLY files. Defaults
to `'u1'` (8-bit integer) for all list properties.
val_types : dict, optional
Mapping from list property names to type strings as for
`len_types`, but is used to encode the list elements in
binary-format PLY files. Defaults to `'i4'` (32-bit
integer) for all list properties.
comments : list of str
Comments between the "element" line and first property
definition in the header.
Returns
-------
PlyElement
Raises
------
TypeError, ValueError
"""
if not isinstance(data, _np.ndarray):
raise TypeError("only numpy arrays are supported")
if len(data.shape) != 1:
raise ValueError("only one-dimensional arrays are "
"supported")
count = len(data)
properties = []
descr = data.dtype.descr
for t in descr:
if not isinstance(t[1], str):
raise ValueError("nested records not supported")
if not t[0]:
raise ValueError("field with empty name")
if len(t) != 2 or t[1][1] == 'O':
# non-scalar field, which corresponds to a list
# property in PLY.
if t[1][1] == 'O':
if len(t) != 2:
raise ValueError("non-scalar object fields not "
"supported")
len_str = _data_type_reverse[len_types.get(t[0], 'u1')]
if t[1][1] == 'O':
val_type = val_types.get(t[0], 'i4')
val_str = _lookup_type(val_type)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyListProperty(t[0], len_str, val_str)
else:
val_str = _lookup_type(t[1][1:])
prop = PlyProperty(t[0], val_str)
properties.append(prop)
elt = PlyElement(name, properties, count, comments)
elt.data = data
return elt
|
(data, name, len_types={}, val_types={}, comments=[])
|
62,503 |
plyfile
|
dtype
|
Return the `numpy.dtype` description of the in-memory
representation of the data. (If there are no list properties,
and the PLY format is binary, then this also accurately
describes the on-disk representation of the element.)
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
numpy.dtype
|
def dtype(self, byte_order='='):
"""
Return the `numpy.dtype` description of the in-memory
representation of the data. (If there are no list properties,
and the PLY format is binary, then this also accurately
describes the on-disk representation of the element.)
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
numpy.dtype
"""
return _np.dtype([(prop.name, prop.dtype(byte_order))
for prop in self.properties])
|
(self, byte_order='=')
|
62,504 |
plyfile
|
ply_property
|
Look up property by name.
Parameters
----------
name : str
Returns
-------
PlyProperty
Raises
------
KeyError
If the property can't be found.
|
def ply_property(self, name):
"""
Look up property by name.
Parameters
----------
name : str
Returns
-------
PlyProperty
Raises
------
KeyError
If the property can't be found.
"""
return self._property_lookup[name]
|
(self, name)
|
62,505 |
plyfile
|
PlyElementParseError
|
Raised when a PLY element cannot be parsed.
Attributes
----------
message : str
element : PlyElement
row : int
prop : PlyProperty
|
class PlyElementParseError(PlyParseError):
"""
Raised when a PLY element cannot be parsed.
Attributes
----------
message : str
element : PlyElement
row : int
prop : PlyProperty
"""
def __init__(self, message, element=None, row=None, prop=None):
self.message = message
self.element = element
self.row = row
self.prop = prop
s = ''
if self.element:
s += 'element %r: ' % self.element.name
if self.row is not None:
s += 'row %d: ' % self.row
if self.prop:
s += 'property %r: ' % self.prop.name
s += self.message
Exception.__init__(self, s)
def __repr__(self):
return ('%s(%r, element=%r, row=%r, prop=%r)' %
(self.__class__.__name__,
self.message, self.element, self.row, self.prop))
|
(message, element=None, row=None, prop=None)
|
62,506 |
plyfile
|
__init__
| null |
def __init__(self, message, element=None, row=None, prop=None):
self.message = message
self.element = element
self.row = row
self.prop = prop
s = ''
if self.element:
s += 'element %r: ' % self.element.name
if self.row is not None:
s += 'row %d: ' % self.row
if self.prop:
s += 'property %r: ' % self.prop.name
s += self.message
Exception.__init__(self, s)
|
(self, message, element=None, row=None, prop=None)
|
62,507 |
plyfile
|
__repr__
| null |
def __repr__(self):
return ('%s(%r, element=%r, row=%r, prop=%r)' %
(self.__class__.__name__,
self.message, self.element, self.row, self.prop))
|
(self)
|
62,508 |
plyfile
|
PlyHeaderParseError
|
Raised when a PLY header cannot be parsed.
Attributes
----------
line : str
Which header line the error occurred on.
|
class PlyHeaderParseError(PlyParseError):
"""
Raised when a PLY header cannot be parsed.
Attributes
----------
line : str
Which header line the error occurred on.
"""
def __init__(self, message, line=None):
self.message = message
self.line = line
s = ''
if self.line:
s += 'line %r: ' % self.line
s += self.message
Exception.__init__(self, s)
def __repr__(self):
return ('%s(%r, line=%r)' %
(self.__class__.__name__,
self.message, self.line))
|
(message, line=None)
|
62,509 |
plyfile
|
__init__
| null |
def __init__(self, message, line=None):
self.message = message
self.line = line
s = ''
if self.line:
s += 'line %r: ' % self.line
s += self.message
Exception.__init__(self, s)
|
(self, message, line=None)
|
62,510 |
plyfile
|
__repr__
| null |
def __repr__(self):
return ('%s(%r, line=%r)' %
(self.__class__.__name__,
self.message, self.line))
|
(self)
|
62,511 |
plyfile
|
PlyListProperty
|
PLY list property description.
Attributes
----------
name
val_dtype
len_dtype : str
`numpy.dtype` description for the property's length field.
|
class PlyListProperty(PlyProperty):
"""
PLY list property description.
Attributes
----------
name
val_dtype
len_dtype : str
`numpy.dtype` description for the property's length field.
"""
def __init__(self, name, len_dtype, val_dtype):
"""
Parameters
----------
name : str
len_dtype : str
val_dtype : str
"""
PlyProperty.__init__(self, name, val_dtype)
self.len_dtype = len_dtype
def _get_len_dtype(self):
return self._len_dtype
def _set_len_dtype(self, len_dtype):
self._len_dtype = _data_types[_lookup_type(len_dtype)]
len_dtype = property(_get_len_dtype, _set_len_dtype)
def dtype(self, byte_order='='):
"""
`numpy.dtype` name for the property's field in the element.
List properties always have a numpy dtype of "object".
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
dtype : str
Always `'|O'`.
"""
return '|O'
def list_dtype(self, byte_order='='):
"""
Return the pair `(len_dtype, val_dtype)` (both numpy-friendly
strings).
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
len_dtype : str
val_dtype : str
"""
return (byte_order + self.len_dtype,
byte_order + self.val_dtype)
def _from_fields(self, fields):
"""
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data : numpy.ndarray
Parsed list data for the property.
Raises
------
StopIteration
if the property's data could not be read.
"""
(len_t, val_t) = self.list_dtype()
n = int(_np.dtype(len_t).type(next(fields)))
data = _np.loadtxt(list(_islice(fields, n)), val_t, ndmin=1)
if len(data) < n:
raise StopIteration
return data
def _to_fields(self, data):
"""
Return generator over the (numerical) PLY representation of the
list data (length followed by actual data).
Parameters
----------
data : numpy.ndarray
Property data to encode.
Yields
------
Length followed by each list element.
"""
(len_t, val_t) = self.list_dtype()
data = _np.asarray(data, dtype=val_t).ravel()
yield _np.dtype(len_t).type(data.size)
for x in data:
yield x
def _read_bin(self, stream, byte_order):
"""
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<', '>', '='}
Returns
-------
data : numpy.ndarray
Raises
------
StopIteration
If data could not be read.
"""
(len_t, val_t) = self.list_dtype(byte_order)
try:
n = _read_array(stream, _np.dtype(len_t), 1)[0]
except IndexError:
raise StopIteration
data = _read_array(stream, _np.dtype(val_t), n)
if len(data) < n:
raise StopIteration
return data
def _write_bin(self, data, stream, byte_order):
"""
Write data to a binary stream.
Parameters
----------
data : numpy.ndarray
Data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
"""
(len_t, val_t) = self.list_dtype(byte_order)
data = _np.asarray(data, dtype=val_t).ravel()
_write_array(stream, _np.array(data.size, dtype=len_t))
_write_array(stream, data)
def __str__(self):
len_str = _data_type_reverse[self.len_dtype]
val_str = _data_type_reverse[self.val_dtype]
return 'property list %s %s %s' % (len_str, val_str, self.name)
def __repr__(self):
return ('PlyListProperty(%r, %r, %r)' %
(self.name,
_lookup_type(self.len_dtype),
_lookup_type(self.val_dtype)))
|
(name, len_dtype, val_dtype)
|
62,512 |
plyfile
|
__init__
|
Parameters
----------
name : str
len_dtype : str
val_dtype : str
|
def __init__(self, name, len_dtype, val_dtype):
"""
Parameters
----------
name : str
len_dtype : str
val_dtype : str
"""
PlyProperty.__init__(self, name, val_dtype)
self.len_dtype = len_dtype
|
(self, name, len_dtype, val_dtype)
|
62,513 |
plyfile
|
__repr__
| null |
def __repr__(self):
return ('PlyListProperty(%r, %r, %r)' %
(self.name,
_lookup_type(self.len_dtype),
_lookup_type(self.val_dtype)))
|
(self)
|
62,514 |
plyfile
|
__str__
| null |
def __str__(self):
len_str = _data_type_reverse[self.len_dtype]
val_str = _data_type_reverse[self.val_dtype]
return 'property list %s %s %s' % (len_str, val_str, self.name)
|
(self)
|
62,515 |
plyfile
|
_from_fields
|
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data : numpy.ndarray
Parsed list data for the property.
Raises
------
StopIteration
if the property's data could not be read.
|
def _from_fields(self, fields):
"""
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data : numpy.ndarray
Parsed list data for the property.
Raises
------
StopIteration
if the property's data could not be read.
"""
(len_t, val_t) = self.list_dtype()
n = int(_np.dtype(len_t).type(next(fields)))
data = _np.loadtxt(list(_islice(fields, n)), val_t, ndmin=1)
if len(data) < n:
raise StopIteration
return data
|
(self, fields)
|
62,516 |
plyfile
|
_get_len_dtype
| null |
def _get_len_dtype(self):
return self._len_dtype
|
(self)
|
62,517 |
plyfile
|
_get_val_dtype
| null |
def _get_val_dtype(self):
return self._val_dtype
|
(self)
|
62,518 |
plyfile
|
_read_bin
|
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<', '>', '='}
Returns
-------
data : numpy.ndarray
Raises
------
StopIteration
If data could not be read.
|
def _read_bin(self, stream, byte_order):
"""
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<', '>', '='}
Returns
-------
data : numpy.ndarray
Raises
------
StopIteration
If data could not be read.
"""
(len_t, val_t) = self.list_dtype(byte_order)
try:
n = _read_array(stream, _np.dtype(len_t), 1)[0]
except IndexError:
raise StopIteration
data = _read_array(stream, _np.dtype(val_t), n)
if len(data) < n:
raise StopIteration
return data
|
(self, stream, byte_order)
|
62,519 |
plyfile
|
_set_len_dtype
| null |
def _set_len_dtype(self, len_dtype):
self._len_dtype = _data_types[_lookup_type(len_dtype)]
|
(self, len_dtype)
|
62,520 |
plyfile
|
_set_val_dtype
| null |
def _set_val_dtype(self, val_dtype):
self._val_dtype = _data_types[_lookup_type(val_dtype)]
|
(self, val_dtype)
|
62,521 |
plyfile
|
_to_fields
|
Return generator over the (numerical) PLY representation of the
list data (length followed by actual data).
Parameters
----------
data : numpy.ndarray
Property data to encode.
Yields
------
Length followed by each list element.
|
def _to_fields(self, data):
"""
Return generator over the (numerical) PLY representation of the
list data (length followed by actual data).
Parameters
----------
data : numpy.ndarray
Property data to encode.
Yields
------
Length followed by each list element.
"""
(len_t, val_t) = self.list_dtype()
data = _np.asarray(data, dtype=val_t).ravel()
yield _np.dtype(len_t).type(data.size)
for x in data:
yield x
|
(self, data)
|
62,522 |
plyfile
|
_write_bin
|
Write data to a binary stream.
Parameters
----------
data : numpy.ndarray
Data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
|
def _write_bin(self, data, stream, byte_order):
"""
Write data to a binary stream.
Parameters
----------
data : numpy.ndarray
Data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
"""
(len_t, val_t) = self.list_dtype(byte_order)
data = _np.asarray(data, dtype=val_t).ravel()
_write_array(stream, _np.array(data.size, dtype=len_t))
_write_array(stream, data)
|
(self, data, stream, byte_order)
|
62,523 |
plyfile
|
dtype
|
`numpy.dtype` name for the property's field in the element.
List properties always have a numpy dtype of "object".
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
dtype : str
Always `'|O'`.
|
def dtype(self, byte_order='='):
"""
`numpy.dtype` name for the property's field in the element.
List properties always have a numpy dtype of "object".
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
dtype : str
Always `'|O'`.
"""
return '|O'
|
(self, byte_order='=')
|
62,524 |
plyfile
|
list_dtype
|
Return the pair `(len_dtype, val_dtype)` (both numpy-friendly
strings).
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
len_dtype : str
val_dtype : str
|
def list_dtype(self, byte_order='='):
"""
Return the pair `(len_dtype, val_dtype)` (both numpy-friendly
strings).
Parameters
----------
byte_order : {'<', '>', '='}
Returns
-------
len_dtype : str
val_dtype : str
"""
return (byte_order + self.len_dtype,
byte_order + self.val_dtype)
|
(self, byte_order='=')
|
62,525 |
plyfile
|
PlyParseError
|
Base class for PLY parsing errors.
|
class PlyParseError(Exception):
"""
Base class for PLY parsing errors.
"""
pass
| null |
62,526 |
plyfile
|
PlyProperty
|
PLY property description.
This class is pure metadata. The data itself is contained in
`PlyElement` instances.
Attributes
----------
name : str
val_dtype : str
`numpy.dtype` description for the property's data.
|
class PlyProperty(object):
"""
PLY property description.
This class is pure metadata. The data itself is contained in
`PlyElement` instances.
Attributes
----------
name : str
val_dtype : str
`numpy.dtype` description for the property's data.
"""
def __init__(self, name, val_dtype):
"""
Parameters
----------
name : str
val_dtype : str
"""
_check_name(name)
self._name = str(name)
self.val_dtype = val_dtype
def _get_val_dtype(self):
return self._val_dtype
def _set_val_dtype(self, val_dtype):
self._val_dtype = _data_types[_lookup_type(val_dtype)]
val_dtype = property(_get_val_dtype, _set_val_dtype)
@property
def name(self):
return self._name
def dtype(self, byte_order='='):
"""
Return the `numpy.dtype` description for this property.
Parameters
----------
byte_order : {'<', '>', '='}, default='='
Returns
-------
tuple of str
"""
return byte_order + self.val_dtype
def _from_fields(self, fields):
"""
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data
Parsed data of the correct type.
Raises
------
StopIteration
if the property's data could not be read.
"""
return _np.dtype(self.dtype()).type(next(fields))
def _to_fields(self, data):
"""
Parameters
----------
data
Property data to encode.
Yields
------
encoded_data
Data with type consistent with `self.val_dtype`.
"""
yield _np.dtype(self.dtype()).type(data)
def _read_bin(self, stream, byte_order):
"""
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<'. '>', '='}
Raises
------
StopIteration
If the property data could not be read.
"""
try:
return _read_array(stream, self.dtype(byte_order), 1)[0]
except IndexError:
raise StopIteration
def _write_bin(self, data, stream, byte_order):
"""
Write data to a binary stream.
Parameters
----------
data
Property data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
"""
_write_array(stream, _np.dtype(self.dtype(byte_order)).type(data))
def __str__(self):
val_str = _data_type_reverse[self.val_dtype]
return 'property %s %s' % (val_str, self.name)
def __repr__(self):
return 'PlyProperty(%r, %r)' % (self.name,
_lookup_type(self.val_dtype))
|
(name, val_dtype)
|
62,527 |
plyfile
|
__init__
|
Parameters
----------
name : str
val_dtype : str
|
def __init__(self, name, val_dtype):
"""
Parameters
----------
name : str
val_dtype : str
"""
_check_name(name)
self._name = str(name)
self.val_dtype = val_dtype
|
(self, name, val_dtype)
|
62,528 |
plyfile
|
__repr__
| null |
def __repr__(self):
return 'PlyProperty(%r, %r)' % (self.name,
_lookup_type(self.val_dtype))
|
(self)
|
62,529 |
plyfile
|
__str__
| null |
def __str__(self):
val_str = _data_type_reverse[self.val_dtype]
return 'property %s %s' % (val_str, self.name)
|
(self)
|
62,530 |
plyfile
|
_from_fields
|
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data
Parsed data of the correct type.
Raises
------
StopIteration
if the property's data could not be read.
|
def _from_fields(self, fields):
"""
Parse data from generator.
Parameters
----------
fields : iterator of str
Returns
-------
data
Parsed data of the correct type.
Raises
------
StopIteration
if the property's data could not be read.
"""
return _np.dtype(self.dtype()).type(next(fields))
|
(self, fields)
|
62,532 |
plyfile
|
_read_bin
|
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<'. '>', '='}
Raises
------
StopIteration
If the property data could not be read.
|
def _read_bin(self, stream, byte_order):
"""
Read data from a binary stream.
Parameters
----------
stream : readable open binary file
byte_order : {'<'. '>', '='}
Raises
------
StopIteration
If the property data could not be read.
"""
try:
return _read_array(stream, self.dtype(byte_order), 1)[0]
except IndexError:
raise StopIteration
|
(self, stream, byte_order)
|
62,534 |
plyfile
|
_to_fields
|
Parameters
----------
data
Property data to encode.
Yields
------
encoded_data
Data with type consistent with `self.val_dtype`.
|
def _to_fields(self, data):
"""
Parameters
----------
data
Property data to encode.
Yields
------
encoded_data
Data with type consistent with `self.val_dtype`.
"""
yield _np.dtype(self.dtype()).type(data)
|
(self, data)
|
62,535 |
plyfile
|
_write_bin
|
Write data to a binary stream.
Parameters
----------
data
Property data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
|
def _write_bin(self, data, stream, byte_order):
"""
Write data to a binary stream.
Parameters
----------
data
Property data to encode.
stream : writeable open binary file
byte_order : {'<', '>', '='}
"""
_write_array(stream, _np.dtype(self.dtype(byte_order)).type(data))
|
(self, data, stream, byte_order)
|
62,536 |
plyfile
|
dtype
|
Return the `numpy.dtype` description for this property.
Parameters
----------
byte_order : {'<', '>', '='}, default='='
Returns
-------
tuple of str
|
def dtype(self, byte_order='='):
"""
Return the `numpy.dtype` description for this property.
Parameters
----------
byte_order : {'<', '>', '='}, default='='
Returns
-------
tuple of str
"""
return byte_order + self.val_dtype
|
(self, byte_order='=')
|
62,537 |
plyfile
|
_PlyHeaderLines
|
Generator over lines in the PLY header.
LF, CR, and CRLF line endings are supported.
|
class _PlyHeaderLines(object):
"""
Generator over lines in the PLY header.
LF, CR, and CRLF line endings are supported.
"""
def __init__(self, stream):
"""
Parameters
----------
stream : text or binary stream.
Raises
------
PlyHeaderParseError
"""
s = self._decode(stream.read(4))
self.chars = []
if s[:3] != 'ply':
raise PlyHeaderParseError("expected 'ply'", 1)
self.nl = s[3:]
if s[3:] == '\r':
c = self._decode(stream.read(1))
if c == '\n':
self.nl += c
else:
self.chars.append(c)
elif s[3:] != '\n':
raise PlyHeaderParseError(
"unexpected characters after 'ply'", 1)
self.stream = stream
self.len_nl = len(self.nl)
self.done = False
self.lines = 1
@staticmethod
def _decode(s):
"""
Convert input `str` or `bytes` instance to `str`, decoding
as ASCII if necessary.
"""
if isinstance(s, str):
return s
return s.decode('ascii')
def __iter__(self):
"""
Yields
------
line : str
Decoded line with newline removed.
"""
while not self.done:
self.lines += 1
while ''.join(self.chars[-self.len_nl:]) != self.nl:
char = self._decode(self.stream.read(1))
if not char:
raise PlyHeaderParseError("early end-of-file",
self.lines)
self.chars.append(char)
line = ''.join(self.chars[:-self.len_nl])
self.chars = []
if line == 'end_header':
self.done = True
yield line
|
(stream)
|
62,538 |
plyfile
|
__init__
|
Parameters
----------
stream : text or binary stream.
Raises
------
PlyHeaderParseError
|
def __init__(self, stream):
"""
Parameters
----------
stream : text or binary stream.
Raises
------
PlyHeaderParseError
"""
s = self._decode(stream.read(4))
self.chars = []
if s[:3] != 'ply':
raise PlyHeaderParseError("expected 'ply'", 1)
self.nl = s[3:]
if s[3:] == '\r':
c = self._decode(stream.read(1))
if c == '\n':
self.nl += c
else:
self.chars.append(c)
elif s[3:] != '\n':
raise PlyHeaderParseError(
"unexpected characters after 'ply'", 1)
self.stream = stream
self.len_nl = len(self.nl)
self.done = False
self.lines = 1
|
(self, stream)
|
62,539 |
plyfile
|
__iter__
|
Yields
------
line : str
Decoded line with newline removed.
|
def __iter__(self):
"""
Yields
------
line : str
Decoded line with newline removed.
"""
while not self.done:
self.lines += 1
while ''.join(self.chars[-self.len_nl:]) != self.nl:
char = self._decode(self.stream.read(1))
if not char:
raise PlyHeaderParseError("early end-of-file",
self.lines)
self.chars.append(char)
line = ''.join(self.chars[:-self.len_nl])
self.chars = []
if line == 'end_header':
self.done = True
yield line
|
(self)
|
62,540 |
plyfile
|
_decode
|
Convert input `str` or `bytes` instance to `str`, decoding
as ASCII if necessary.
|
@staticmethod
def _decode(s):
"""
Convert input `str` or `bytes` instance to `str`, decoding
as ASCII if necessary.
"""
if isinstance(s, str):
return s
return s.decode('ascii')
|
(s)
|
62,541 |
plyfile
|
_PlyHeaderParser
|
Parser for PLY format header.
Attributes
----------
format : str
"ascii", "binary_little_endian", or "binary_big_endian"
elements : list of (name, comments, count, properties)
comments : list of str
obj_info : list of str
lines : int
|
class _PlyHeaderParser(object):
"""
Parser for PLY format header.
Attributes
----------
format : str
"ascii", "binary_little_endian", or "binary_big_endian"
elements : list of (name, comments, count, properties)
comments : list of str
obj_info : list of str
lines : int
"""
def __init__(self, lines):
"""
Parameters
----------
lines : iterable of str
Header lines, starting *after* the "ply" line.
Raises
------
PlyHeaderParseError
"""
self.format = None
self.elements = []
self.comments = []
self.obj_info = []
self.lines = 1
self._allowed = ['format', 'comment', 'obj_info']
for line in lines:
self.consume(line)
if self._allowed:
self._error("early end-of-file")
def consume(self, raw_line):
"""
Parse and internalize one line of input.
"""
self.lines += 1
if not raw_line:
self._error("early end-of-file")
line = raw_line.strip()
try:
keyword = line.split(None, 1)[0]
except IndexError:
self._error()
if keyword not in self._allowed:
self._error("expected one of {%s}" %
", ".join(self._allowed))
# This dynamic method lookup pattern is somewhat questionable,
# but it's probably not worth replacing it with something more
# principled but also more complex.
getattr(self, 'parse_' + keyword)(line[len(keyword)+1:])
return self._allowed
def _error(self, message="parse error"):
raise PlyHeaderParseError(message, self.lines)
# The parse_* methods below are used to parse all the different
# types of PLY header lines. (See `consume` above for the call site,
# which uses dynamic lookup.) Each method accepts a single argument,
# which is the remainder of the header line after the first word,
# and the method does two things:
# - internalize the semantic content of the string into the
# instance's attributes, and
# - set self._allowed to a list of the line types that can come
# next.
def parse_format(self, data):
fields = data.strip().split()
if len(fields) != 2:
self._error("expected \"format {format} 1.0\"")
self.format = fields[0]
if self.format not in _byte_order_map:
self._error("don't understand format %r" % self.format)
if fields[1] != '1.0':
self._error("expected version '1.0'")
self._allowed = ['element', 'comment', 'obj_info', 'end_header']
def parse_comment(self, data):
if not self.elements:
self.comments.append(data)
else:
self.elements[-1][3].append(data)
def parse_obj_info(self, data):
self.obj_info.append(data)
def parse_element(self, data):
fields = data.strip().split()
if len(fields) != 2:
self._error("expected \"element {name} {count}\"")
name = fields[0]
try:
count = int(fields[1])
except ValueError:
self._error("expected integer count")
self.elements.append((name, [], count, []))
self._allowed = ['element', 'comment', 'property', 'end_header']
def parse_property(self, data):
properties = self.elements[-1][1]
fields = data.strip().split()
if len(fields) < 2:
self._error("bad 'property' line")
if fields[0] == 'list':
if len(fields) != 4:
self._error("expected \"property list "
"{len_type} {val_type} {name}\"")
try:
properties.append(
PlyListProperty(fields[3], fields[1], fields[2])
)
except ValueError as e:
self._error(str(e))
else:
if len(fields) != 2:
self._error("expected \"property {type} {name}\"")
try:
properties.append(
PlyProperty(fields[1], fields[0])
)
except ValueError as e:
self._error(str(e))
def parse_end_header(self, data):
if data:
self._error("unexpected data after 'end_header'")
self._allowed = []
|
(lines)
|
62,542 |
plyfile
|
__init__
|
Parameters
----------
lines : iterable of str
Header lines, starting *after* the "ply" line.
Raises
------
PlyHeaderParseError
|
def __init__(self, lines):
"""
Parameters
----------
lines : iterable of str
Header lines, starting *after* the "ply" line.
Raises
------
PlyHeaderParseError
"""
self.format = None
self.elements = []
self.comments = []
self.obj_info = []
self.lines = 1
self._allowed = ['format', 'comment', 'obj_info']
for line in lines:
self.consume(line)
if self._allowed:
self._error("early end-of-file")
|
(self, lines)
|
62,543 |
plyfile
|
_error
| null |
def _error(self, message="parse error"):
raise PlyHeaderParseError(message, self.lines)
|
(self, message='parse error')
|
62,544 |
plyfile
|
consume
|
Parse and internalize one line of input.
|
def consume(self, raw_line):
"""
Parse and internalize one line of input.
"""
self.lines += 1
if not raw_line:
self._error("early end-of-file")
line = raw_line.strip()
try:
keyword = line.split(None, 1)[0]
except IndexError:
self._error()
if keyword not in self._allowed:
self._error("expected one of {%s}" %
", ".join(self._allowed))
# This dynamic method lookup pattern is somewhat questionable,
# but it's probably not worth replacing it with something more
# principled but also more complex.
getattr(self, 'parse_' + keyword)(line[len(keyword)+1:])
return self._allowed
|
(self, raw_line)
|
62,545 |
plyfile
|
parse_comment
| null |
def parse_comment(self, data):
if not self.elements:
self.comments.append(data)
else:
self.elements[-1][3].append(data)
|
(self, data)
|
62,546 |
plyfile
|
parse_element
| null |
def parse_element(self, data):
fields = data.strip().split()
if len(fields) != 2:
self._error("expected \"element {name} {count}\"")
name = fields[0]
try:
count = int(fields[1])
except ValueError:
self._error("expected integer count")
self.elements.append((name, [], count, []))
self._allowed = ['element', 'comment', 'property', 'end_header']
|
(self, data)
|
62,547 |
plyfile
|
parse_end_header
| null |
def parse_end_header(self, data):
if data:
self._error("unexpected data after 'end_header'")
self._allowed = []
|
(self, data)
|
62,548 |
plyfile
|
parse_format
| null |
def parse_format(self, data):
fields = data.strip().split()
if len(fields) != 2:
self._error("expected \"format {format} 1.0\"")
self.format = fields[0]
if self.format not in _byte_order_map:
self._error("don't understand format %r" % self.format)
if fields[1] != '1.0':
self._error("expected version '1.0'")
self._allowed = ['element', 'comment', 'obj_info', 'end_header']
|
(self, data)
|
62,549 |
plyfile
|
parse_obj_info
| null |
def parse_obj_info(self, data):
self.obj_info.append(data)
|
(self, data)
|
62,550 |
plyfile
|
parse_property
| null |
def parse_property(self, data):
properties = self.elements[-1][1]
fields = data.strip().split()
if len(fields) < 2:
self._error("bad 'property' line")
if fields[0] == 'list':
if len(fields) != 4:
self._error("expected \"property list "
"{len_type} {val_type} {name}\"")
try:
properties.append(
PlyListProperty(fields[3], fields[1], fields[2])
)
except ValueError as e:
self._error(str(e))
else:
if len(fields) != 2:
self._error("expected \"property {type} {name}\"")
try:
properties.append(
PlyProperty(fields[1], fields[0])
)
except ValueError as e:
self._error(str(e))
|
(self, data)
|
62,551 |
plyfile
|
_can_mmap
|
Determine if a readable stream can be memory-mapped, using some good
heuristics.
Parameters
----------
stream : open binary file
Returns
-------
bool
|
def _can_mmap(stream):
"""
Determine if a readable stream can be memory-mapped, using some good
heuristics.
Parameters
----------
stream : open binary file
Returns
-------
bool
"""
try:
pos = stream.tell()
try:
_np.memmap(stream, 'u1', 'c')
stream.seek(pos)
return True
except Exception:
stream.seek(pos)
return False
except Exception:
return False
|
(stream)
|
62,552 |
plyfile
|
_check_comments
|
Check that the given comments can be safely used in a PLY header.
Parameters
----------
comments : list of str
Raises
------
ValueError
If the check fails.
|
def _check_comments(comments):
"""
Check that the given comments can be safely used in a PLY header.
Parameters
----------
comments : list of str
Raises
------
ValueError
If the check fails.
"""
for comment in comments:
for char in comment:
if not 0 <= ord(char) < 128:
raise ValueError("non-ASCII character in comment")
if char == '\n':
raise ValueError("embedded newline in comment")
|
(comments)
|
62,553 |
plyfile
|
_check_name
|
Check that a string can be safely be used as the name of an element
or property in a PLY file.
Parameters
----------
name : str
Raises
------
ValueError
If the check failed.
|
def _check_name(name):
"""
Check that a string can be safely be used as the name of an element
or property in a PLY file.
Parameters
----------
name : str
Raises
------
ValueError
If the check failed.
"""
for char in name:
if not 0 <= ord(char) < 128:
raise ValueError("non-ASCII character in name %r" % name)
if char.isspace():
raise ValueError("space character(s) in name %r" % name)
|
(name)
|
62,556 |
plyfile
|
_lookup_type
| null |
def _lookup_type(type_str):
if type_str not in _data_type_reverse:
try:
type_str = _data_types[type_str]
except KeyError:
raise ValueError("field type %r not in %r" %
(type_str, _types_list))
return _data_type_reverse[type_str]
|
(type_str)
|
62,558 |
plyfile
|
_open_stream
|
Normalizing function: given a filename or open stream,
return an open stream.
Parameters
----------
stream : str or open file-like object
read_or_write : str
`"read"` or `"write"`, the method to be used on the stream.
Returns
-------
must_close : bool
Whether `.close` needs to be called on the file object
by the caller (i.e., it wasn't already open).
file : file-like object
Raises
------
TypeError
If `stream` is neither a string nor has the
`read_or_write`-indicated method.
|
def _open_stream(stream, read_or_write):
"""
Normalizing function: given a filename or open stream,
return an open stream.
Parameters
----------
stream : str or open file-like object
read_or_write : str
`"read"` or `"write"`, the method to be used on the stream.
Returns
-------
must_close : bool
Whether `.close` needs to be called on the file object
by the caller (i.e., it wasn't already open).
file : file-like object
Raises
------
TypeError
If `stream` is neither a string nor has the
`read_or_write`-indicated method.
"""
if hasattr(stream, read_or_write):
return (False, stream)
try:
return (True, open(stream, read_or_write[0] + 'b'))
except TypeError:
raise TypeError("expected open file or filename")
|
(stream, read_or_write)
|
62,559 |
plyfile
|
_read_array
|
Read `n` elements of type `dtype` from an open stream.
Parameters
----------
stream : readable open binary file
dtype : dtype description
n : int
Returns
-------
numpy.ndarray
Raises
------
StopIteration
If `n` elements could not be read.
|
def _read_array(stream, dtype, n):
"""
Read `n` elements of type `dtype` from an open stream.
Parameters
----------
stream : readable open binary file
dtype : dtype description
n : int
Returns
-------
numpy.ndarray
Raises
------
StopIteration
If `n` elements could not be read.
"""
try:
size = int(_np.dtype(dtype).itemsize * n)
return _np.frombuffer(stream.read(size), dtype)
except Exception:
raise StopIteration
|
(stream, dtype, n)
|
62,560 |
plyfile
|
_write_array
|
Write `numpy` array to a binary file.
Parameters
----------
stream : writeable open binary file
array : numpy.ndarray
|
def _write_array(stream, array):
"""
Write `numpy` array to a binary file.
Parameters
----------
stream : writeable open binary file
array : numpy.ndarray
"""
stream.write(array.tobytes())
|
(stream, array)
|
62,561 |
mailchimp_transactional.api.allowlists_api
|
AllowlistsApi
|
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
|
class AllowlistsApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_key='', api_client = None):
self.api_key = api_key
if api_client:
self.api_client = api_client
else:
self.api_client = ApiClient()
def add(self, body = {}, **kwargs): # noqa: E501
"""Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
"""
(data) = self.add_with_http_info(body, **kwargs) # noqa: E501
return data
def add_with_http_info(self, body, **kwargs): # noqa: E501
"""Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method add" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/add', 'POST',
body=body_params,
response_type='InlineResponse200') # noqa: E501
def delete(self, body = {}, **kwargs): # noqa: E501
"""Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
"""
(data) = self.delete_with_http_info(body, **kwargs) # noqa: E501
return data
def delete_with_http_info(self, body, **kwargs): # noqa: E501
"""Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method delete" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/delete', 'POST',
body=body_params,
response_type='InlineResponse2002') # noqa: E501
def list(self, body = {}, **kwargs): # noqa: E501
"""List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
"""
(data) = self.list_with_http_info(body, **kwargs) # noqa: E501
return data
def list_with_http_info(self, body, **kwargs): # noqa: E501
"""List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method list" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/list', 'POST',
body=body_params,
response_type='list[InlineResponse2001]') # noqa: E501
|
(api_key='', api_client=None)
|
62,562 |
mailchimp_transactional.api.allowlists_api
|
__init__
| null |
def __init__(self, api_key='', api_client = None):
self.api_key = api_key
if api_client:
self.api_client = api_client
else:
self.api_client = ApiClient()
|
(self, api_key='', api_client=None)
|
62,563 |
mailchimp_transactional.api.allowlists_api
|
add
|
Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
|
def add(self, body = {}, **kwargs): # noqa: E501
"""Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
"""
(data) = self.add_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
62,564 |
mailchimp_transactional.api.allowlists_api
|
add_with_http_info
|
Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
|
def add_with_http_info(self, body, **kwargs): # noqa: E501
"""Add email to allowlist # noqa: E501
Adds an email to your email rejection allowlist. If the address is currently on your denylist, that denylist entry will be removed automatically. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method add" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/add', 'POST',
body=body_params,
response_type='InlineResponse200') # noqa: E501
|
(self, body, **kwargs)
|
62,565 |
mailchimp_transactional.api.allowlists_api
|
delete
|
Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
|
def delete(self, body = {}, **kwargs): # noqa: E501
"""Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
"""
(data) = self.delete_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
62,566 |
mailchimp_transactional.api.allowlists_api
|
delete_with_http_info
|
Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
|
def delete_with_http_info(self, body, **kwargs): # noqa: E501
"""Remove email from allowlist # noqa: E501
Removes an email address from the allowlist. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method delete" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/delete', 'POST',
body=body_params,
response_type='InlineResponse2002') # noqa: E501
|
(self, body, **kwargs)
|
62,567 |
mailchimp_transactional.api.allowlists_api
|
list
|
List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
|
def list(self, body = {}, **kwargs): # noqa: E501
"""List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
"""
(data) = self.list_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
62,568 |
mailchimp_transactional.api.allowlists_api
|
list_with_http_info
|
List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
|
def list_with_http_info(self, body, **kwargs): # noqa: E501
"""List allowlisted emails # noqa: E501
Retrieves your email rejection allowlist. You can provide an email address or search prefix to limit the results. Returns up to 1000 results. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method list" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/allowlists/list', 'POST',
body=body_params,
response_type='list[InlineResponse2001]') # noqa: E501
|
(self, body, **kwargs)
|
62,569 |
mailchimp_transactional.api_client
|
ApiClient
| null |
class ApiClient(object):
def __init__(self):
self.host = "https://mandrillapp.com/api/1.0"
self.user_agent = 'Swagger-Codegen/1.0.56/python'
self.format_list = ['json', 'xml', 'php', 'yaml']
self.content_type = 'application/json'
self.default_output_format = 'json'
self.accepts = ['application/json', 'application/xml', 'application/x-php', 'application/x-yaml; charset=utf-8']
self.timeout = 300
def set_default_output_format(self, output_format):
if output_format in self.format_list:
self.default_output_format = output_format
def set_timeout(self, timeout):
self.timeout = timeout
def call_api(self, resource_path, method, header_params=None, body=None, **kwargs):
# header parameters
headers = header_params or {}
headers['User-Agent'] = self.user_agent
headers['Content-Type'] = self.content_type
# request url
url = self.host + resource_path
use_default_output_format = True
if body and 'outputFormat' in body:
format = body['outputFormat'].lower()
if format in self.format_list:
url += '.%s' % format
del body['outputFormat']
use_default_output_format = False
if use_default_output_format and self.default_output_format in self.format_list:
url += '.%s' % self.default_output_format
# perform request and return response
res = self.request(method, url, body, headers)
try:
if 'application/json' in res.headers.get('content-type'):
data = res.json()
else:
data = res.text
except Exception as err:
data = None
if data:
if (res.ok):
return data
else:
raise ApiClientError(text = data, status_code = res.status_code)
else:
return res
def request(self, method, url, body=None, headers=None, timeout=None):
if not timeout:
timeout = self.timeout
if method == 'POST':
return requests.post(url, data=json.dumps(body), headers=headers, timeout=timeout)
else:
raise ValueError(
"http method must be `POST`"
)
|
()
|
62,570 |
mailchimp_transactional.api_client
|
__init__
| null |
def __init__(self):
self.host = "https://mandrillapp.com/api/1.0"
self.user_agent = 'Swagger-Codegen/1.0.56/python'
self.format_list = ['json', 'xml', 'php', 'yaml']
self.content_type = 'application/json'
self.default_output_format = 'json'
self.accepts = ['application/json', 'application/xml', 'application/x-php', 'application/x-yaml; charset=utf-8']
self.timeout = 300
|
(self)
|
62,571 |
mailchimp_transactional.api_client
|
call_api
| null |
def call_api(self, resource_path, method, header_params=None, body=None, **kwargs):
# header parameters
headers = header_params or {}
headers['User-Agent'] = self.user_agent
headers['Content-Type'] = self.content_type
# request url
url = self.host + resource_path
use_default_output_format = True
if body and 'outputFormat' in body:
format = body['outputFormat'].lower()
if format in self.format_list:
url += '.%s' % format
del body['outputFormat']
use_default_output_format = False
if use_default_output_format and self.default_output_format in self.format_list:
url += '.%s' % self.default_output_format
# perform request and return response
res = self.request(method, url, body, headers)
try:
if 'application/json' in res.headers.get('content-type'):
data = res.json()
else:
data = res.text
except Exception as err:
data = None
if data:
if (res.ok):
return data
else:
raise ApiClientError(text = data, status_code = res.status_code)
else:
return res
|
(self, resource_path, method, header_params=None, body=None, **kwargs)
|
62,572 |
mailchimp_transactional.api_client
|
request
| null |
def request(self, method, url, body=None, headers=None, timeout=None):
if not timeout:
timeout = self.timeout
if method == 'POST':
return requests.post(url, data=json.dumps(body), headers=headers, timeout=timeout)
else:
raise ValueError(
"http method must be `POST`"
)
|
(self, method, url, body=None, headers=None, timeout=None)
|
62,573 |
mailchimp_transactional.api_client
|
set_default_output_format
| null |
def set_default_output_format(self, output_format):
if output_format in self.format_list:
self.default_output_format = output_format
|
(self, output_format)
|
62,574 |
mailchimp_transactional.api_client
|
set_timeout
| null |
def set_timeout(self, timeout):
self.timeout = timeout
|
(self, timeout)
|
62,575 |
mailchimp_transactional
|
Client
| null |
class Client(object):
def __init__(self, api_key = ''):
self.api_key = api_key
self.api_client = ApiClient()
self.allowlists = AllowlistsApi(self.api_key, self.api_client)
self.exports = ExportsApi(self.api_key, self.api_client)
self.inbound = InboundApi(self.api_key, self.api_client)
self.ips = IpsApi(self.api_key, self.api_client)
self.messages = MessagesApi(self.api_key, self.api_client)
self.metadata = MetadataApi(self.api_key, self.api_client)
self.rejects = RejectsApi(self.api_key, self.api_client)
self.senders = SendersApi(self.api_key, self.api_client)
self.subaccounts = SubaccountsApi(self.api_key, self.api_client)
self.tags = TagsApi(self.api_key, self.api_client)
self.templates = TemplatesApi(self.api_key, self.api_client)
self.urls = UrlsApi(self.api_key, self.api_client)
self.users = UsersApi(self.api_key, self.api_client)
self.webhooks = WebhooksApi(self.api_key, self.api_client)
self.whitelists = WhitelistsApi(self.api_key, self.api_client)
def set_api_key(self, api_key = ''):
self.api_key = api_key
self.allowlists = AllowlistsApi(self.api_key, self.api_client)
self.exports = ExportsApi(self.api_key, self.api_client)
self.inbound = InboundApi(self.api_key, self.api_client)
self.ips = IpsApi(self.api_key, self.api_client)
self.messages = MessagesApi(self.api_key, self.api_client)
self.metadata = MetadataApi(self.api_key, self.api_client)
self.rejects = RejectsApi(self.api_key, self.api_client)
self.senders = SendersApi(self.api_key, self.api_client)
self.subaccounts = SubaccountsApi(self.api_key, self.api_client)
self.tags = TagsApi(self.api_key, self.api_client)
self.templates = TemplatesApi(self.api_key, self.api_client)
self.urls = UrlsApi(self.api_key, self.api_client)
self.users = UsersApi(self.api_key, self.api_client)
self.webhooks = WebhooksApi(self.api_key, self.api_client)
self.whitelists = WhitelistsApi(self.api_key, self.api_client)
def set_default_output_format(self, output_format):
self.api_client.set_default_output_format(output_format)
def set_timeout(self, timeout):
self.api_client.set_timeout(timeout)
|
(api_key='')
|
62,576 |
mailchimp_transactional
|
__init__
| null |
def __init__(self, api_key = ''):
self.api_key = api_key
self.api_client = ApiClient()
self.allowlists = AllowlistsApi(self.api_key, self.api_client)
self.exports = ExportsApi(self.api_key, self.api_client)
self.inbound = InboundApi(self.api_key, self.api_client)
self.ips = IpsApi(self.api_key, self.api_client)
self.messages = MessagesApi(self.api_key, self.api_client)
self.metadata = MetadataApi(self.api_key, self.api_client)
self.rejects = RejectsApi(self.api_key, self.api_client)
self.senders = SendersApi(self.api_key, self.api_client)
self.subaccounts = SubaccountsApi(self.api_key, self.api_client)
self.tags = TagsApi(self.api_key, self.api_client)
self.templates = TemplatesApi(self.api_key, self.api_client)
self.urls = UrlsApi(self.api_key, self.api_client)
self.users = UsersApi(self.api_key, self.api_client)
self.webhooks = WebhooksApi(self.api_key, self.api_client)
self.whitelists = WhitelistsApi(self.api_key, self.api_client)
|
(self, api_key='')
|
62,577 |
mailchimp_transactional
|
set_api_key
| null |
def set_api_key(self, api_key = ''):
self.api_key = api_key
self.allowlists = AllowlistsApi(self.api_key, self.api_client)
self.exports = ExportsApi(self.api_key, self.api_client)
self.inbound = InboundApi(self.api_key, self.api_client)
self.ips = IpsApi(self.api_key, self.api_client)
self.messages = MessagesApi(self.api_key, self.api_client)
self.metadata = MetadataApi(self.api_key, self.api_client)
self.rejects = RejectsApi(self.api_key, self.api_client)
self.senders = SendersApi(self.api_key, self.api_client)
self.subaccounts = SubaccountsApi(self.api_key, self.api_client)
self.tags = TagsApi(self.api_key, self.api_client)
self.templates = TemplatesApi(self.api_key, self.api_client)
self.urls = UrlsApi(self.api_key, self.api_client)
self.users = UsersApi(self.api_key, self.api_client)
self.webhooks = WebhooksApi(self.api_key, self.api_client)
self.whitelists = WhitelistsApi(self.api_key, self.api_client)
|
(self, api_key='')
|
62,578 |
mailchimp_transactional
|
set_default_output_format
| null |
def set_default_output_format(self, output_format):
self.api_client.set_default_output_format(output_format)
|
(self, output_format)
|
62,579 |
mailchimp_transactional
|
set_timeout
| null |
def set_timeout(self, timeout):
self.api_client.set_timeout(timeout)
|
(self, timeout)
|
62,580 |
mailchimp_transactional.api.exports_api
|
ExportsApi
|
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
|
class ExportsApi(object):
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
Ref: https://github.com/swagger-api/swagger-codegen
"""
def __init__(self, api_key='', api_client = None):
self.api_key = api_key
if api_client:
self.api_client = api_client
else:
self.api_client = ApiClient()
def activity(self, body = {}, **kwargs): # noqa: E501
"""Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
"""
(data) = self.activity_with_http_info(body, **kwargs) # noqa: E501
return data
def activity_with_http_info(self, body, **kwargs): # noqa: E501
"""Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method activity" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/activity', 'POST',
body=body_params,
response_type='InlineResponse2007') # noqa: E501
def allowlist(self, body = {}, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
(data) = self.allowlist_with_http_info(body, **kwargs) # noqa: E501
return data
def allowlist_with_http_info(self, body, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method allowlist" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/allowlist', 'POST',
body=body_params,
response_type='InlineResponse2006') # noqa: E501
def info(self, body = {}, **kwargs): # noqa: E501
"""View export info # noqa: E501
Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type. # noqa: E501
"""
(data) = self.info_with_http_info(body, **kwargs) # noqa: E501
return data
def info_with_http_info(self, body, **kwargs): # noqa: E501
"""View export info # noqa: E501
Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method info" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/info', 'POST',
body=body_params,
response_type='InlineResponse2003') # noqa: E501
def list(self, body = {}, **kwargs): # noqa: E501
"""List exports # noqa: E501
Returns a list of your exports. # noqa: E501
"""
(data) = self.list_with_http_info(body, **kwargs) # noqa: E501
return data
def list_with_http_info(self, body, **kwargs): # noqa: E501
"""List exports # noqa: E501
Returns a list of your exports. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method list" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/list', 'POST',
body=body_params,
response_type='list[InlineResponse2004]') # noqa: E501
def rejects(self, body = {}, **kwargs): # noqa: E501
"""Export denylist # noqa: E501
Begins an export of your rejection denylist. The denylist will be exported to a zip archive containing a single file named rejects.csv that includes the following fields: email, reason, detail, created_at, expires_at, last_event_at, expires_at. # noqa: E501
"""
(data) = self.rejects_with_http_info(body, **kwargs) # noqa: E501
return data
def rejects_with_http_info(self, body, **kwargs): # noqa: E501
"""Export denylist # noqa: E501
Begins an export of your rejection denylist. The denylist will be exported to a zip archive containing a single file named rejects.csv that includes the following fields: email, reason, detail, created_at, expires_at, last_event_at, expires_at. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method rejects" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/rejects', 'POST',
body=body_params,
response_type='InlineResponse2005') # noqa: E501
def whitelist(self, body = {}, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
(data) = self.whitelist_with_http_info(body, **kwargs) # noqa: E501
return data
def whitelist_with_http_info(self, body, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method whitelist" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/whitelist', 'POST',
body=body_params,
response_type='InlineResponse2006') # noqa: E501
|
(api_key='', api_client=None)
|
62,582 |
mailchimp_transactional.api.exports_api
|
activity
|
Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
|
def activity(self, body = {}, **kwargs): # noqa: E501
"""Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
"""
(data) = self.activity_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
62,583 |
mailchimp_transactional.api.exports_api
|
activity_with_http_info
|
Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
|
def activity_with_http_info(self, body, **kwargs): # noqa: E501
"""Export activity history # noqa: E501
Begins an export of your activity history. The activity will be exported to a zip archive containing a single file named activity.csv in the same format as you would be able to export from your account's activity view. It includes the following fields: Date, Email Address, Sender, Subject, Status, Tags, Opens, Clicks, Bounce Detail. If you have configured any custom metadata fields, they will be included in the exported data. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method activity" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/activity', 'POST',
body=body_params,
response_type='InlineResponse2007') # noqa: E501
|
(self, body, **kwargs)
|
62,584 |
mailchimp_transactional.api.exports_api
|
allowlist
|
Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
|
def allowlist(self, body = {}, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
(data) = self.allowlist_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
62,585 |
mailchimp_transactional.api.exports_api
|
allowlist_with_http_info
|
Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
|
def allowlist_with_http_info(self, body, **kwargs): # noqa: E501
"""Export Allowlist # noqa: E501
Begins an export of your rejection allowlist. The allowlist will be exported to a zip archive containing a single file named allowlist.csv that includes the following fields: email, detail, created_at. # noqa: E501
"""
all_params = ['body'] # noqa: E501
params = locals()
for key, val in six.iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method allowlist" % key
)
params[key] = val
del params['kwargs']
# add api_key to body params
params['body']['key'] = self.api_key
body_params = None
if 'body' in params:
body_params = params['body']
return self.api_client.call_api(
'/exports/allowlist', 'POST',
body=body_params,
response_type='InlineResponse2006') # noqa: E501
|
(self, body, **kwargs)
|
62,586 |
mailchimp_transactional.api.exports_api
|
info
|
View export info # noqa: E501
Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type. # noqa: E501
|
def info(self, body = {}, **kwargs): # noqa: E501
"""View export info # noqa: E501
Returns information about an export job. If the export job's state is 'complete', the returned data will include a URL you can use to fetch the results. Every export job produces a zip archive, but the format of the archive is distinct for each job type. The api calls that initiate exports include more details about the output format for that job type. # noqa: E501
"""
(data) = self.info_with_http_info(body, **kwargs) # noqa: E501
return data
|
(self, body={}, **kwargs)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.