Librarian in regular requirements.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 27 Feb 2019 22:03:13 +0000 (23:03 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 27 Feb 2019 22:04:46 +0000 (23:04 +0100)
.gitmodules [deleted file]
apps/catalogue/management/commands/import_wl.py
apps/catalogue/models/book.py
apps/catalogue/models/image.py
apps/catalogue/views.py
apps/cover/views.py
lib/librarian [deleted submodule]
manage.py
redakcja/wsgi.py
requirements.txt

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644 (file)
index 004f6f3..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "lib/librarian"]
-       path = lib/librarian
-       url = git://git.nowoczesnapolska.org.pl/librarian.git
index 7eee897..45c9e33 100644 (file)
@@ -41,7 +41,7 @@ class Command(BaseCommand):
                 print b.slug
             text = b.materialize().encode('utf-8')
             try:
-                info = BookInfo.from_string(text)
+                info = BookInfo.from_bytes(text)
             except (ParseError, ValidationError):
                 pass
             else:
@@ -59,7 +59,7 @@ class Command(BaseCommand):
         for book in json.load(urllib2.urlopen(WL_API)):
             book_detail = json.load(urllib2.urlopen(book['href']))
             xml_text = urllib2.urlopen(book_detail['xml']).read()
-            info = BookInfo.from_string(xml_text)
+            info = BookInfo.from_bytes(xml_text)
             previous_books = slugs.get(info.slug)
             if previous_books:
                 if len(previous_books) > 1:
index 0239673..1fcd05a 100755 (executable)
@@ -339,7 +339,7 @@ class Book(models.Model):
             from librarian.dcparser import BookInfo
             from librarian import NoDublinCore, ParseError, ValidationError
             try:
-                return BookInfo.from_string(book_xml.encode('utf-8'))
+                return BookInfo.from_bytes(book_xml.encode('utf-8'))
             except (self.NoTextError, ParseError, NoDublinCore, ValidationError):
                 return None
 
@@ -416,8 +416,8 @@ class Book(models.Model):
         from catalogue.ebook_utils import RedakcjaDocProvider
         from librarian.parser import WLDocument
 
-        return WLDocument.from_string(
-                self.materialize(publishable=publishable, changes=changes),
+        return WLDocument.from_bytes(
+                self.materialize(publishable=publishable, changes=changes).encode('utf-8'),
                 provider=RedakcjaDocProvider(publishable=publishable),
                 parse_dublincore=parse_dublincore,
                 strict=strict)
index 8f044d3..646dd0a 100755 (executable)
@@ -80,7 +80,8 @@ class Image(dvcs_models.Document):
         picture_xml = publishable.materialize()
 
         try:
-            picture = WLPicture.from_string(picture_xml.encode('utf-8'),
+            picture = WLPicture.from_bytes(
+                    picture_xml.encode('utf-8'),
                     image_store=SelfImageStore)
         except ParseError, e:
             raise AssertionError(_('Invalid XML') + ': ' + str(e))
index b6521c7..f620805 100644 (file)
@@ -235,7 +235,7 @@ def book_txt(request, slug):
         return HttpResponseForbidden("Not authorized.")
 
     doc = book.wldocument()
-    text = doc.as_text().get_string()
+    text = doc.as_text().get_bytes()
     response = http.HttpResponse(text, content_type='text/plain')
     response['Content-Disposition'] = 'attachment; filename=%s.txt' % slug
     return response
@@ -250,7 +250,7 @@ def book_html(request, slug):
     doc = book.wldocument(parse_dublincore=False)
     html = doc.as_html(options={'gallery': "'%s'" % book.gallery_url()})
 
-    html = html.get_string() if html is not None else ''
+    html = html.get_bytes() if html is not None else ''
     # response = http.HttpResponse(html, content_type='text/html')
     # return response
     # book_themes = {}
@@ -288,7 +288,7 @@ def book_epub(request, slug):
     # TODO: move to celery
     doc = book.wldocument()
     # TODO: error handling
-    epub = doc.as_epub(ilustr_path=book.gallery_path()).get_string()
+    epub = doc.as_epub(ilustr_path=book.gallery_path()).get_bytes()
     response = HttpResponse(content_type='application/epub+zip')
     response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.epub'
     response.write(epub)
@@ -304,7 +304,7 @@ def book_mobi(request, slug):
     # TODO: move to celery
     doc = book.wldocument()
     # TODO: error handling
-    mobi = doc.as_mobi(ilustr_path=book.gallery_path()).get_string()
+    mobi = doc.as_mobi(ilustr_path=book.gallery_path()).get_bytes()
     response = HttpResponse(content_type='application/x-mobipocket-ebook')
     response['Content-Disposition'] = 'attachment; filename=%s' % book.slug + '.mobi'
     response.write(mobi)
index bbcf28e..3f2c46f 100644 (file)
@@ -41,7 +41,7 @@ def preview(request, book, chunk=None, rev=None):
     xml = revision.materialize().encode('utf-8')
 
     try:
-        info = BookInfo.from_string(xml)
+        info = BookInfo.from_bytes(xml)
     except:
         return HttpResponseRedirect(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
     cover = make_cover(info)
@@ -63,7 +63,7 @@ def preview_from_xml(request):
 
     xml = request.POST['xml']
     try:
-        info = BookInfo.from_string(xml.encode('utf-8'))
+        info = BookInfo.from_bytes(xml.encode('utf-8'))
     except:
         return HttpResponse(os.path.join(settings.STATIC_URL, "img/sample_cover.png"))
     coverid = sha1(etree.tostring(info.to_etree())).hexdigest()
diff --git a/lib/librarian b/lib/librarian
deleted file mode 160000 (submodule)
index 03c2258..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 03c2258429bf8f80e88025fce45126960bfcd827
index 29702c0..44d4b1a 100755 (executable)
--- a/manage.py
+++ b/manage.py
@@ -5,8 +5,6 @@ import sys
 ROOT = os.path.dirname(os.path.abspath(__file__))
 sys.path = [
     os.path.join(ROOT, 'apps'),
-    os.path.join(ROOT, 'lib'),
-    os.path.join(ROOT, 'lib/librarian'),
 ] + sys.path
 
 if __name__ == "__main__":
index 62743d6..5ffd742 100755 (executable)
@@ -8,8 +8,6 @@ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 sys.path = [
     ROOT,
     os.path.join(ROOT, 'apps'),
-    os.path.join(ROOT, 'lib'),
-    os.path.join(ROOT, 'lib/librarian'),
 ] + sys.path
 
 
index a3e7a74..03c1bc4 100644 (file)
@@ -1,16 +1,13 @@
--i https://py.mdrn.pl:8443/simple
+-i https://py.mdrn.pl/simple
 
 ## Python libraries
-lxml>=2.2.2
 Mercurial>=3.3,<3.4
 PyYAML>=3.0
 Pillow
 oauth2
 httplib2 # oauth2 dependency
-texml==2.0.2
 
-## Book conversion library
-# git+git://github.com/fnp/librarian.git@master#egg=librarian
+librarian
 
 ## Django
 Django>=1.6,<1.7
@@ -31,4 +28,3 @@ kombu>=3.0,<3.1
 South>=1.0.2
 
 raven
-argparse
\ No newline at end of file