def stat_command(path=None): check_path(path) print("Goals count: %s" % len(query_nodes(path, '*', ''))) print("Goals done: %s" % len(query_nodes(path, 'icon-%s' % BTN_OK, ''))) print("Goals canceled: %s" % len(query_nodes(path, 'icon-%s' % BTN_CANCEL, ''))) print("Goals stoped: %s" % len(query_nodes(path, 'icon-%s' % BTN_STOP, ''))) node = freemind.freemind_load(path) print("Goals in progress: %s" % len(freemind.select_bottom(node)))
def questions_command(path=None): check_path(path) def fn_list(n): if not hasattr(fn_list, 'counter'): fn_list.counter = 1 if n.has_attr('@ICON') and 'help' in n.get_attr('@ICON'): print("%s. %s\n %s\n" % (fn_list.counter, n.get_title(), n.get_content())) fn_list.counter += 1 result = freemind.freemind_load(path) freemind.traverse(result, fn_list)
def estimate_command(path=None, format=' - {grandparent}/{parent}/{title}, {@estimate}h'): check_path(path) def fn_list(n): if not hasattr(fn_list, 'result'): fn_list.result = [] fn_list.total = 0 if n.has_attr('estimate'): if n.has_attr('@ICON') and BTN_STOP in n.get_attr('@ICON'): return fn_list.result.append(format_node(n, format)) fn_list.total += float(n.get_attr('estimate')) result = freemind.freemind_load(path) freemind.traverse(result, fn_list) [print(i) for i in sorted(fn_list.result)] print("\nTotal: %sh" % fn_list.total)
def spec_command(path=None, parts=None, out=None): check_path(path) doc = freemind.freemind_load(path) if out: output = open(out, "w", encoding="utf-8") def process_node(n, level): result = level * '#' + ' ' + n.get_title() + "\n\n" # print(level * '#' + ' ' + n.get_title()) if n.has_content(): result += n.get_content() + "\n\n" if out: output.write(result) else: print(result) def fn_list(nodes, level): if not nodes: return for n in nodes: process_node(n, level) fn_list(n, level + 1) if parts is None: pass else: for part in parts.split(';'): nodes = nodes_select(doc, "title:%s" % part) fn_list(nodes, 1) # print(nodes) if out: output.close()
def query_nodes(path=None, select='', filter=''): check_path(path) doc = freemind.freemind_load(path) result = nodes_select(doc, select) result = nodes_filter(result, filter) return result
def test_bottom(self): result = freemind_load('Test.mm') bottom = select_bottom(result) self.assertEqual('In progress', bottom[0].get_title()) self.assertEqual('Canceled', bottom[1].get_title())
def test_content2(self): doc = freemind_load('Test.mm') node = doc[0][1] self.assertEqual('Stop', node.get_title())
def test_content(self): doc = freemind_load('Test.mm') node = doc[0][2] self.assertEqual('In progress', node.get_title()) self.assertEqual("abc\ndef", node.get_content())
def test_traverse(self): doc = freemind_load('Test.mm') nodes = traverse(doc, lambda n: n.get_title() == 'Task1') self.assertEqual(1, len(nodes)) self.assertEqual('Task1', nodes[0].get_title())