class documentation

class Path: (source)

Known subclasses: zim.notebook.index.pages.PageIndexRecord, zim.notebook.page.Page

View In Hierarchy

Class Method new_from_zim_config Returns a new object based on the string representation for that path.
Static Method assertValidPageName No summary
Static Method makeValidPageName No summary
Method __add__ path + name is an alias for path.child(name)
Method __eq__ Paths are equal when their names are the same
Method __hash__ Undocumented
Method __init__ Constructor.
Method __ne__ Paths are not equal when their names are not the same
Method __repr__ Undocumented
Method __str__ Undocumented
Method child Get a child Path
Method commonparent Find a common parent for two Paths
Method ischild Check whether this path is a child of a given path @param parent: a Path object @returns: True when this path is a (grand-)child of parent
Method match_namespace Check whether this path is in a specific section of the notebook @param namespace: a Path object @returns: True when this path is equal to namespace or is a (grand-)child of namespace
Method parents Generator function for parent Paths including root
Method relname Get a part of this path relative to a parent path
Method serialize_zim_config Returns the name for serializing this path
Class Variable __slots__ Undocumented
Instance Variable name Undocumented
Property basename Get the basename of the path (last part of the name)
Property isroot True when this Path represents the top level namespace
Property namespace Gives the name for the parent page. Returns an empty string for the top level namespace.
Property parent Get the path for the parent page
Property parts Get all the parts of the name (split on ":")
@classmethod
def new_from_zim_config(klass, string): (source)
Returns a new object based on the string representation for that path.
Parameters
klassUndocumented
string:strUndocumented
Returns
PathUndocumented
@staticmethod
def assertValidPageName(name): (source)
Raises an AssertionError if name does not represent a valid page name. This is a strict check, most names that fail this test can still be cleaned up by the makeValidPageName().
Parameters
name:strUndocumented
Raises
AssertionErrorif the name is not valid
@staticmethod
def makeValidPageName(name): (source)
Remove any invalid characters from the string and return a valid page name. Only string that can not be turned in somthing valid is a string that reduces to an empty string after removing all invalid characters.
Parameters
name:strUndocumented
Returns
strUndocumented
Raises
ValueErrorwhen the result would be an empty string
def __add__(self, name): (source)
path + name is an alias for path.child(name)
def __eq__(self, other): (source)
Paths are equal when their names are the same
def __hash__(self): (source)

Undocumented

def __init__(self, name): (source)
Constructor.
Parameters
name:Union[str, tuple]

the absolute page name in the right case as a string or as a tuple strings

The name ":" is used as a special case to construct a path for the toplevel namespace in a notebook.

Note
This constructor does not do any checks for the sanity of the path name. Never construct a path directly from user input, but use either index.lookup_from_user_input() or first check the name with makeValidPageName()
def __ne__(self, other): (source)
Paths are not equal when their names are not the same
def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

def child(self, basename): (source)
Get a child Path
Parameters
basename:strthe relative name for the child
Returns
Patha new Path object
def commonparent(self, other): (source)
Find a common parent for two Paths
Parameters
other:Pathanother Path object
Returns
Patha Path object for the first common parent
def ischild(self, parent): (source)
Check whether this path is a child of a given path
Parameters
parent:Patha Path object
Returns
boolTrue when this path is a (grand-)child of parent
def match_namespace(self, namespace): (source)
Check whether this path is in a specific section of the notebook
Parameters
namespace:Patha Path object
Returns
boolTrue when this path is equal to namespace or is a (grand-)child of namespace
def parents(self): (source)
Generator function for parent Paths including root
Returns
Generator[Path, None, None]Undocumented
def relname(self, path): (source)
Get a part of this path relative to a parent path
Parameters
path:Patha parent Path
Returns
strthe part of the path that is relative to path
Raises
ValueErrorif path is not a parent
def serialize_zim_config(self): (source)
Returns the name for serializing this path
Returns
strUndocumented
__slots__: tuple[str, ...] = (source)

Undocumented

name = (source)

Undocumented

@property
basename: str = (source)
Get the basename of the path (last part of the name)
True when this Path represents the top level namespace
@property
namespace: str = (source)
Gives the name for the parent page. Returns an empty string for the top level namespace.
Get the path for the parent page
Get all the parts of the name (split on ":")