disable crawling for catalogue pages with multiple tags
[wolnelektury.git] / src / search / management / commands / snippets.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 django.core.management.base import BaseCommand
6
7 from glob import glob
8 from os import path
9 from django.conf import settings
10
11
12 class Command(BaseCommand):
13     help = 'Check snippets.'
14     args = ''
15
16     def handle(self, *args, **opts):
17         sfn = glob(settings.SEARCH_INDEX+'snippets/*')
18         for fn in sfn:
19             print fn
20             bkid = path.basename(fn)
21             with open(fn) as f:
22                 cont = f.read()
23                 try:
24                     cont.decode('utf-8')
25                 except UnicodeDecodeError:
26                     print "error in snippets %s" % bkid