Beispiel #1
0
    def checksum(self):
        """
        Return an MD5 checksum of this file. 

        If SELF is a directory, raise InappropriateError
        If SELF is nonexistant, raise DoesNotExistError

        Return: str
        """
        if not self:
            raise exceptions.DoesNotExistError()
        if self.is_dir:
            raise exceptions.InappropriateError()
        checksum = hashlib.md5(self.open('rb').read()).hexdigest()
        return checksum
Beispiel #2
0
    def mimetype(self):
        """
        Return a guessed mimetype for SELF.

        If SELF is a directory, raise InappropriateError
        If SELF is nonexistant, raise DoesNotExistError

        Return: str
        Exceptions: InappropriateError, DoesNotExistError
        """
        if not self:
            raise exceptions.DoesNotExistError()
        if self.is_dir:
            raise exceptions.InappropriateError()
        mime, _ = mimetypes.guess_type(str(self))
        return mime
Beispiel #3
0
 def tempdir(self):
     raise exceptions.InappropriateError("Can't tempdir() on a Read-only filesystem")
Beispiel #4
0
 def touch(self, resource):
     raise exceptions.InappropriateError("Can't touch() on a Read-only filesystem")
Beispiel #5
0
 def mv(self, resource, target):
     raise exceptions.InappropriateError("Can't mv() on a Read-only filesystem")
Beispiel #6
0
 def cd(self, target):
     raise exceptions.InappropriateError(
         "Can't cd() on an Archive filesystem")
Beispiel #7
0
 def getwd(self):
     raise exceptions.InappropriateError(
         "Can't getwd() on an Archive filesystem")
Beispiel #8
0
 def abspath(self, resource):
     raise exceptions.InappropriateError(
         "Can't is_abspath() on an Archive filesystem")
Beispiel #9
0
 def expanduser(self, resource):
     raise exceptions.InappropriateError(
         "Can't expanduser() on an Archive filesystem")
Beispiel #10
0
 def tempdir(self):
     raise exceptions.InappropriateError(
         "Can't ln() on an Archive filesystem")
Beispiel #11
0
 def ln(self, resource, target, symbolic=False):
     raise exceptions.InappropriateError(
         "Can't ln() on an Archive filesystem")