Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/xdg/Exceptions.py: 55%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

44 statements  

1""" 

2Exception Classes for the xdg package 

3""" 

4 

5debug = False 

6 

7class Error(Exception): 

8 """Base class for exceptions defined here.""" 

9 def __init__(self, msg): 

10 self.msg = msg 

11 Exception.__init__(self, msg) 

12 def __str__(self): 

13 return self.msg 

14 

15class ValidationError(Error): 

16 """Raised when a file fails to validate. 

17  

18 The filename is the .file attribute. 

19 """ 

20 def __init__(self, msg, file): 

21 self.msg = msg 

22 self.file = file 

23 Error.__init__(self, "ValidationError in file '%s': %s " % (file, msg)) 

24 

25class ParsingError(Error): 

26 """Raised when a file cannot be parsed. 

27  

28 The filename is the .file attribute. 

29 """ 

30 def __init__(self, msg, file): 

31 self.msg = msg 

32 self.file = file 

33 Error.__init__(self, "ParsingError in file '%s', %s" % (file, msg)) 

34 

35class NoKeyError(Error): 

36 """Raised when trying to access a nonexistant key in an INI-style file. 

37  

38 Attributes are .key, .group and .file. 

39 """ 

40 def __init__(self, key, group, file): 

41 Error.__init__(self, "No key '%s' in group %s of file %s" % (key, group, file)) 

42 self.key = key 

43 self.group = group 

44 self.file = file 

45 

46class DuplicateKeyError(Error): 

47 """Raised when the same key occurs twice in an INI-style file. 

48  

49 Attributes are .key, .group and .file. 

50 """ 

51 def __init__(self, key, group, file): 

52 Error.__init__(self, "Duplicate key '%s' in group %s of file %s" % (key, group, file)) 

53 self.key = key 

54 self.group = group 

55 self.file = file 

56 

57class NoGroupError(Error): 

58 """Raised when trying to access a nonexistant group in an INI-style file. 

59  

60 Attributes are .group and .file. 

61 """ 

62 def __init__(self, group, file): 

63 Error.__init__(self, "No group: %s in file %s" % (group, file)) 

64 self.group = group 

65 self.file = file 

66 

67class DuplicateGroupError(Error): 

68 """Raised when the same key occurs twice in an INI-style file. 

69  

70 Attributes are .group and .file. 

71 """ 

72 def __init__(self, group, file): 

73 Error.__init__(self, "Duplicate group: %s in file %s" % (group, file)) 

74 self.group = group 

75 self.file = file 

76 

77class NoThemeError(Error): 

78 """Raised when trying to access a nonexistant icon theme. 

79  

80 The name of the theme is the .theme attribute. 

81 """ 

82 def __init__(self, theme): 

83 Error.__init__(self, "No such icon-theme: %s" % theme) 

84 self.theme = theme