def clean_dirs(input_dir, output_dir): # print 'Cleaning the pyrite-produced files' file_util.remove_file(os.path.join(input_dir, psettings.OPTIONS_NAME)) file_util.remove_file(os.path.join(output_dir, "pyrite_index.html")) moddir = file_util.get_module_dir() for d in psettings.DIRS: dir_path = os.path.join(output_dir, d) # dirlist = os.path.listdir( file_util.remove_all_files(dir_path) file_util.remove_dir(dir_path)
def create_in_out_pair(out_dir, out_file, in_file=None, connect=None): read_path = os.path.join(file_util.get_module_dir(), psettings.RES_DIR) if connect is not None: read_path = os.path.join(read_path, connect) if in_file is not None: read_path = os.path.join(read_path, in_file) else: read_path = os.path.join(read_path, out_file) out_path = out_dir if connect is not None: out_path = os.path.join(out_path, connect) out_path = os.path.join(out_path, out_file) return (read_path, out_path)
def init_outdir_if_needed(out_dir, opts): print '------------------' print "Checking for output directory initialization" print '------------------' ensure_base_dir_exists(out_dir) make_out_dirs(out_dir) copy_template_file(out_dir, psettings.BLOG_JS, opts, rdir=psettings.JS_DIR) copy_template_file(out_dir, psettings.JQUERY, opts, rdir=psettings.JS_DIR) copy_template_file(out_dir, opts.INDEX_FILE, opts, in_file=psettings.INDEX_TEMP) # Right now, copying all the files. Could copy just the one specified. mod_dir = file_util.get_module_dir() for css in os.listdir(os.path.join(mod_dir, psettings.RES_DIR, psettings.CSS_DIR)): if css.endswith(".css"): copy_template_file(out_dir, css, opts, rdir=psettings.CSS_DIR)
'in_dir': os.getcwd(), 'out_dir': os.path.join(os.getcwd(), 'pyrite_blog'), 'clean_init': False, 'clean': False, 'verbosity': 0, } # print arg_hash for o, v in opts: if o == '-h' or o == '--help': display_help() sys.exit(1) elif o == '--test': arg_hash['in_dir'] = os.path.join( file_util.get_module_dir(), "test_files") arg_hash['out_dir'] = os.path.join( file_util.get_module_dir(), "test_files", "pyrite_blog") arg_hash['test'] = True elif o == "--stress": arg_hash['in_dir'] = "stress_files" arg_hash['out_dir'] = "stress_files/test_blog_dir" elif o == "--clean_init": arg_hash['clean_init'] = True elif o == '-o': arg_hash['out_dir'] = v elif o == '-c' or o == '--clean': arg_hash['clean'] = True elif o == '-v' or o == '--version': print 'Pyrite Version %s' % __init__.__version__ sys.exit(0)
def read_default_options(): to_read = os.path.join( file_util.get_module_dir(), psettings.RES_DIR, psettings.DEFAULT_OPTS) return file_util.read_file(to_read)