freeplane module

class freeplane.EncryptedNodeState(wrapper_node: object, decrypted_root: object = None, password: str = '', original_payload: str = '', cipher: object = None, is_unlocked: bool = False, is_dirty: bool = False, encryption_enabled: bool = True)

Bases: object

Hold runtime state for an encrypted Freeplane wrapper node.

The raw lxml tree keeps Freeplane’s persisted wrapper node unchanged. When a password is available, the decrypted subtree is stored separately and can be exposed through Node accessors without losing round-trip fidelity when saving the map later.

Attributes:

wrapper_node: The original wrapper node from the loaded lxml tree. decrypted_root: The decrypted subtree root, if available. password: The password that successfully decrypted the subtree. original_payload: The original ENCRYPTED_CONTENT value from the file. cipher: The cipher instance that successfully decrypted this node. is_unlocked: Whether decrypted_root currently holds valid content. is_dirty: Whether the decrypted subtree was modified in memory.

cipher: object = None
decrypted_root: object = None
encryption_enabled: bool = True
is_dirty: bool = False
is_unlocked: bool = False
original_payload: str = ''
password: str = ''
wrapper_node: object
class freeplane.Mindmap(path='', mtype='freeplane', version='1.3.0', encryption_passwords=None, _id='', log_level='')

Bases: object

representation of Freeplane mindmap file as a container for nodes. access styles and other general features from here.

add_password(password)

Add a preferred encryption password for this map.

Args:

password: Password string to append if not already present.

add_style(name='', settings={})

This functions adds a style to a mindmap

clear_passwords()

Remove all map-specific preferred encryption passwords.

classmethod create_node(core='', link='', id='', style='', modified='', created='')
classmethod create_node_id(mindmap=None)

create a valid node id. this node id is incremented automatically, whenever a new XML node is created. even if it is discarded later. the node id, here consists of three parts:

  1. the id token “ID_” which is used for all nodes directly created within freeplane editor

  2. and kind of session seed which is the current date

  3. and a standard 4-digit integer value constantly incremented

find_nodes(core='', link='', id='', attrib='', details='', notes='', icon='', style=[], exact=False, generalpathsep=False, caseinsensitive=False, keep_link_specials=False, regex=False)
classmethod get_num_of_maps()

return the number of maps already created within the current session

Returns:

integer

property passwords

Return the map-specific list of preferred encryption passwords.

classmethod print_tree(node=None, max_depth=0, current_depth=0, indent='  ', _node=None)

print tree structure until a specified depth

Parameters:
  • node – Freeplane node element (node)

  • max_depth – max recursion depth (0 = only base node)

  • current_depth – current depth (internal)

  • indent – indentation for each layer

property rootnode
save(strPath, encoding='')
set_passwords(passwords)

Replace the map-specific list of preferred encryption passwords.

Args:

passwords: Iterable of password strings in preferred order.

property styles
test()
unlock_encrypted_nodes(passwords=None)

Try to unlock registered encrypted wrapper nodes with preferred passwords.

Args:

passwords: Optional iterable of passwords to try in order.

Returns:

int: Number of nodes that were successfully unlocked.

class freeplane.Node(xmlnode, mindmap)

Bases: object

representation of Freeplane node elements found within a mindmap. all the node-related features can be accessed from here.

draw an arrow link from the current node to the given one.

the arrow starts at the host object and extends to an arbitrary node. it’s appearance can be configured using the following parameters:

Parameters:
  • node (freeplane.Node) – the node object an arrow is to be drawn to

  • shape (string) – the shape of the arrow (e.g. “CUBIC_CURVE”)

  • color (string) – the color of the arrow (e.g. “#FF0000” for red)

  • transparency (string) – the transparency of the arrow over the background (e.g. “80” for 80%)

add_attribute(key='', value='')

This functions adds an attribute to a node

add_child(core='', link='', id='', pos=-1, style='')

This functions adds a Freeplane-Node as a child to this Node. Further more a XML-node ist added to the XML-Tree

add_icon(icon='')

This functions adds a Freeplane-Icon to a node

add_sibling(core='', link='', id='', pos=-1, style=None)

This functions adds a Freeplane-Node as a Sibling. Further more a XML-node ist added to the XML-Tree at the corresponding position

property arrowlinked

get list of nodes connecting to the node (incoming arrowlinks)

Returns:

list of Node elements

get list of nodes connected via outgoing arrowlinks

Returns:

list of Node elements

attach(attached_node=None, pos=-1)

This functions appends an existing but previously detached Freeplane-Node as a child to this node object.

property attributes
property children
property comment
property creationdate
decrypt(password='')

Unlock this encrypted wrapper node for in-memory access.

remove arrowlink from node

Parameters:

ident (Node - the target node reference itself int - the index of target node according to the return of the arrowlinks method str - the node id of the target node to which the connection is to be removed) – identifier for node to which the arrowlink connection is to be removed

Returns:

True - if the desired coonnection was removed False - if target node could not be found

del_icon(icon='')

This functions removes a Freeplane-Icon from a node

property details
encrypt(password='')

Backward-compatible alias for set_encryption_password().

find_children(core='', link='', id='', attrib='', details='', notes='', icon='', style=[], exact=False, generalpathsep=False, caseinsensitive=False, keep_link_specials=False, regex=False)
find_nodes(core='', link='', id='', attrib='', details='', notes='', icon='', style=[], exact=False, generalpathsep=False, caseinsensitive=False, find_in_self=False, keep_link_specials=False, regex=False)
getSubText(token='')
get_child_by_index(idx=0)
get_indexchain_until(node)

determine the list of index values which have to be used in order to find the given node. the process is started from the self object and continued until the given node was found. the actual implementation works from backwards. starting at the given node and determining its parents until the base node (self) was found. then reversing the list order.

property has_children
property icons
property id
property imagepath
property imagesize
property index
property is_comment
is_descendant_of(node)

determine if the current node object has a direct relational connection to a given node element. so, if the current node object is a child, grand-child, … of that given node element.

property is_detached_head

check if node is the head node of a detached branch.

property is_detached_node

check if node is belonging to a detached branch.

property is_encrypted

Check whether this node is an encrypted Freeplane wrapper node.

property is_html_format
property is_map_node

check if node is belonging to a map, but not being the root node.

property is_root_node

check if node is the map’s root node.

property is_rootnode
property is_unlocked

Check whether this encrypted wrapper node has decrypted shadow content.

iter_tree(max_depth=100000, track_depth=False, _current_depth=0, _node=None, _current_node=None)

iterate tree structure recursively until a specified depth

Parameters:
  • max_depth – max recursion depth (0 = only base node)

  • track_depth – set to True if return of node AND respective depth desired

  • _current_depth – current level below base node (internal)

  • _node – xmlnode when recursion has started (internal)

lock()

Drop decrypted shadow content for this encrypted wrapper node.

property max_width
property min_width
property modificationdate
property next
property notes

get the value of the node’s notes attribute.

Returns:

the plaintext value of the notes attribute (preserving newlines)

Return type:

string

property parent
property plaintext
property previous
print_tree(max_depth=0, current_depth=0, indent='  ')

print tree structure until a specified depth

Parameters:
  • max_depth – max recursion depth (0 = only base node)

  • current_depth – current depth (internal)

  • indent – indentation for each layer

remove()

This functions removes the current Freeplane node from a branch

remove_attribute(key='')

This functions removes the node’s existing attribute

set_attribute(key='', value='')

This functions sets an attribute for a node

set_encryption_password(password='')

Configure encryption for this node for future save operations.

A non-empty password enables encrypted persistence. An empty string neutralizes encryption for an already unlocked encrypted node so that future saves write the expanded subtree in plaintext form.

set_image(link='', size='1', modified='')
property style
unlock(password='')

Try to unlock this encrypted wrapper node.

Args:

password: Optional explicit password override.

Returns:

bool: True if this node is unlocked after the call.

property visibletext

using Groovy scripting or formulas, it is possible to show a distant node’s content within the local node by e.g. inserting

= ID_12345678.text

into the local node. When using the “plaintext” attribute, this small formula is returned as is, but when using the new “visibletext” attribute, the text string of the distant node with id ID_12345678 (as visible within the local node) is returned.

In case, there is no core-linked content, this attribute behaves like the “plaintext” attribute.

class freeplane.TextExtractor

Bases: HTMLParser

get_text()
handle_data(data)
freeplane.extract_sanitized_body_content(body_elem)
freeplane.extract_text_from_html(html_code: str) str
freeplane.match_textual_content(search='', text='', regex=False, exact=False, caseinsensitive=False)
freeplane.reduce_node_objects(lstNodes=[], id='', core='', attrib='', details='', notes='', link='', icon='', style=[], exact=False, generalpathsep=False, caseinsensitive=False, keep_link_specials=False, regex=False)

Filter Node objects using logical node semantics.

This variant is aware of decrypted virtual subtrees exposed by unlocked encrypted wrapper nodes because it relies on Node properties instead of raw XML traversal.

freeplane.sanitized(text)