stupid copy2
[wolnelektury.git] / apps / waiter / utils.py
1 from os.path import abspath, join, exists
2 from shutil import rmtree
3 from waiter.settings import WAITER_ROOT
4
5
6 def check_abspath(path):
7     abs_path = abspath(join(WAITER_ROOT, path))
8     if not abs_path.startswith(WAITER_ROOT):
9         raise ValueError('Path not inside WAITER_ROOT.')
10     return abs_path
11
12
13 def clear_cache(path):
14     abs_path = check_abspath(path)
15     if exists(abs_path):
16         rmtree(abs_path)
17