Permalink
Browse files

Refactor mobi generation into common

  • Loading branch information...
1 parent 2f18f5e commit fef19dc92911ae304f2a3e38779f28e8e2405d08 @palfrey committed Oct 21, 2012
Showing with 11 additions and 7 deletions.
  1. +2 −5 books.py
  2. +9 −2 common.py
View
@@ -3,7 +3,6 @@
from google.protobuf import text_format
from blog_pb2 import All
from re import compile, DOTALL, MULTILINE
-from os import system
from os.path import exists
from codecs import open
from urlparse import urljoin
@@ -87,10 +86,8 @@
break
page = newpage
tocEnd(toc)
- if newitems or not exists(folder + ".mobi"):
- cmd = "rm -f book.zip && zip -j book.zip %s/* && ebook-convert book.zip \"%s.mobi\" --output-profile kindle --margin-top 0 --margin-bottom 0 --margin-left 0 --authors=\"%s\" --input-encoding=utf-8" %(folder.replace(" ", "\\ "), folder, s.author)
- print cmd
- system(cmd)
+ if newitems:
+ makeMobi(folder, s.author)
if page != None:
index +=1
View
@@ -1,5 +1,5 @@
from codecs import open
-from os import mkdir
+from os import mkdir, system
from os.path import join, exists
try:
@@ -54,4 +54,11 @@ def tocEnd(toc):
toc.write("""\t\t</div>
</body>
</html>""")
- toc.close()
+ toc.close()
+
+def makeMobi(folder, author):
+ if not exists(folder + ".mobi"):
+ cmd = "rm -f book.zip && zip -j book.zip %s/* && ebook-convert book.zip \"%s.mobi\" --output-profile kindle --margin-top 0 --margin-bottom 0 --margin-left 0 --authors=\"%s\" --input-encoding=utf-8" %(folder.replace(" ", "\\ "), folder, author)
+ print cmd
+ system(cmd)
+

0 comments on commit fef19dc

Please sign in to comment.