+++ /dev/null
-[submodule "lib/librarian"]
- path = lib/librarian
- url = git://git.nowoczesnapolska.org.pl/librarian.git
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:
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:
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
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)
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))
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
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 = {}
# 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)
# 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)
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)
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()
+++ /dev/null
-Subproject commit 03c2258429bf8f80e88025fce45126960bfcd827
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__":
sys.path = [
ROOT,
os.path.join(ROOT, 'apps'),
- os.path.join(ROOT, 'lib'),
- os.path.join(ROOT, 'lib/librarian'),
] + sys.path
--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
South>=1.0.2
raven
-argparse
\ No newline at end of file