Esempio n. 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
Esempio n. 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
Esempio n. 3
0
 def tempdir(self):
     raise exceptions.InappropriateError("Can't tempdir() on a Read-only filesystem")
Esempio n. 4
0
 def touch(self, resource):
     raise exceptions.InappropriateError("Can't touch() on a Read-only filesystem")
Esempio n. 5
0
 def mv(self, resource, target):
     raise exceptions.InappropriateError("Can't mv() on a Read-only filesystem")
Esempio n. 6
0
 def cd(self, target):
     raise exceptions.InappropriateError(
         "Can't cd() on an Archive filesystem")
Esempio n. 7
0
 def getwd(self):
     raise exceptions.InappropriateError(
         "Can't getwd() on an Archive filesystem")
Esempio n. 8
0
 def abspath(self, resource):
     raise exceptions.InappropriateError(
         "Can't is_abspath() on an Archive filesystem")
Esempio n. 9
0
 def expanduser(self, resource):
     raise exceptions.InappropriateError(
         "Can't expanduser() on an Archive filesystem")
Esempio n. 10
0
 def tempdir(self):
     raise exceptions.InappropriateError(
         "Can't ln() on an Archive filesystem")
Esempio n. 11
0
 def ln(self, resource, target, symbolic=False):
     raise exceptions.InappropriateError(
         "Can't ln() on an Archive filesystem")