A BaseMatchTree is a tree covering the filename, where each node represents a substring in the filename and can have a Guess associated with it that contains the information that has been guessed in this node. Nodes can be further split into subnodes until a proper split has been found.
BaseMatchTrees are displayed in the following way:
>>> path = 'Movies/Dark City (1998)/Dark.City.(1998).DC.BDRip.720p.DTS.X264-CHD.mkv'
>>> print(guessit.IterativeMatcher(path).match_tree)
000000 1111111111111111 2222222222222222222222222222222222222222222 333
000000 0000000000111111 0000000000111111222222222222222222222222222 000
011112 011112000011111222222222222222222 000
011112222222222222
0000011112222
01112 0111
Movies/__________(____)/Dark.City.(____).DC._____.____.___.____-___.___
tttttttttt yyyy yyyy fffff ssss aaa vvvv rrr ccc
Movies/Dark City (1998)/Dark.City.(1998).DC.BDRip.720p.DTS.X264-CHD.mkv
The last line contains the filename, which you can use a reference. The previous line contains the type of property that has been found. The line before that contains the filename, where all the found groups have been blanked. Basically, what is left on this line are the leftover groups which could not be identified.
The lines before that indicate the indices of the groups in the tree.
For instance, the part of the filename ‘BDRip’ is the leaf with index (2, 2, 1) (read from top to bottom), and its meaning is ‘format’ (as shown by the f‘s on the last-but-one line).
Add a new child node to this node with the given span.
Return a cleaned value of the matched substring, with better presentation formatting (punctuation marks removed, duplicate spaces, ...)
Return the depth of this node.
Return the list of absolute spans for the regions of the original string defined by splitting this node at the given indices (relative to this node)
Return a dict containing all the info guessed by this node, subnodes included.
Return whether this node is a leaf or not.
Return a generator over all the nodes that are leaves.
Return next leaf for this node
Return next leaves for this node
Return the node at the given index in the subtree rooted at this node.
Return this node’s index in the tree, as a tuple. If this node is the root of the tree, then return ().
Return all the nodes and subnodes in this tree.
Return all the nodes at a given depth in the tree
Partition this node by splitting it at the given indices, relative to this node.
Return previous leaf for this node
Return previous leaves for this node
Return the root node of the tree.
Return a readable string representation of this tree.
Return the substring that this node matches.
The MatchTree contains a few “utility” methods which are not necessary for the BaseMatchTree, but add a lot of convenience for writing higher-level rules.
Return the first leaf containing the given property.
Return whether the group was explicitly enclosed by parentheses/square brackets/etc.
Return a generator of leaves that guessed the given property.
Return a single guess that contains all the info found in the nodes of this tree, trying to merge properties as good as possible.
Return a generator of leaves containing the given property that are before the given node (in the string).
Return a generator of non-empty leaves that are before the given node (in the string).
Return a generator of leaves that are not empty.