Search is not available for this dataset
text stringlengths 75 104k |
|---|
def from_value(cls, ion_type, value, annotations=()):
"""Constructs a value as a copy with an associated Ion type and annotations.
Args:
ion_type (IonType): The associated Ion type.
value (Any): The value to construct from, generally of type ``cls``.
annotations (Seq... |
def to_event(self, event_type, field_name=None, depth=None):
"""Constructs an IonEvent from this _IonNature value.
Args:
event_type (IonEventType): The type of the resulting event.
field_name (Optional[text]): The field name associated with this value, if any.
depth ... |
def bytes_to_long(s):
"""bytes_to_long(string) : long
Convert a byte string to a long integer.
This is (essentially) the inverse of long_to_bytes().
"""
if isinstance(s, int):
# On Python 2, indexing into a bytearray returns a byte string; on Python 3, an int.
return s
acc = 0
... |
def long_to_bytes(n, blocksize=0):
"""long_to_bytes(n:long, blocksize:int) : string
Convert a long integer to a byte string.
If optional blocksize is given and greater than zero, pad the front of the
byte string with binary zeros so that the length is a multiple of
blocksize.
"""
# after mu... |
def raw_p_sha1(secret, seed, sizes=()):
"""
Derive one or more keys from secret and seed.
(See specs part 6, 6.7.5 and RFC 2246 - TLS v1.0)
Lengths of keys will match sizes argument
Source: https://github.com/FreeOpcUa/python-opcua
key_sizes = (signature_key_size, symmetric_key_size, 16)
(s... |
def verify_x509_cert_chain(cert_chain, ca_pem_file=None, ca_path=None):
"""
Look at certs in the cert chain and add them to the store one by one.
Return the cert at the end of the chain. That is the cert to be used by the caller for verifying.
From https://www.w3.org/TR/xmldsig-core2/#sec-X509Data:
... |
def _remove_sig(signature, idempotent=False):
"""
Remove the signature node from its parent, keeping any tail element.
This is needed for eneveloped signatures.
:param signature: Signature to remove from payload
:type signature: XML ElementTree Element
:param idempotent:
If True, don't ... |
def sign(self, data, key=None, passphrase=None, cert=None, reference_uri=None, key_name=None, key_info=None,
id_attribute=None):
"""
Sign the data and return the root element of the resulting XML tree.
:param data: Data to sign
:type data: String, file-like object, or XML E... |
def verify(self, data, require_x509=True, x509_cert=None, cert_subject_name=None, ca_pem_file=None, ca_path=None,
hmac_key=None, validate_schema=True, parser=None, uri_resolver=None, id_attribute=None,
expect_references=1):
"""
Verify the XML signature supplied in the data ... |
def authorize(self, scope=None, redirect_uri=None, state=None):
"""
Redirect to GitHub and request access to a user's data.
:param scope: List of `Scopes`_ for which to request access, formatted
as a string or comma delimited list of scopes as a
strin... |
def authorized_handler(self, f):
"""
Decorator for the route that is used as the callback for authorizing
with GitHub. This callback URL can be set in the settings for the app
or passed in during authorization.
"""
@wraps(f)
def decorated(*args, **kwargs):
... |
def _handle_response(self):
"""
Handles response after the redirect to GitHub. This response
determines if the user has allowed the this application access. If we
were then we send a POST request for the access_key used to
authenticate requests to GitHub.
"""
_lo... |
def raw_request(self, method, resource, access_token=None, **kwargs):
"""
Makes a HTTP request and returns the raw
:class:`~requests.Response` object.
"""
headers = self._pop_headers(kwargs)
headers['Authorization'] = self._get_authorization_header(access_token)
... |
def request(self, method, resource, all_pages=False, **kwargs):
"""
Makes a request to the given endpoint.
Keyword arguments are passed to the :meth:`~requests.request` method.
If the content type of the response is JSON, it will be decoded
automatically and a dictionary will be ... |
def get(self, resource, params=None, **kwargs):
"""Shortcut for ``request('GET', resource)``."""
return self.request('GET', resource, params=params, **kwargs) |
def post(self, resource, data=None, **kwargs):
"""Shortcut for ``request('POST', resource)``.
Use this to make POST request since it will also encode ``data`` to
'application/json' format."""
headers = dict(kwargs.pop('headers', {}))
headers.setdefault('Content-Type', 'applicatio... |
def decode_lazy(rlp, sedes=None, **sedes_kwargs):
"""Decode an RLP encoded object in a lazy fashion.
If the encoded object is a bytestring, this function acts similar to
:func:`rlp.decode`. If it is a list however, a :class:`LazyList` is
returned instead. This object will decode the string lazily, avoi... |
def consume_item_lazy(rlp, start):
"""Read an item from an RLP string lazily.
If the length prefix announces a string, the string is read; if it
announces a list, a :class:`LazyList` is created.
:param rlp: the rlp string to read from
:param start: the position at which to start reading
:retur... |
def peek(rlp, index, sedes=None):
"""Get a specific element from an rlp encoded nested list.
This function uses :func:`rlp.decode_lazy` and, thus, decodes only the
necessary parts of the string.
Usage example::
>>> import rlp
>>> rlpdata = rlp.encode([1, 2, [3, [4, 5]]])
>>> r... |
def fixed_length(cls, l, allow_empty=False):
"""Create a sedes for text data with exactly `l` encoded characters."""
return cls(l, l, allow_empty=allow_empty) |
def _eq(left, right):
"""
Equality comparison that allows for equality between tuple and list types
with equivalent elements.
"""
if isinstance(left, (tuple, list)) and isinstance(right, (tuple, list)):
return len(left) == len(right) and all(_eq(*pair) for pair in zip(left, right))
else:... |
def is_sequence(obj):
"""Check if `obj` is a sequence, but not a string or bytes."""
return isinstance(obj, Sequence) and not (
isinstance(obj, str) or BinaryClass.is_valid_type(obj)) |
def encode(obj, sedes=None, infer_serializer=True, cache=True):
"""Encode a Python object in RLP format.
By default, the object is serialized in a suitable way first (using
:func:`rlp.infer_sedes`) and then encoded. Serialization can be explicitly
suppressed by setting `infer_serializer` to ``False`` a... |
def encode_raw(item):
"""RLP encode (a nested sequence of) :class:`Atomic`s."""
if isinstance(item, Atomic):
if len(item) == 1 and item[0] < 128:
return item
payload = item
prefix_offset = 128 # string
elif not isinstance(item, str) and isinstance(item, collections.Seque... |
def length_prefix(length, offset):
"""Construct the prefix to lists or strings denoting their length.
:param length: the length of the item in bytes
:param offset: ``0x80`` when encoding raw bytes, ``0xc0`` when encoding a
list
"""
if length < 56:
return ALL_BYTES[offset ... |
def consume_length_prefix(rlp, start):
"""Read a length prefix from an RLP string.
:param rlp: the rlp byte string to read from
:param start: the position at which to start reading
:returns: a tuple ``(prefix, type, length, end)``, where ``type`` is either ``str``
or ``list`` depending on... |
def consume_payload(rlp, prefix, start, type_, length):
"""Read the payload of an item from an RLP string.
:param rlp: the rlp string to read from
:param type_: the type of the payload (``bytes`` or ``list``)
:param start: the position at which to start reading
:param length: the length of the payl... |
def consume_item(rlp, start):
"""Read an item from an RLP string.
:param rlp: the rlp string to read from
:param start: the position at which to start reading
:returns: a tuple ``(item, per_item_rlp, end)``, where ``item`` is
the read item, per_item_rlp is a list containing the RLP
... |
def decode(rlp, sedes=None, strict=True, recursive_cache=False, **kwargs):
"""Decode an RLP encoded object.
If the deserialized result `obj` has an attribute :attr:`_cached_rlp` (e.g. if `sedes` is a
subclass of :class:`rlp.Serializable`) it will be set to `rlp`, which will improve performance
on subse... |
def infer_sedes(obj):
"""Try to find a sedes objects suitable for a given Python object.
The sedes objects considered are `obj`'s class, `big_endian_int` and
`binary`. If `obj` is a sequence, a :class:`rlp.sedes.List` will be
constructed recursively.
:param obj: the python object for which to find... |
def destinations(self, cluster='main'):
"""Return a list of destinations for a cluster."""
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
destinations = self.config.get(cluster, 'd... |
def replication_factor(self, cluster='main'):
"""Return the replication factor for a cluster as an integer."""
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
return int(self.config... |
def ssh_user(self, cluster='main'):
"""Return the ssh user for a cluster or current user if undefined."""
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
try:
return sel... |
def whisper_lock_writes(self, cluster='main'):
"""Lock whisper files during carbon-sync."""
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
try:
return bool(self.config.... |
def hashing_type(self, cluster='main'):
"""Hashing type of cluster."""
if not self.config.has_section(cluster):
raise SystemExit("Cluster '%s' not defined in %s"
% (cluster, self.config_file))
hashing_type = 'carbon_ch'
try:
return sel... |
def fill_archives(src, dst, startFrom, endAt=0, overwrite=False,
lock_writes=False):
"""
Fills gaps in dst using data from src.
src is the path as a string
dst is the path as a string
startFrom is the latest timestamp (archives are read backward)
endAt is the earliest timestam... |
def data(path, hours, offset=0):
"""
Does the metric at ``path`` have any whisper data newer than ``hours``?
If ``offset`` is not None, view the ``hours`` prior to ``offset`` hours
ago, instead of from right now.
"""
now = time.time()
end = now - _to_sec(offset) # Will default to now
s... |
def stat(path, hours, offset=None):
"""
Has the metric file at ``path`` been modified since ``hours`` ago?
.. note::
``offset`` is only for compatibility with ``data()`` and is ignored.
"""
return os.stat(path).st_mtime < (time.time() - _to_sec(hours)) |
def short_path(path, cwd=None):
"""
Return relative or absolute path name, whichever is shortest.
"""
if not isinstance(path, str):
return path
if cwd is None:
cwd = os.getcwd()
abspath = os.path.abspath(path)
relpath = os.path.relpath(path, cwd)
if len(abspath) <= len(re... |
def get_all_dict(module):
"""Return a copy of the __all__ dict with irrelevant items removed."""
if hasattr(module, "__all__"):
all_dict = copy.deepcopy(module.__all__)
else:
all_dict = copy.deepcopy(dir(module))
all_dict = [name for name in all_dict
if not name.s... |
def compare(all_dict, others, names, module_name):
"""Return sets of objects only in __all__, refguide, or completely missing."""
only_all = set()
for name in all_dict:
if name not in names:
only_all.add(name)
only_ref = set()
missing = set()
for name in names:
if na... |
def check_rest(module, names, dots=True):
"""
Check reStructuredText formatting of docstrings
Returns: [(name, success_flag, output), ...]
"""
try:
skip_types = (dict, str, unicode, float, int)
except NameError:
# python 3
skip_types = (dict, str, float, int)
resul... |
def update_header(self):
"""
Updates header to edffile struct
"""
set_technician(self.handle, du(self.technician))
set_recording_additional(self.handle, du(self.recording_additional))
set_patientname(self.handle, du(self.patient_name))
set_patientcode(self.handle,... |
def setHeader(self, fileHeader):
"""
Sets the file header
"""
self.technician = fileHeader["technician"]
self.recording_additional = fileHeader["recording_additional"]
self.patient_name = fileHeader["patientname"]
self.patient_additional = fileHeader["patient_addi... |
def setSignalHeader(self, edfsignal, channel_info):
"""
Sets the parameter for signal edfsignal.
channel_info should be a dict with
these values:
'label' : channel label (string, <= 16 characters, must be unique)
'dimension' : physical dimension (e.g., mV) (stri... |
def setSignalHeaders(self, signalHeaders):
"""
Sets the parameter for all signals
Parameters
----------
signalHeaders : array_like
containing dict with
'label' : str
channel label (string, <= 16 characters, must be unique)
... |
def set_number_of_annotation_signals(self, number_of_annotations):
"""
Sets the number of annotation signals. The default value is 1
This function is optional and can be called only after opening a file in writemode
and before the first sample write action
Normally you don't need... |
def setStartdatetime(self, recording_start_time):
"""
Sets the recording start Time
Parameters
----------
recording_start_time: datetime object
Sets the recording start Time
"""
if isinstance(recording_start_time,datetime):
self.recording_... |
def setSamplefrequency(self, edfsignal, samplefrequency):
"""
Sets the samplefrequency of signal edfsignal.
Notes
-----
This function is required for every signal and can be called only after opening a file in writemode and before the first sample write action.
"""
... |
def setPhysicalMaximum(self, edfsignal, physical_maximum):
"""
Sets the physical_maximum of signal edfsignal.
Parameters
----------
edfsignal: int
signal number
physical_maximum: float
Sets the physical maximum
Notes
-----
... |
def setPhysicalMinimum(self, edfsignal, physical_minimum):
"""
Sets the physical_minimum of signal edfsignal.
Parameters
----------
edfsignal: int
signal number
physical_minimum: float
Sets the physical minimum
Notes
-----
... |
def setDigitalMaximum(self, edfsignal, digital_maximum):
"""
Sets the samplefrequency of signal edfsignal.
Usually, the value 32767 is used for EDF+ and 8388607 for BDF+.
Parameters
----------
edfsignal : int
signal number
digital_maximum : int
... |
def setDigitalMinimum(self, edfsignal, digital_minimum):
"""
Sets the minimum digital value of signal edfsignal.
Usually, the value -32768 is used for EDF+ and -8388608 for BDF+. Usually this will be (-(digital_maximum + 1)).
Parameters
----------
edfsignal : int
... |
def setLabel(self, edfsignal, label):
"""
Sets the label (name) of signal edfsignal ("FP1", "SaO2", etc.).
Parameters
----------
edfsignal : int
signal number on which the label should be changed
label : str
signal label
Notes
---... |
def setPhysicalDimension(self, edfsignal, physical_dimension):
"""
Sets the physical dimension of signal edfsignal ("uV", "BPM", "mA", "Degr.", etc.)
:param edfsignal: int
:param physical_dimension: str
Notes
-----
This function is recommended for every signal a... |
def setTransducer(self, edfsignal, transducer):
"""
Sets the transducer of signal edfsignal
:param edfsignal: int
:param transducer: str
Notes
-----
This function is optional for every signal and can be called only after opening a file in writemode and before th... |
def setPrefilter(self, edfsignal, prefilter):
"""
Sets the prefilter of signal edfsignal ("HP:0.1Hz", "LP:75Hz N:50Hz", etc.)
:param edfsignal: int
:param prefilter: str
Notes
-----
This function is optional for every signal and can be called only after opening ... |
def writeSamples(self, data_list, digital = False):
"""
Writes physical samples (uV, mA, Ohm) from data belonging to all signals
The physical samples will be converted to digital samples using the values
of physical maximum, physical minimum, digital maximum and digital minimum.
... |
def writeAnnotation(self, onset_in_seconds, duration_in_seconds, description, str_format='utf-8'):
"""
Writes an annotation/event to the file
"""
if str_format == 'utf-8':
if duration_in_seconds >= 0:
return write_annotation_utf8(self.handle, np.round(onset_in... |
def readAnnotations(self):
"""
Annotations from a edf-file
Parameters
----------
None
"""
annot = self.read_annotation()
annot = np.array(annot)
if (annot.shape[0] == 0):
return np.array([]), np.array([]), np.array([])
ann_time... |
def getHeader(self):
"""
Returns the file header as dict
Parameters
----------
None
"""
return {"technician": self.getTechnician(), "recording_additional": self.getRecordingAdditional(),
"patientname": self.getPatientName(), "patient_additional": ... |
def getSignalHeader(self, chn):
"""
Returns the header of one signal as dicts
Parameters
----------
None
"""
return {'label': self.getLabel(chn),
'dimension': self.getPhysicalDimension(chn),
'sample_rate': self.g... |
def getSignalHeaders(self):
"""
Returns the header of all signals as array of dicts
Parameters
----------
None
"""
signalHeader = []
for chn in np.arange(self.signals_in_file):
signalHeader.append(self.getSignalHeader(chn))
return sig... |
def getStartdatetime(self):
"""
Returns the date and starttime as datetime object
Parameters
----------
None
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getStartdatetime()
datetime.datetime(2... |
def getBirthdate(self, string=True):
"""
Returns the birthdate as string object
Parameters
----------
None
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getBirthdate()=='30 jun 1969'
True
... |
def getSampleFrequencies(self):
"""
Returns samplefrequencies of all signals.
Parameters
----------
None
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> all(f.getSampleFrequencies()==200.0)
True
... |
def getSampleFrequency(self,chn):
"""
Returns the samplefrequency of signal edfsignal.
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getSample... |
def getSignalLabels(self):
"""
Returns all labels (name) ("FP1", "SaO2", etc.).
Parameters
----------
None
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getSignalLabels()==['squarewave', 'ramp', 'pulse... |
def getLabel(self,chn):
"""
Returns the label (name) of signal chn ("FP1", "SaO2", etc.).
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> f.getLab... |
def getPrefilter(self,chn):
"""
Returns the prefilter of signal chn ("HP:0.1Hz", "LP:75Hz N:50Hz", etc.)
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
... |
def getPhysicalMaximum(self,chn=None):
"""
Returns the maximum physical value of signal edfsignal.
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>>... |
def getPhysicalMinimum(self,chn=None):
"""
Returns the minimum physical value of signal edfsignal.
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>>... |
def getDigitalMaximum(self, chn=None):
"""
Returns the maximum digital value of signal edfsignal.
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> ... |
def getDigitalMinimum(self, chn=None):
"""
Returns the minimum digital value of signal edfsignal.
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
>>> ... |
def getTransducer(self, chn):
"""
Returns the transducer of signal chn ("AgAgCl cup electrodes", etc.).
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.test_generator()
... |
def getPhysicalDimension(self, chn):
"""
Returns the physical dimension of signal edfsignal ("uV", "BPM", "mA", "Degr.", etc.)
Parameters
----------
chn : int
channel number
Examples
--------
>>> import pyedflib
>>> f = pyedflib.data.... |
def readSignal(self, chn, start=0, n=None):
"""
Returns the physical data of signal chn. When start and n is set, a subset is returned
Parameters
----------
chn : int
channel number
start : int
start pointer (default is 0)
n : int
... |
def file_info_long(self):
"""
Returns information about the opened EDF/BDF file
"""
self.file_info()
for ii in np.arange(self.signals_in_file):
print("label:", self.getSignalLabels()[ii], "fs:",
self.getSampleFrequencies()[ii], "nsamples",
... |
def stackplot(marray, seconds=None, start_time=None, ylabels=None):
"""
will plot a stack of traces one above the other assuming
marray.shape = numRows, numSamples
"""
tarray = np.transpose(marray)
stackplot_t(tarray, seconds=seconds, start_time=start_time, ylabels=ylabels)
plt.show() |
def stackplot_t(tarray, seconds=None, start_time=None, ylabels=None):
"""
will plot a stack of traces one above the other assuming
tarray.shape = numSamples, numRows
"""
data = tarray
numSamples, numRows = tarray.shape
# data = np.random.randn(numSamples,numRows) # test data
# data.shape = numS... |
def subcmd_list_parser(subcmd):
""" list subcommand """
subcmd.add_argument(
'--broker',
action='store',
dest='broker',
help=u'Route to the Ansible Service Broker'
)
subcmd.add_argument(
'--secure',
action='store_true',
dest='verify',
help=... |
def subcmd_build_parser(subcmd):
""" build subcommand """
subcmd.add_argument(
'--tag',
action='store',
dest='tag',
help=u'Tag of APB to build (ie. mysql-apb or docker.io/username/mysql-apb)'
)
subcmd.add_argument(
'--dockerfile',
'-f',
action='st... |
def subcmd_init_parser(subcmd):
""" init subcommand """
subcmd.add_argument(
'tag',
action='store',
help=u'Tag (org/name) or name of APB to initialize'
)
subcmd.add_argument(
'--force',
action='store_true',
dest='force',
help=u'Force re-init on cu... |
def subcmd_prepare_parser(subcmd):
""" prepare subcommand """
subcmd.add_argument(
'--provider',
action='store',
dest='provider',
help=u'Targeted cluster type',
choices=['openshift', 'kubernetes'],
default='openshift'
)
subcmd.add_argument(
'--doc... |
def subcmd_push_parser(subcmd):
""" push subcommand """
subcmd.add_argument(
'--broker',
action='store',
dest='broker',
help=u'Route to the Ansible Service Broker'
)
subcmd.add_argument(
'--registry-service-name',
action='store',
dest='reg_svc_name... |
def subcmd_remove_parser(subcmd):
""" remove subcommand """
subcmd.add_argument(
'--broker',
action='store',
dest='broker',
help=u'Route to the Ansible Service Broker'
)
subcmd.add_argument(
'--local', '-l',
action='store_true',
dest='local',
... |
def subcmd_bootstrap_parser(subcmd):
""" bootstrap subcommand """
subcmd.add_argument(
'--broker',
action='store',
dest='broker',
help=u'Route to the Ansible Service Broker'
)
subcmd.add_argument(
'--secure',
action='store_true',
dest='verify',
... |
def subcmd_run_parser(subcmd):
""" provision subcommand """
subcmd.add_argument(
'--project',
action='store',
dest='project',
required=True,
help=u'Project where the APB should be run'
)
subcmd.add_argument(
'--action',
action='store',
dest... |
def subcmd_relist_parser(subcmd):
""" relist subcommand """
subcmd.add_argument(
'--broker-name',
action='store',
dest='broker_name',
help=u'Name of the ServiceBroker k8s resource',
default=u'ansible-service-broker'
)
subcmd.add_argument(
'--secure',
... |
def main():
""" main """
# BZ 1581651 - Override the ArgumentParser to disable argument abbreviations.
parser = OverrideArgumentParser(
description=u'APB tooling for '
u'assisting in building and packaging APBs.'
)
parser.add_argument(
'--debug',
action='store_true',... |
def find_path(start, goal, neighbors_fnct, reversePath=False, heuristic_cost_estimate_fnct=lambda a, b: Infinite, distance_between_fnct=lambda a, b: 1.0, is_goal_reached_fnct=lambda a, b: a == b):
"""A non-class version of the path finding algorithm"""
class FindPath(AStar):
def heuristic_cost_estimate... |
def preset(name):
"""https://github.com/frictionlessdata/goodtables-py#custom-presets
"""
def decorator(func):
registry.register_preset(func, name)
return func
return decorator |
def check(name, type=None, context=None, position=None):
"""https://github.com/frictionlessdata/goodtables-py#custom-checks
"""
def decorator(func):
registry.register_check(func, name, type, context, position)
return func
return decorator |
def validate(source, **options):
"""Validates a source file and returns a report.
Args:
source (Union[str, Dict, List[Dict], IO]): The source to be validated.
It can be a local file path, URL, dict, list of dicts, or a
file-like object. If it's a list of dicts and the `preset` i... |
def init_datapackage(resource_paths):
"""Create tabular data package with resources.
It will also infer the tabular resources' schemas.
Args:
resource_paths (List[str]): Paths to the data package resources.
Returns:
datapackage.Package: The data package.
"""
dp = datapackage.P... |
def init(paths, output, **kwargs):
"""Init data package from list of files.
It will also infer tabular data's schemas from their contents.
"""
dp = goodtables.init_datapackage(paths)
click.secho(
json_module.dumps(dp.descriptor, indent=4),
file=output
)
exit(dp.valid) |
def _clean_empty(d):
"""Remove None values from a dict."""
if not isinstance(d, (dict, list)):
return d
if isinstance(d, list):
return [v for v in (_clean_empty(v) for v in d) if v is not None]
return {
k: v for k, v in
((k, _clean_empty(v)) for k, v in d.items())
... |
def inspect(self, source, preset=None, **options):
"""https://github.com/frictionlessdata/goodtables-py#inspector
"""
# Start timer
start = datetime.datetime.now()
# Prepare preset
preset = self.__get_source_preset(source, preset)
if preset == 'nested':
... |
def create_cells(headers, schema_fields, values=None, row_number=None):
"""Create list of cells from headers, fields and values.
Args:
headers (List[str]): The headers values.
schema_fields (List[tableschema.field.Field]): The tableschema
fields.
values (List[Any], optional)... |
def __impl_read_chain(self, start, read_sector_f, read_fat_f):
"""Returns the entire contents of a chain starting at the given sector."""
sector = start
check = [ sector ] # keep a list of sectors we've already read
buffer = StringIO()
while sector != ENDOFCHAIN:
buff... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.