Ejemplo n.º 1
0
    def prepare_html_dir(self, html_dir):
        '''
        Prepare the html_directory, copying it from the project's template
        '''
        cwd = os.getcwd()
        # Delete the html folder if it exists
        dgen_utils.delete_folder(html_dir)
        # Copy the template html folder

        src = os.path.join(self.project.template_dir, 'html')
        src = dgen_utils.expand_paths(src)
        dgen_utils.copy_files(src, html_dir)
        # Copy other files to the HTML dir for referencing
        for item in [
                p for p in glob.glob('*')
                if not (p.endswith('.md') or p.endswith('.yaml')
                        or p.endswith('.pdf') or p.endswith('-html'))
        ]:
            src = os.path.join(cwd, item)
            dst = os.path.join(html_dir, item)
            dgen_utils.copy_files(src, dst)
        # replace ${html_dir} in all files
        for root, _, files in os.walk(html_dir, topdown=False):
            for name in files:
                # Symbol processor must be initialised previously
                self.symbol_processor.replace_symbols_in_file(
                    os.path.join(root, name))
Ejemplo n.º 2
0
 def prepare_html_dir(self, html_dir):
     '''
     Prepare the html_directory, copying it from the project's template
     '''
     if self.working_offline() is False:
         repo = git.Repo(self.project.local_template_dir)
         for remote in repo.remotes:
             remote.fetch(progress=dgen_utils.GitProgress())
         g = git.Git(repo.working_dir)
         g.checkout(self.project.pathspec)
     cwd = os.getcwd()
     # Delete the html folder if it exists
     dgen_utils.delete_folder(html_dir)
     # Copy the template html folder
     src = os.path.join(self.project.local_template_dir, 'html')
     src = dgen_utils.expand_path(src)
     dgen_utils.copy_files(src, html_dir)
     # Copy other files to the HTML dir for referencing
     for item in [
             p for p in glob.glob('*')
             if not (p.endswith('.md') or p.endswith('.yaml')
                     or p.endswith('.pdf') or p.endswith('-html'))
     ]:
         src = os.path.join(cwd, item)
         dst = os.path.join(html_dir, item)
         dgen_utils.copy_files(src, dst)
     # replace ${html_dir} in all files
     for root, _, files in os.walk(html_dir, topdown=False):
         for name in files:
             # Symbol processor must be initialised previously
             self.symbol_processor.replace_symbols_in_file(
                 os.path.join(root, name), self.symbol_processor.symbols)
Ejemplo n.º 3
0
 def refresh_template(self):
     if os.path.exists(self.local_template_dir):
         dgen_utils.delete_folder(self.local_template_dir)
     if dgen_utils.is_git_url(self.template_dir) is True:
         repo = git.Repo.clone_from(self.template_dir,
                                    self.local_template_dir,
                                    progress=dgen_utils.GitProgress())
         for remote in repo.remotes:
             remote.fetch(progress=dgen_utils.GitProgress())
         g = git.Git(repo.working_dir)
         g.checkout(self.pathspec)
     elif os.path.isdir(self.template_dir):
         dgen_utils.copy_files(self.template_dir, self.local_template_dir)
Ejemplo n.º 4
0
 def refresh_template(self):
     if os.path.exists(self.local_template_dir):
         dgen_utils.delete_folder(self.local_template_dir)
     dgen_utils.copy_files(self.template_dir, self.local_template_dir)
Ejemplo n.º 5
0
 def copy_reveal(self):
     if self.project.revealjs_dir is '':
         dgen_utils.log_err('config item revealjs_dir not set for project')
     dgen_utils.copy_files(self.project.html_dir, self.project.revealjs_dir)