andrea_crotti committed c58b152

implement a mechanism to find automatically where is the root
directory of the project

  • Participants
  • Parent commits 58ac725

Comments (0)

Files changed (1)

File tinkerer/

 import shutil
 import sphinx
 import sys
-from tinkerer import draft, page, paths, post, writer
+from tinkerer import draft, page, paths, post, writer, utils
 logger = logging.getLogger(__name__)
     # silence Sphinx if in quiet mode
     if quiet or filename_only:
-    flags += ["-d", paths.doctree, "-b", "html", paths.root, paths.html]
+    # look up the project root in the directory structure
+    flags += ["-d", paths.doctree, "-b", "html",
+              utils.find_project_root(), paths.html]
     # build always prints "index.html"
     if filename_only:
     command = parse_arguments(argv)
-    # tinkerer should be run from the blog root unless in setup mode
-    if not command.setup and not os.path.exists(paths.conf_file):
-        sys.stderr.write("Tinkerer must be run from your blog root "
-                "(directory containing '')\n")
-        return -1
     # in setup mode it should fail if run from a blog root
-    elif command.setup and os.path.exists(paths.conf_file):
+    if command.setup and os.path.exists(paths.conf_file):
         sys.stderr.write("'' already exists in current directory, "
                 "choose a different directory to setup your blog.\n")
         return -1
     if command.setup:
         setup(command.quiet, command.filename)