import nblite.utils as this_module
utils
get_nb_format_from_path
str) -> str get_nb_format_from_path(path:
'file.pct.py') get_nb_format_from_path(
'module'
get_nb_path_info
str, root_path: str, config: NBLiteConfig) get_nb_path_info(nb_path:
= '../../test_proj'
root_path = get_project_root_and_config(root_path)
root_path, config '../../test_proj/nbs/notebook1.ipynb', '../../test_proj', config) get_nb_path_info(
{'name': Path('nbs/notebook1'),
'cl_name': Path('notebook1'),
'basename': 'notebook1',
'format': 'ipynb',
'file_ext': 'ipynb',
'cl_path': 'nbs'}
is_code_loc_nb
str, root_path: str, config: NBLiteConfig) is_code_loc_nb(nb_path:
Returns True if the notebook is a notebook associated with a code location.
= '../../test_proj'
root_path print(is_code_loc_nb('../../test_proj/nbs/notebook1.ipynb', root_path, config))
print(is_code_loc_nb('../../test_proj/nbs/notebook1.pct.py', root_path, config))
print(is_code_loc_nb('../../test_proj/test.txt', root_path, config))
True
False
False
get_code_location_nbs
get_code_location_nbs(str,
root_path:
cl: CodeLocation,bool,
ignore_dunders: bool
ignore_periods: )
Returns all notebooks in a code location. If ignore_dunders is True,
notebooks that being with a dunder (double underscore ’__’) in their names, or notebooks in folders that start with dunders, are ignored.
'../../test_proj', CodeLocation(path='nbs', format='ipynb')) get_code_location_nbs(
[Path('../../test_proj/nbs/notebook2.ipynb'),
Path('../../test_proj/nbs/notebook1.ipynb'),
Path('../../test_proj/nbs/func_notebook.ipynb'),
Path('../../test_proj/nbs/func_notebook2.ipynb'),
Path('../../test_proj/nbs/index.ipynb'),
Path('../../test_proj/nbs/submodule/notebook3.ipynb'),
Path('../../test_proj/nbs/folder/notebook4.ipynb'),
Path('../../test_proj/nbs/folder/subfolder/notebook7.ipynb')]
'../../test_proj', CodeLocation(path='nbs', format='ipynb'), ignore_dunders=False) get_code_location_nbs(
[Path('../../test_proj/nbs/notebook2.ipynb'),
Path('../../test_proj/nbs/__notebook6.ipynb'),
Path('../../test_proj/nbs/notebook1.ipynb'),
Path('../../test_proj/nbs/func_notebook.ipynb'),
Path('../../test_proj/nbs/func_notebook2.ipynb'),
Path('../../test_proj/nbs/index.ipynb'),
Path('../../test_proj/nbs/__scratch/notebook5.ipynb'),
Path('../../test_proj/nbs/submodule/notebook3.ipynb'),
Path('../../test_proj/nbs/folder/notebook4.ipynb'),
Path('../../test_proj/nbs/folder/subfolder/notebook7.ipynb')]
is_nb_unclean
is_nb_unclean(str, None],
nb_path: Union[str, None],
file_content: Union[bool
include_top_metadata: )
='{"cells":[]}') is_nb_unclean(file_content
False
'../../test_proj/nbs/notebook1.ipynb') is_nb_unclean(
False
get_unclean_nbs
str, ignore_dunders: bool) get_unclean_nbs(root_path:
Get all notebooks that have metadata or execution count.
Returns: bool: True if all notebooks are clean, False otherwise.
= get_unclean_nbs('../../test_proj') unclean_nbs
get_relative_path
str, to_path: str) get_relative_path(from_path:
Returns the relative path to the root path.
'.', '/Users/lukastk/') get_relative_path(
Path('../../../..')
is_ignorable_path
str, cl_path: str) is_ignorable_path(path:
Returns True if any part of the path, relative to the code location path, starts with an underscore or period.