Permalink
Browse files

require existence of options.yaml

  • Loading branch information...
bkidwell committed Dec 4, 2011
1 parent 8da9692 commit 716099ffed152a63d1e95ce81197f0a47a47613f
Showing with 13 additions and 0 deletions.
  1. +9 −0 mdepub/__init__.py
  2. +1 −0 mdepub/actions/archive.py
  3. +1 −0 mdepub/actions/epub.py
  4. +1 −0 mdepub/actions/html.py
  5. +1 −0 mdepub/actions/newid.py
View
@@ -5,6 +5,7 @@
options = None
import filename
import uuid
+import sys
VERSION = "0.1"
@@ -18,7 +19,9 @@ def new_id():
log.debug("Working path: %s", project_path)
options_file = os.path.join(project_path, "options.yaml")
+options_loaded = False
if os.path.exists(options_file):
+ options_loaded = True
log.debug("Loading options.yaml")
options = yaml.load(open("options.yaml"))
if VERSION.split(".") < (options.get("require mdepub version") or "").split("."):
@@ -30,6 +33,12 @@ def new_id():
options['filename'] = filename.clean(options['title'])
log.debug("Filename: %s", options['filename'])
else:
+ options = yaml.load("")
log.debug("options.yaml not found")
arguments = ArgumentParser().parse_args()
+
+def require_opts_file():
+ if options_loaded: return
+ log.fatal("No options.yaml file found for this project.")
+ sys.exit(1)
@@ -11,6 +11,7 @@
def run():
log.debug("run()")
+ mdepub.require_opts_file()
os.chdir(project_path)
View
@@ -18,6 +18,7 @@ def quote(text):
def run():
log.debug("run()")
+ mdepub.require_opts_file()
os.chdir(project_path)
View
@@ -23,6 +23,7 @@ def checkForBadLinks(html):
def run():
log.debug("run()")
+ mdepub.require_opts_file()
os.chdir(project_path)
View
@@ -15,6 +15,7 @@
def run():
log.debug("run()")
+ mdepub.require_opts_file()
os.chdir(project_path)
print mdepub.options

0 comments on commit 716099f

Please sign in to comment.