示例#1
0
    def scan(self):
        """
Scan over objects of a collection like a directory.

:return: (list) Child VFS objects
:since:  v1.0.0
        """

        if (self.file_path_name is not None): raise OperationNotSupportedException("VFS object can not be scanned")
        if (self.dir_path_name is None): raise IOException("VFS object not opened")

        _return = [ ]

        entry_list = os.listdir(self.dir_path_name)
        entry_list.sort()

        dir_path_url = self.url

        for entry in entry_list:
            if (entry[0] != "."):
                vfs_child_object = Object()

                try:
                    vfs_child_object.open("{0}/{1}".format(dir_path_url, entry), self.object_readonly)
                    _return.append(vfs_child_object)
                except IOException as handled_exception: LogLine.error(handled_exception, context = "dpt_vfs")
            #
        #

        return _return
示例#2
0
    def get_class(scheme):
        """
Returns an VFS watcher class for the given scheme.

:return: (object) VFS watcher class
:since:  v1.0.0
        """

        with WatcherImplementation._lock:
            if (WatcherImplementation._is_disabled):
                raise OperationNotSupportedException(
                    "VFS watcher creation has been disabled")

            _return = WatcherImplementation._classes.get(scheme)

            if (_return is None):
                _return = NamedClassLoader.get_class_in_namespace(
                    "dpt_vfs", "{0}.Watcher".format(scheme.replace("-", "_")))

                if (issubclass(_return, AbstractWatcher)):
                    WatcherImplementation._classes[scheme] = _return
                else:
                    _return = None
            #
        #

        if (_return is None):
            raise IOException(
                "VFS watcher not defined for URL scheme '{0}'".format(scheme))

        return _return
示例#3
0
    def flush(self):
        """
python.org: Flush the write buffers of the stream if applicable.

:since: v1.0.0
        """

        raise OperationNotSupportedException()
示例#4
0
    def tell(self):
        """
python.org: Return the current stream position as an opaque number.

:return: (int) Stream position
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#5
0
    def scan(self):
        """
Scan over objects of a collection like a directory.

:return: (list) Child VFS objects
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#6
0
    def time_updated(self):
        """
Returns the UNIX timestamp this object was updated.

:return: (int) UNIX timestamp this object was updated
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#7
0
    def name(self):
        """
Returns the name of this VFS object.

:return: (str) VFS object name
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#8
0
    def is_eof(self):
        """
Checks if the pointer is at EOF.

:return: (bool) True on success
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#9
0
    def truncate(self, new_size):
        """
python.org: Resize the stream to the given size in bytes.

:param new_size: Cut file at the given byte position

:return: (int) New file size
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#10
0
    def seek(self, offset):
        """
python.org: Change the stream position to the given byte offset.

:param offset: Seek to the given offset

:return: (int) Return the new absolute position.
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#11
0
    def new(self, _type, vfs_url):
        """
Creates a new VFS object.

:param _type: VFS object type
:param vfs_url: VFS URL

:since: v1.0.0
        """

        raise OperationNotSupportedException()
示例#12
0
    def new(self, _type, vfs_url):
        """
Creates a new VFS object.

:param _type: VFS object type
:param vfs_url: VFS URL

:since: v1.0.0
        """

        if (_type == Object.TYPE_DIRECTORY): self._new_directory(vfs_url)
        elif (_type == Object.TYPE_FILE): self._new_file(vfs_url)
        else: raise OperationNotSupportedException()
示例#13
0
    def write(self, b, timeout=-1):
        """
python.org: Write the given bytes or bytearray object, b, to the underlying
raw stream and return the number of bytes written.

:param b: (Over)write file with the given data at the current position
:param timeout: Timeout to use (defaults to construction time value)

:return: (int) Number of bytes written
:since:  v1.0.0
        """

        raise OperationNotSupportedException()
示例#14
0
    def read(self, n=0, timeout=-1):
        """
python.org: Read up to n bytes from the object and return them.

:param n: How many bytes to read from the current position (0 means until
          EOF)
:param timeout: Timeout to use (if supported by implementation)

:return: (bytes) Data; None if EOF
:since:  v1.0.0
        """

        raise OperationNotSupportedException()