X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e8390b9f10338ff5ced700f5dbd87ba30a3566bd..c9f85a25896062833551550a6da8d4e83cd03d39:/scripts/conv_genre_families.py?ds=inline diff --git a/scripts/conv_genre_families.py b/scripts/conv_genre_families.py index 611471322..f798d69eb 100644 --- a/scripts/conv_genre_families.py +++ b/scripts/conv_genre_families.py @@ -1,4 +1,8 @@ +#!/usr/bin/env python # -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# from lxml import etree from slughifi import slughifi from django.core.management import setup_environ @@ -13,13 +17,13 @@ doc = etree.parse('rodziny.xml') for element in doc.findall('//span'): themes = [s.strip() for s in element.text.split(',')] - + element.text = u'' - + for theme in themes: try: Tag.objects.get(slug=slughifi(theme)) - + link = etree.SubElement(element, 'a', href=u'/katalog/%s' % slughifi(theme)) link.text = theme link.tail = ', '