Commits

edgimar  committed d17eeb3

- rename functions/methods:
- tree.last() -> tree.last_task_node_at_level()
- parse_text() -> parse_text_to_tree()

  • Participants
  • Parent commits 73bb509

Comments (0)

Files changed (1)

File michel/michel.py

         
     def __delitem__(self, key):
         del(self.subtasks[key])
-    
+
     def __len__(self):
         return len(self.subtasks)
 
                 raise ValueError, "No element with suitable parent id"
             self.get_task_with_id(parent_id).add_subtask(title, task_id, None,
                     task_notes, task_status)
-    
+
     def add_subtree(self, tree_to_add, include_root=False, root_title=None,
             root_notes=None):
         """Add *tree_to_add* as a subtree of this tree.
                 tree_to_add.notes = root_notes
             
             self.subtasks.append(tree_to_add)
-    
-    def last(self, level):
+
+    def last_task_node_at_level(self, level):
         """Return the last task added at a given level of the tree.
         
         Level 0 is the "root" node of the tree, and there is only one node at
         else:
             res = None
             for subtask in self.subtasks:
-                x = subtask.last(level - 1)
+                x = subtask.last_task_node_at_level(level - 1)
                 if x is not None:
                     res = x
             if res is not None:
     new = str(new_tree)
     merged_text, conflict_occurred = diff3.merge3_text(new, old, other)
     
-    merged_tree = parse_text(merged_text)
+    merged_tree = parse_text_to_tree(merged_text)
     
     return merged_tree, conflict_occurred
  
     """Parses an org-mode file and returns a tree"""
     file_lines = open(path, "r").readlines()
     file_text = "".join(file_lines)
-    return parse_text(file_text)
+    return parse_text_to_tree(file_text)
     
-def parse_text(text):
+def parse_text_to_tree(text):
     """Parses an org-mode formatted block of text and returns a tree"""
     # create a (read-only) file object containing *text*
     f = cStringIO.StringIO(text)
             
             if seen_first_task:
                 # add the task to the tree
-                tasks_tree.last(indent_level).add_subtask(
+                tasks_tree.last_task_node_at_level(indent_level).add_subtask(
                         title=task_title,
                         task_notes=task_notes,
                         task_status=task_status)
                     # this means there was some text at the beginning of the
                     # file before any headline was encountered.  We create a
                     # dummy headline to contain this text.
-                    tasks_tree.last(0).add_subtask(
+                    tasks_tree.last_task_node_at_level(0).add_subtask(
                             title="",
                             task_notes=task_notes,
                             task_status=None)
     # again after the last line of the file (tasks are added at beginning
     # of the for loop)
     if task_title is not None:
-        tasks_tree.last(indent_level).add_subtask(
+        tasks_tree.last_task_node_at_level(indent_level).add_subtask(
                 title=task_title,
                 task_notes=task_notes,
                 task_status=task_status)
     else: # there are no headlines in the org-file; create a dummy headline
-        tasks_tree.last(0).add_subtask(
+        tasks_tree.last_task_node_at_level(0).add_subtask(
                 title="",
                 task_notes=task_notes,
                 task_status=None)