def generate(self): logger.debug("Empty the destination directory") dest_dir = os.path.join(self.target_path, self.config["destination"]) if os.path.exists(dest_dir): # for github pages exclude_list = ['.git', 'CNAME'] emptytree(dest_dir, exclude_list) self.generate_pages() if not os.path.exists(os.path.join(self.config['source'], 'index.md')): self.generate_catalog(self.pages) feed_fn = 'atom.xml' if os.path.exists(os.path.join(getcwdu(), feed_fn)): self.generate_feed(self.pages, feed_fn) self.install_theme() self.copy_attach() # for github pages with custom domain cname_file = os.path.join(getcwdu(), 'CNAME') if os.path.exists(cname_file): shutil.copy2(cname_file, os.path.join(self.config['destination'], 'CNAME'))
def setUp(self): os.chdir(os.path.dirname(__file__)) self.content = "sample" self.output = "output" if os.path.exists(self.output): utils.emptytree(self.output) os.rmdir(self.output)
def generate(self, include_draft=False): ''' :include_draft: True/False, include draft pages or not to generate. ''' self.include_draft = include_draft logger.debug("Empty the destination directory") dest_dir = os.path.join(self.target_path, self.config["destination"]) if os.path.exists(dest_dir): # for github pages and favicon.ico exclude_list = ['.git', 'CNAME', 'favicon.ico'] emptytree(dest_dir, exclude_list) self.generate_pages() if not os.path.exists(os.path.join(self.config['source'], 'index.md')): self.generate_catalog(self.pages) feed_fn = 'atom.xml' if os.path.exists(os.path.join(getcwdu(), feed_fn)): self.generate_feed(self.pages, feed_fn) self.install_theme() self.copy_attach() # for default supported files to be copied to output/ # CNAME for github pages with custom domain # TODO favicon can be other formats, such as .png, use glob match? for _fn in ('CNAME', 'favicon.ico'): _file = os.path.join(getcwdu(), _fn) if os.path.exists(_file): shutil.copy2(_file, os.path.join(self.config['destination'], _fn))
def setUp(self): self.args = deepcopy(INIT_ARGS) self.target_path = os.path.join(TESTS_ROOT, "mywiki") self.output_path = os.path.join(self.target_path, "output") if os.path.exists(self.output_path): emptytree(self.output_path) self.drafts = [ os.path.join(self.output_path, "intro", "my_draft.html") ] self.files = [ os.path.join(self.output_path, "index.html"), os.path.join(self.output_path, "intro", "gettingstarted.html") ] self.dirs = [ self.output_path, os.path.join(self.output_path, "intro"), ] self.attach = [ os.path.join(self.output_path, 'attach', 'images', 'linux', 'opstools.png'), ] self.static = [ os.path.join(self.output_path, "static", "css", "style.css"), ] os.chdir(self.target_path)
def setUp(self): self.args = deepcopy(INIT_ARGS) self.wiki_path = os.path.join(test_path, "mywiki_for_cli") self.output_path = os.path.join(self.wiki_path, "output") if os.path.exists(self.output_path): emptytree(self.output_path) config_file_tpl = os.path.join(base_path, "simiki", "conf_templates", "_config.yml.in") self.config_file_dst = os.path.join(self.wiki_path, "_config.yml") shutil.copyfile(config_file_tpl, self.config_file_dst) s_themes_path = os.path.join(base_path, "simiki", "themes") self.d_themes_path = os.path.join(self.wiki_path, "themes") if os.path.exists(self.d_themes_path): shutil.rmtree(self.d_themes_path) copytree(s_themes_path, self.d_themes_path) self.drafts = [os.path.join(self.output_path, "intro", "my_draft.html")] self.files = [ os.path.join(self.output_path, "index.html"), os.path.join(self.output_path, "intro", "gettingstarted.html"), ] self.dirs = [self.output_path, os.path.join(self.output_path, "intro")] self.attach = [os.path.join(self.output_path, "attach", "images", "linux", "opstools.png")] self.static = [os.path.join(self.output_path, "static", "css", "style.css")] os.chdir(self.wiki_path)
def setUp(self): wiki_path = os.path.join(test_path, 'mywiki_for_others') os.chdir(wiki_path) self.content = 'content' self.output = 'output' if os.path.exists(self.output): utils.emptytree(self.output) os.rmdir(self.output)
def generate(self, delete_output_dir=False): if delete_output_dir: logger.info("Delete all the files and dirs under output directory") output_dir = os.path.join(os.getcwd(), self.configs["destination"]) emptytree(output_dir) pages = self.generate_all_pages() self.generate_catalog(pages) install_theme(os.getcwd(), self.configs["theme"])
def generate(self, delete_output_dir=False): if delete_output_dir: logger.info("Delete all the files and dirs under output directory") output_dir = osp.join(os.getcwd(), self.configs["destination"]) emptytree(output_dir) pages = self.generate_all_pages() self.generate_catalog(pages) install_theme(os.getcwd(), self.configs["theme"])
def setUp(self): self.args = deepcopy(INIT_ARGS) self.target_path = os.path.join(TESTS_ROOT, "mywiki") self.output_path = os.path.join(self.target_path, "output") if os.path.exists(self.output_path): emptytree(self.output_path) self.files = [ os.path.join(self.output_path, "index.html"), os.path.join(self.output_path, "intro", "gettingstarted.html") ] self.dirs = [ self.output_path, os.path.join(self.output_path, "intro"), ] os.chdir(self.target_path)
def generate(self, empty_dest_dir=False, update_theme=False): if empty_dest_dir: logger.info("Empty the destination directory") dest_dir = os.path.join(self.target_path, self.config["destination"]) emptytree(dest_dir) pages = self.generate_all_pages() self.generate_catalog(pages) if empty_dest_dir or update_theme: install_theme(self.target_path, self.config["themes_dir"], self.config["theme"], self.config["destination"]) copy_attach(self.target_path, self.config['attach'], self.config['destination'])
def generate(self): logger.debug("Empty the destination directory") dest_dir = os.path.join(self.target_path, self.config["destination"]) if os.path.exists(dest_dir): # for github pages exclude_list = ['.git', 'CNAME'] emptytree(dest_dir, exclude_list) self.generate_pages() if not os.path.exists(os.path.join(self.config['source'], 'index.md')): self.generate_catalog(self.pages) self.install_theme() self.copy_attach()
def setUp(self): self.args = deepcopy(INIT_ARGS) self.wiki_path = os.path.join(test_path, "mywiki_for_cli") self.output_path = os.path.join(self.wiki_path, "output") if os.path.exists(self.output_path): emptytree(self.output_path) config_file_tpl = os.path.join(base_path, 'simiki', 'conf_templates', '_config.yml.in') self.config_file_dst = os.path.join(self.wiki_path, '_config.yml') shutil.copyfile(config_file_tpl, self.config_file_dst) s_themes_path = os.path.join(base_path, 'simiki', 'themes') self.d_themes_path = os.path.join(self.wiki_path, 'themes') if os.path.exists(self.d_themes_path): shutil.rmtree(self.d_themes_path) copytree(s_themes_path, self.d_themes_path) self.drafts = [ os.path.join(self.output_path, "intro", "my_draft.html") ] self.files = [ os.path.join(self.output_path, "index.html"), os.path.join(self.output_path, "intro", "gettingstarted.html") ] self.dirs = [ self.output_path, os.path.join(self.output_path, "intro"), ] self.attach = [ os.path.join(self.output_path, 'attach', 'images', 'linux', 'opstools.png'), ] self.static = [ os.path.join(self.output_path, "static", "css", "style.css"), ] os.chdir(self.wiki_path)
def generate(self, include_draft=False): ''' :include_draft: True/False, include draft pages or not to generate. ''' self.include_draft = include_draft logger.debug("Empty the destination directory") dest_dir = os.path.join(self.target_path, self.config["destination"]) if os.path.exists(dest_dir): # for github pages and favicon.ico exclude_list = ['.git', 'CNAME', 'favicon.ico'] emptytree(dest_dir, exclude_list) self.generate_tags() self.generate_pages() if not os.path.exists(os.path.join(self.config['source'], 'index.md')): self.generate_catalog(self.pages) feed_fn = 'atom.xml' if os.path.exists(os.path.join(getcwdu(), feed_fn)): self.generate_feed(self.pages, feed_fn) self.install_theme() self.copy_attach() # for default supported files to be copied to output/ # CNAME for github pages with custom domain # TODO favicon can be other formats, such as .png, use glob match? for _fn in ('CNAME', 'favicon.ico'): _file = os.path.join(getcwdu(), _fn) if os.path.exists(_file): shutil.copy2(_file, os.path.join(self.config['destination'], _fn))
def test_emptytree(self): utils.copytree(self.content, self.output) utils.emptytree(self.output) assert os.path.isdir(self.output) and not os.listdir(self.output)
def tearDown(self): if utils.check_path_exists(self.output): utils.emptytree(self.output) os.rmdir(self.output)
def tearDown(self): if os.path.exists(self.output_path): emptytree(self.output_path)
def tearDown(self): for f in self.files: os.remove(f) for d in self.dirs: emptytree(d) os.rmdir(d)
def tearDown(self): os.remove(self.config_file_dst) if os.path.exists(self.d_themes_path): shutil.rmtree(self.d_themes_path) if os.path.exists(self.output_path): emptytree(self.output_path)
def tearDown(self): if os.path.exists(self.output): utils.emptytree(self.output) os.rmdir(self.output)
def setUp(self): self.content = "sample" self.output = "output" if utils.check_path_exists(self.output): utils.emptytree(self.output) os.rmdir(self.output)