Skip to content

Commit 23c7d61

Browse files
committed
working on color
1 parent e2fe88d commit 23c7d61

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

clid/validators.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
"""Contains validating functions used to check whether valid values
4+
are given when changing preferencs. ValidationError is raised
5+
if value to be tested doesn't pass the test.
6+
"""
7+
8+
import os
9+
10+
class ValidationError(Exception):
11+
"""Raised when validation fails"""
12+
pass
13+
14+
def music_dir(test):
15+
"""Checks whether `test` exists and is a directory.
16+
17+
Args:
18+
test(str): path to be tested.
19+
20+
Raises:
21+
ValidationError: if `test` doesn't exist or is not directory
22+
"""
23+
if not os.path.isdir(test):
24+
raise ValidationError('"' + test + '"' + ' is not a directory')
25+
if not os.path.exists(test):
26+
raise ValidationError('"' + test + '"' + ' doesn\'t exist')
27+
28+
29+
VALIDATORS = {
30+
'music_dir': music_dir
31+
}

0 commit comments

Comments
 (0)