コード例 #1
0
ファイル: build.py プロジェクト: dkienzle/d2l-book
    def lib(self):
        root = os.path.join(self.config.src_dir,
                            self.config.build['index'] + '.md')
        notebooks = get_toc(root)
        notebooks_enabled, _, _ = self._find_md_files()
        notebooks = [nb for nb in notebooks if nb in notebooks_enabled]
        root_dir = self.config.library['root_dir']
        if root_dir:
            for nb in notebooks:
                library.save_file(root_dir, nb)

        # deprecated, can be removed later
        save_patterns = self.config.library['save_patterns']
        if save_patterns:
            items = split_config_str(save_patterns, num_items_per_line=2)
            for lib_fname, tab in items:
                library.save_tab(notebooks, lib_fname, tab,
                                 self.config.default_tab)

        for tab in self.config.tabs:
            if tab in self.config.library:
                tab_lib = self.config.library[tab]
                library.save_tab(notebooks, tab_lib['lib_file'], tab,
                                 self.config.default_tab)
                library.save_alias(tab_lib)

        save_mark = self.config.library['save_mark']
        lib_fname = self.config.library['save_filename']
        if save_mark and lib_fname:
            library.save_mark(notebooks, lib_fname, save_mark)

        library.save_version(self.config.project['release'],
                             self.config.library['version_file'])
コード例 #2
0
    def lib(self):
        root = os.path.join(self.config.src_dir,
                            self.config.build['index'] + '.md')
        notebooks = get_toc(root)
        notebooks_enabled, _, _ = self._find_md_files()
        notebooks = [nb for nb in notebooks if nb in notebooks_enabled]

        save_patterns = self.config.library['save_patterns']
        if save_patterns:
            items = split_config_str(save_patterns, num_items_per_line=2)
            for lib_fname, tab in items:
                library.save_tab(notebooks, lib_fname, tab,
                                 self.config.default_tab)

        save_mark = self.config.library['save_mark']
        lib_fname = self.config.library['save_filename']
        if save_mark and lib_fname:
            library.save_mark(notebooks, lib_fname, save_mark)

        version = self.config.library['version']
        version_fn = self.config.library['version_file']
        if version and version_fn:
            with open(version_fn, 'r') as f:
                lines = f.read().split('\n')
            for i, l in enumerate(lines):
                if '__version__' in l:
                    lines[i] = f'__version__ = "{version}"'
                    logging.info(f'save {lines[i]} into {version_fn}')
            with open(version_fn, 'w') as f:
                f.write('\n'.join(lines))
コード例 #3
0
ファイル: build.py プロジェクト: cuongvng/d2l-book
    def lib(self):
        root = os.path.join(self.config.src_dir, self.config.build['index'] + '.md')
        notebooks = get_toc(root)
        notebooks_enabled, _, _ = self._find_md_files()
        notebooks = [nb for nb in notebooks if nb in notebooks_enabled]

        save_patterns = self.config.library['save_patterns']
        if save_patterns:
            items = split_config_str(save_patterns, num_items_per_line=2)
            for lib_fname, tab in items:
               library.save_tab(notebooks, lib_fname, tab, self.config.default_tab)

        save_mark = self.config.library['save_mark']
        lib_fname = self.config.library['save_filename']
        if save_mark and lib_fname:
            library.save_mark(notebooks, lib_fname, save_mark)