Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __call__(self, arg):
bytes, origin = arg
source = uproot.source.source.Source(bytes)
cursor = uproot.source.cursor.Cursor(0, origin=origin)
return self.cls.read(source, cursor, self.context, None)
def __repr__(self):
def __call__(self, arg):
bytes, origin = arg
source = uproot.source.source.Source(bytes)
cursor = uproot.source.cursor.Cursor(0, origin=origin)
return self.cls.read(source, cursor, self.context, None)
def __repr__(self):
#!/usr/bin/env python
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE
from __future__ import absolute_import
import os.path
import re
import multiprocessing
import sys
import numpy
import uproot.source.chunked
class HTTPSource(uproot.source.chunked.ChunkedSource):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (uproot.source.chunked.ChunkedSource.__metaclass__,), {})
def __init__(self, path, auth=None, *args, **kwds):
super(HTTPSource, self).__init__(path, *args, **kwds)
self._size = None
self.auth = auth
defaults = {"chunkbytes": 1024**2, "limitbytes": 100*1024**2, "parallel": 8*multiprocessing.cpu_count() if sys.version_info[0] > 2 else 1}
def _open(self):
try:
import requests
except ImportError:
raise ImportError("Install requests package (for HTTP) with:\n pip install requests\nor\n conda install -c anaconda requests")
#!/usr/bin/env python
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE
from __future__ import absolute_import
import os
import threading
import numpy
import uproot.source.chunked
class XRootDSource(uproot.source.chunked.ChunkedSource):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (uproot.source.chunked.ChunkedSource.__metaclass__,), {})
def __init__(self, path, timeout=None, *args, **kwds):
self._size = None
self.timeout = timeout
super(XRootDSource, self).__init__(path, *args, **kwds)
defaults = {"timeout": None, "chunkbytes": 1024**2, "limitbytes": 100*1024**2, "parallel": False}
def _open(self):
try:
os.environ["XRD_RUNFORKHANDLER"] = "1" # To make uproot + xrootd + multiprocessing work
import pyxrootd.client
except ImportError:
raise ImportError("Install pyxrootd package with:\n conda install -c conda-forge xrootd\n(or download from http://xrootd.org/dload.html and manually compile with cmake; setting PYTHONPATH and LD_LIBRARY_PATH appropriately).")
#!/usr/bin/env python
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE
from __future__ import absolute_import
import os.path
import numpy
import uproot.source.source
class MemmapSource(uproot.source.source.Source):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (uproot.source.source.Source.__metaclass__,), {})
defaults = {}
def __init__(self, path):
self.path = os.path.expanduser(path)
self._source = numpy.memmap(self.path, dtype=numpy.uint8, mode="r")
def parent(self):
return self
def size(self):
return len(self._source)
def threadlocal(self):
def localsource(path):
return uproot.source.file.FileSource(path, chunkbytes=8*1024, limitbytes=None)
return _schema(uproot.open(path, localsource=localsource)[treepath], namespace=namespace)
def localsource(path):
return uproot.source.file.FileSource(path, chunkbytes=8*1024, limitbytes=None)
#!/usr/bin/env python
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE
from __future__ import absolute_import
import os
import threading
import numpy
import uproot.source.chunked
class XRootDSource(uproot.source.chunked.ChunkedSource):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (uproot.source.chunked.ChunkedSource.__metaclass__,), {})
def __init__(self, path, timeout=None, *args, **kwds):
self._size = None
self.timeout = timeout
super(XRootDSource, self).__init__(path, *args, **kwds)
defaults = {"timeout": None, "chunkbytes": 1024**2, "limitbytes": 100*1024**2, "parallel": False}
def _open(self):
try:
os.environ["XRD_RUNFORKHANDLER"] = "1" # To make uproot + xrootd + multiprocessing work
import pyxrootd.client
except ImportError:
raise ImportError("Install pyxrootd package with:\n conda install -c conda-forge xrootd\n(or download from http://xrootd.org/dload.html and manually compile with cmake; setting PYTHONPATH and LD_LIBRARY_PATH appropriately).")
if self._source is None or not self._source.is_open():
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os.path
import numpy
import uproot.source.chunked
class FileSource(uproot.source.chunked.ChunkedSource):
# makes __doc__ attribute mutable before Python 3.3
__metaclass__ = type.__new__(type, "type", (uproot.source.chunked.ChunkedSource.__metaclass__,), {})
defaults = {"chunkbytes": 8*1024, "limitbytes": 1024**2}
def __init__(self, path, *args, **kwds):
self._size = None
self._parallel = kwds["parallel"]
super(FileSource, self).__init__(os.path.expanduser(path), *args, **kwds)
def size(self):
if self._size is None:
self._size = os.path.getsize(self.path)
return self._size
def threadlocal(self):
chunkbytes : int or string matching number + /[kMGTPEZY]?B/i
number of bytes per chunk.
limitbytes : int or string matching number + /[kMGTPEZY]?B/i
maximum number of bytes to keep in the cache.
Notes
-----
{see2}
""".format(**source_fragments)
_method(uproot.source.xrootd.XRootDSource.parent).__doc__ = source_fragments["see1"]
_method(uproot.source.xrootd.XRootDSource.threadlocal).__doc__ = source_fragments["see1"]
_method(uproot.source.xrootd.XRootDSource.dismiss).__doc__ = source_fragments["see1"]
_method(uproot.source.xrootd.XRootDSource.data).__doc__ = source_fragments["see1"]
################################################################ uproot.source.compressed.Compression
uproot.source.compressed.Compression.__doc__ = \
u"""Describe the compression of a compressed block.
**Attributes, properties, and methods:**
- **algo** (*int*) algorithm code.
- **level** (*int*) 0 is no compression, 1 is least, 9 is most.
- **algoname** (*str*) algorithm expressed as a string: ``"zlib"``, ``"lzma"``, ``"old"``, ``"lz4"`` or ``"zstd"``.
- **copy(algo=None, level=None)** copy this :py:class:`Compression ` object, possibly changing a field.
- **decompress(source, cursor, compressedbytes, uncompressedbytes)** decompress data from **source** at **cursor**, knowing the compressed and uncompressed size.
Parameters
----------