X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e8390b9f10338ff5ced700f5dbd87ba30a3566bd..510a4d0c1e4496bee580f8a1dff2f3674fdb727c:/scripts/conv_genre_families.py 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 = ', '