doc-publik: add script to update doc-publik from redmine wiki pages (#16621)

This commit is contained in:
Frédéric Péters 2017-06-25 18:00:15 +02:00
parent 7ab54b5153
commit 4e964643f9
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
from bs4 import BeautifulSoup
import html5lib
import requests
from combo.data.models import TextCell
DOCS = {
'passerelle-connecteur-dev': "https://dev.entrouvert.org/projects/passerelle/wiki/D%C3%A9veloppement_d'un_connecteur.html",
}
for cell in TextCell.objects.all():
if not cell.slug in DOCS:
continue
resp = requests.get(DOCS[cell.slug])
if resp.status_code != 200:
continue
document = BeautifulSoup(resp.content, 'html5lib')
content = document.find('body')
new_content = unicode(content).replace('<body>', '').replace('</body>', '')
cell.text = new_content
cell.save()