fixed links in the gallery list
[wolnelektury.git] / src / waiter / utils.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from os.path import abspath, join, exists
6 from shutil import rmtree
7 from waiter.settings import WAITER_ROOT
8
9
10 def check_abspath(path):
11     abs_path = abspath(join(WAITER_ROOT, path))
12     if not abs_path.startswith(WAITER_ROOT):
13         raise ValueError('Path not inside WAITER_ROOT.')
14     return abs_path
15
16
17 def clear_cache(path):
18     abs_path = check_abspath(path)
19     if exists(abs_path):
20         rmtree(abs_path)