[ Avaa Bypassed ]




Upload:

Command:

www-data@18.218.241.211: ~ $
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
#
# Copyright 2011 Fabian Topfstedt <topfstedt@schneevonmorgen.com>
#
# This module is included with granted permission from the original author.
# The original source is available at http://bitbucket.org/fabian/filechunkio

import io
import os


SEEK_SET = getattr(io, u'SEEK_SET', 0)
SEEK_CUR = getattr(io, u'SEEK_CUR', 1)
SEEK_END = getattr(io, u'SEEK_END', 2)


class FileChunkIO(io.FileIO):
    u"""
    A class that allows you reading only a chunk of a file.
    """
    def __init__(self, name, mode=u'r', closefd=True, offset=0, bytes=None,
                 *args, **kwargs):
        u"""
        Open a file chunk. The mode can only be 'r' for reading. Offset
        is the amount of bytes that the chunks starts after the real file's
        first byte. Bytes defines the amount of bytes the chunk has, which you
        can set to None to include the last byte of the real file.
        """
        if not mode.startswith(u'r'):
            raise ValueError(u"Mode string must begin with 'r'")
        self.offset = offset
        self.bytes = bytes
        if bytes is None:
            self.bytes = os.stat(name).st_size - self.offset
        super(FileChunkIO, self).__init__(name, mode, closefd, *args, **kwargs)
        self.seek(0)

    def seek(self, offset, whence=SEEK_SET):
        u"""
        Move to a new chunk position.
        """
        if whence == SEEK_SET:
            super(FileChunkIO, self).seek(self.offset + offset)
        elif whence == SEEK_CUR:
            self.seek(self.tell() + offset)
        elif whence == SEEK_END:
            self.seek(self.bytes + offset)

    def tell(self):
        u"""
        Current file position.
        """
        return super(FileChunkIO, self).tell() - self.offset

    def read(self, n=-1):
        u"""
        Read and return at most n bytes.
        """
        if n >= 0:
            max_n = self.bytes - self.tell()
            n = min([n, max_n])
            return super(FileChunkIO, self).read(n)
        else:
            return self.readall()

    def readall(self):
        u"""
        Read all data from the chunk.
        """
        return self.read(self.bytes - self.tell())

    def readinto(self, b):
        u"""
        Same as RawIOBase.readinto().
        """
        data = self.read(len(b))
        n = len(data)
        try:
            b[:n] = data
        except TypeError as err:
            import array
            if not isinstance(b, array.array):
                raise err
            b[:n] = array.array(b'b', data)
        return n

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
backends Folder 0755
__init__.py File 1.08 KB 0644
_librsync.cpython-38-x86_64-linux-gnu.so File 19.99 KB 0644
asyncscheduler.py File 10.54 KB 0644
backend.py File 25.55 KB 0644
cached_ops.py File 1.64 KB 0644
commandline.py File 51.33 KB 0644
diffdir.py File 26.4 KB 0644
dup_collections.py File 45.95 KB 0644
dup_main.py File 65.43 KB 0644
dup_temp.py File 8.1 KB 0644
dup_threading.py File 8.56 KB 0644
dup_time.py File 11.37 KB 0644
errors.py File 2.66 KB 0644
file_naming.py File 16.76 KB 0644
filechunkio.py File 2.54 KB 0644
globals.py File 10.19 KB 0644
globmatch.py File 7.04 KB 0644
gpg.py File 17.3 KB 0644
gpginterface.py File 23.05 KB 0644
lazy.py File 14.5 KB 0644
librsync.py File 8.54 KB 0644
log.py File 13.07 KB 0644
manifest.py File 17.95 KB 0644
patchdir.py File 21.78 KB 0644
path.py File 27.73 KB 0644
progress.py File 13.49 KB 0644
robust.py File 2.42 KB 0644
selection.py File 21.82 KB 0644
statistics.py File 13.15 KB 0644
tarfile.py File 1.26 KB 0644
tempdir.py File 10.55 KB 0644
util.py File 8.42 KB 0644