pnbp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 7510d4dd94c79739a276846aaa5b173c81f3e6c0
parent eff237e9f5ab92ec2d71d658ebf3e336a1a359d4
Author: Paul Longtine <paul@nanner.co>
Date:   Thu Jan 21 21:49:12 2016

added stagit stuff

Diffstat:
 src/core/modules/stagit.py |  5 +++++
 src/init.py                |  9 +++++----
 src/stagit/__init__.py     | 25 +++++++++++++++++++++++++
 src/stagit/ambassador.py   | 31 +++++++++++++++++++++++++++++++
 4 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/src/core/modules/stagit.py b/src/core/modules/stagit.py @@ -0,0 +1,5 @@ + +def getPages(template,settings,name,page): + + pages['all'] = {} + return pages diff --git a/src/init.py b/src/init.py @@ -7,7 +7,7 @@ ' For documentation, please visit http://pnbp.nanner.co ''' -import core +import core, shtml, stagit from time import time from optparse import OptionParser @@ -19,8 +19,6 @@ def parsearg(): help="set site project root directory", metavar="<dir>") parser.add_option("-o", dest="out", default="site", help="where to output", metavar="<out>") - parser.add_option("-i", "--init", dest="init", action="store_true", default=False, - help="initalize basic project directory") return parser.parse_args() if __name__ == "__main__": @@ -30,9 +28,12 @@ if __name__ == "__main__": #Parse arguements options, args = parsearg() - #Try to build the site + #Tries to run the jobs core.init(options) + #Do the thing after + stagit.init(options) + #Print the time it took to build the site print("Finished in {} ms.".format((time()-start)*1000)) diff --git a/src/stagit/__init__.py b/src/stagit/__init__.py @@ -0,0 +1,25 @@ +import os, sys, yaml + +import core.ambassador + +def init(arg): + if os.path.exists(arg.dir): + os.chdir(arg.dir) + else: + print("'{}' does not exist".format(arg.dir)) + sys.exit(1) + + #Try to get the config + try: + raw_config = file("stagit_config.yml") + + except: + print("Can't open file 'stagit_config.yml'") + sys.exit(0) + + config = yaml.load(raw_config) + + core.ambassador.stagit(config) + + + diff --git a/src/stagit/ambassador.py b/src/stagit/ambassador.py @@ -0,0 +1,31 @@ +import sys, os + +from subprocess import call + +def stagit(config): + config['output_dir'] = config.get("output_dir", "html/") + + config['repo_dir'] = config.get("repo_dir", "src/") + + repo_string = "" + + for repo in os.listdir(config['repo_dir']): + repo_path = os.path.join( config['output_dir'], repo ) + + os.mkdir(repo_path) + + path = os.getcwd() + + os.chdir( repo_path ) + + call(["stagit", repo_path]) + + os.chdir(path) + + repo_string = " ".join(repo_string, repo) + + os.chdir(config['output_dir']) + + call(["stagit-index", repo_string]) + +