Пример #1
0
def new_notebook(fakedir=None):
	'''Returns a new Notebook object with all data in memory

	Uses data from L{WikiTestData}

	@param fakedir: optional parameter to set the 'dir' attribute for
	the notebook and the main store which allows you to resolve file
	paths etc. It will not automatically touch the dir
	(hence it being 'fake').
	'''
	from zim.fs import Dir
	from zim.notebook import Notebook, Path
	from zim.index import Index

	notebook = Notebook(index=Index(dbfile=':memory:'))
	store = notebook.add_store(Path(':'), 'memory')
	manifest = []
	for name, text in WikiTestData:
		manifest.append(name)
		store.set_node(Path(name), text)
	notebook.testdata_manifest = _expand_manifest(manifest)
	notebook.index.update()

	if fakedir:
		dir = Dir(fakedir)
		notebook.dir = dir
		store.dir = dir

	return notebook
Пример #2
0
def new_notebook(fakedir=None):
    '''Returns a new Notebook object with all data in memory

	Uses data from L{WikiTestData}

	@param fakedir: optional parameter to set the 'dir' attribute for
	the notebook and the main store which allows you to resolve file
	paths etc. It will not automatically touch the dir
	(hence it being 'fake').
	'''
    from zim.fs import Dir
    from zim.notebook import Notebook, Path
    from zim.index import Index

    notebook = Notebook(index=Index(dbfile=':memory:'))
    store = notebook.add_store(Path(':'), 'memory')
    manifest = []
    for name, text in WikiTestData:
        manifest.append(name)
        store.set_node(Path(name), text)
    notebook.testdata_manifest = _expand_manifest(manifest)
    notebook.index.update()

    if fakedir:
        dir = Dir(fakedir)
        notebook.dir = dir
        store.dir = dir

    return notebook