Skip to content
Browse files

added newid action

  • Loading branch information...
1 parent 6daf313 commit 64b05a5833aa30c31921fba718d0cea208eaa58c @bkidwell committed Dec 3, 2011
View
4 mdepub/__init__.py
@@ -4,6 +4,10 @@
from mdepub.argumentparser import ArgumentParser
options = None
import filename
+import uuid
+
+def new_id():
+ return uuid.uuid4()
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('mdepub')
View
1 mdepub/actions/__init__.py
@@ -2,3 +2,4 @@
import html
import epub
import archive
+import newid
View
2 mdepub/actions/clean.py
@@ -1,5 +1,7 @@
import logging
+# TODO: implement 'clean' action
+
log = logging.getLogger('clean')
def run():
View
2 mdepub/actions/epub.py
@@ -113,6 +113,6 @@ def run():
#metadata = zip.read("content.opf")
soup = BeautifulSoup(metadata)
id = soup.find(id="uuid_id")
- id.contents[0].replaceWith(options.get('uuid') or uuid.uuid4())
+ id.contents[0].replaceWith(options.get('uuid') or mdepub.new_id())
#print soup
zip.writestr("content.opf", str(soup))
View
3 mdepub/argumentparser.py
@@ -16,6 +16,7 @@
archive Archive source files to zip file
epub Convert HTML to Epub and include source zip file
clean Delete output files except Epub package
+ newid Assign a new ID for this project in options.yaml
required files:
options.yaml Project options
@@ -38,7 +39,7 @@
def setup_args(parser):
parser.add_argument(
'action', nargs='+', metavar='action',
- choices=['create', 'html', 'archive', 'epub', 'clean'],
+ choices=['create', 'html', 'archive', 'epub', 'clean', 'newid'],
help="Which action to perform."
)
parser.add_argument(
View
2 sample/Alice in Wonderland/options.yaml
@@ -20,7 +20,7 @@ language: English
rating: ~ # personal rating
series: ~ # name of the series
series index: ~ # ordinal number within a series
-uuid: 8220b2f8-0f38-11e1-962f-889ffa5498bb
+uuid: 57c9f0ba-582c-4a4e-98cd-ed4511717a9e
# Tags: give a list of tag names enclosed in square brackets and separated by
# commas. For consistency, use all lowercase and give multiple word tags with

0 comments on commit 64b05a5

Please sign in to comment.
Something went wrong with that request. Please try again.