~ubuntu-branches/debian/sid/grip/sid

« back to all changes in this revision

Viewing changes to grip/exceptions.py

  • Committer: Package Import Robot
  • Author(s): Tiago Ilieve
  • Date: 2016-04-04 14:26:23 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20160404142623-zw16rooy7z3xadvu
Tags: 4.1.0-1
Initial release (Closes: #790611)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import errno
 
2
try:
 
3
    NotFoundError = FileNotFoundError
 
4
except NameError:
 
5
    NotFoundError = IOError
 
6
 
 
7
 
 
8
class AlreadyRunningError(RuntimeError):
 
9
    pass
 
10
 
 
11
 
 
12
class ReadmeNotFoundError(NotFoundError):
 
13
    """
 
14
    This class inherits from FileNotFoundError on Python 3 and above.
 
15
    """
 
16
    def __init__(self, path=None, message=None):
 
17
        self.path = path
 
18
        self.message = message
 
19
        super(ReadmeNotFoundError, self).__init__(
 
20
            errno.ENOENT, 'README not found', path)
 
21
 
 
22
    def __repr__(self):
 
23
        return '{0}({!r}, {!r})'.format(
 
24
            type(self).__name__, self.path, self.message)
 
25
 
 
26
    def __str__(self):
 
27
        if self.message:
 
28
            return self.message
 
29
 
 
30
        if self.path is not None:
 
31
            return 'No README found at {0}'.format(self.path)
 
32
 
 
33
        return self.strerror