pad prefix
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Wed, 21 Nov 2012 15:06:39 +0000 (16:06 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Wed, 21 Nov 2012 15:06:39 +0000 (16:06 +0100)
remove slowniczek link

apps/catalogue/management/commands/import_pad.py
apps/catalogue/management/edumed.py

index 6e3ff4a..dbfe799 100644 (file)
@@ -14,6 +14,7 @@ from librarian import ParseError, ValidationError, WLURI
 from django.conf import settings
 from catalogue.models import Book
 from catalogue.management import auto_taggers
 from django.conf import settings
 from catalogue.models import Book
 from catalogue.management import auto_taggers
+import re
 
 
 class Command(BaseCommand):
 
 
 class Command(BaseCommand):
@@ -25,6 +26,7 @@ class Command(BaseCommand):
         make_option('-E', '--edumed', dest="tag_edumed", default=False,
                     action='store_true', help="Perform EduMed pre-tagging"),
         make_option('-a', '--autotagger', dest="auto_tagger", default=None, help="Use auto-tagger (one of: %s)" % ', '.join(auto_taggers.keys())),
         make_option('-E', '--edumed', dest="tag_edumed", default=False,
                     action='store_true', help="Perform EduMed pre-tagging"),
         make_option('-a', '--autotagger', dest="auto_tagger", default=None, help="Use auto-tagger (one of: %s)" % ', '.join(auto_taggers.keys())),
+        make_option('-S', '--use-pad-prefix', dest="pad_prefix", default=False, action='store_true', help="use pad name prefix in slug"),
     )
     help = 'Imports Text files from EtherPad Lite.'
 
     )
     help = 'Imports Text files from EtherPad Lite.'
 
@@ -52,6 +54,7 @@ class Command(BaseCommand):
             if verbose:
                 print b.slug
             text = b.materialize().encode('utf-8')
             if verbose:
                 print b.slug
             text = b.materialize().encode('utf-8')
+
             try:
                 info = BookInfo.from_string(text)
                 slugs[info.url.slug].append(b)
             try:
                 info = BookInfo.from_string(text)
                 slugs[info.url.slug].append(b)
@@ -106,6 +109,11 @@ class Command(BaseCommand):
                 comm = '*'
             print book_count, slug, '-->', comm
 
                 comm = '*'
             print book_count, slug, '-->', comm
 
+            # add pad prefix now.
+            if options.get('pad_prefix'):
+                pad_prefix = re.split(r"[-_]", pid)[0]
+                slug = pad_prefix + "-" + slug
+                
             if previous_book:
                 book = previous_book
                 book.slug = slug
             if previous_book:
                 book = previous_book
                 book.slug = slug
index c319132..0503436 100644 (file)
@@ -137,7 +137,8 @@ class List(Tagger):
 class Paragraph(Tagger):
     remove_this = [
         re.compile(r"[\s]*opis zawarto.ci[\s]*", re.I),
 class Paragraph(Tagger):
     remove_this = [
         re.compile(r"[\s]*opis zawarto.ci[\s]*", re.I),
-        re.compile(r"^[\s]*$")
+        re.compile(r"^[\s]*$"),
+        re.compile(r"http://pad.nowoczesnapolska.org.pl/p/slowniczek")
         ]
     podrozdzial = [
         re.compile(r"[\s]*(przebieg zaj..|opcje dodatkowe)[\s]*", re.I),
         ]
     podrozdzial = [
         re.compile(r"[\s]*(przebieg zaj..|opcje dodatkowe)[\s]*", re.I),