From 002b261a11f0aa081741ea99699ecbeb11190e39 Mon Sep 17 00:00:00 2001 From: Bryan Date: Tue, 14 Jan 2014 03:42:57 -0500 Subject: [PATCH] updated to use static HTML --- .../apps/notes/management/commands/strip_html_to_text.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/karmaworld/apps/notes/management/commands/strip_html_to_text.py b/karmaworld/apps/notes/management/commands/strip_html_to_text.py index 8d42981..93180b4 100644 --- a/karmaworld/apps/notes/management/commands/strip_html_to_text.py +++ b/karmaworld/apps/notes/management/commands/strip_html_to_text.py @@ -3,6 +3,7 @@ # Copyright (C) 2012 FinalsClub Foundation import html2text +from django.core.files.storage import default_storage from django.core.management.base import BaseCommand from karmaworld.apps.notes.models import Note @@ -17,6 +18,9 @@ class Command(BaseCommand): notes = Note.objects.filter(html__isnull=False).filter(text__isnull=True) cleaned_notes = 0 for note in notes: + if not note.static_html: + # no HTML to fetch + continue try: h = html2text.HTML2Text() h.escape_snob = True @@ -24,7 +28,10 @@ class Command(BaseCommand): h.ignore_links = True h.ignore_images = True h.ignore_emphasis = True - note.text = h.handle(note.html) + # fetch data + with default_storage.open(note.get_relative_s3_path(),'r') as \ + html: + note.text = h.handle(html.read()) note.save() cleaned_notes += 1 print 'Processed {n}'.format(n=note) -- 2.25.1