def eql_fn(o_node, a_node): result = False if isinstance(o_node, o.HeadlineNode): if isinstance(a_node, a.TaskNode): completed_from_type = {'TODO': False, 'DONE': True} tests = [ (a_node.name == o_node.title), (getattr(a_node, 'notes', None) == getattr(o_node, 'paragraph', None)), (a_node.completed == completed_from_type[o_node.todo_type]), (a_node.id == lib.safe_int(getattr(o_node, 'asana_id', None))), (a_node.project_id == lib.safe_int( getattr(o_node, 'asana_project_id', None))), (getattr(o_node, 'deadline', None) == (getattr(a_node, 'due_at', None) or (getattr(a_node, 'due_on', None)))), (getattr(a_node, 'tags', None) == (getattr(o_node, 'tags', None))) ] result = all(tests) elif isinstance(o_node, o.FilenameNode): if isinstance(a_node, a.ProjectNode): tests = [(a_node.name == lib.basename_no_ext(o_node.id)), (a_node.id == lib.safe_int( getattr(o_node, 'asana_project_id', None)))] result = all(tests) return result
def make_fn(asana_source, o_node): asana_dict = {'id': None, 'parent': None} a_node = None if isinstance(o_node, o.HeadlineNode): asana_dict['name'] = o_node.title if getattr(o_node, 'paragraph', None): asana_dict['notes'] = o_node.paragraph if getattr(o_node, 'todo_type', None): asana_dict['completed'] = COMPLETED_FROM_TYPE.get( o_node.todo_type) if getattr(o_node, 'deadline', None): if re.match("[0-9]{4}-[0-9]{2}-[0-9]{2}$", o_node.deadline): asana_dict['due_on'] = o_node.deadline else: asana_dict['due_at'] = o_node.deadline if hasattr(o_node, 'tags'): asana_dict['tags'] = o_node.tags a_node = asana_source.make_task_node(asana_dict) elif isinstance(o_node, o.FilenameNode): asana_dict['name'] = h.basename_no_ext(o_node.id) a_node = asana_source.make_project_node(asana_dict) return a_node
def map_fn(o_node, a_node): result = False if isinstance(o_node, o.HeadlineNode): if isinstance(a_node, a.TaskNode): o_node_asana_id = lib.safe_int(getattr(o_node, 'asana_id', None)) if o_node_asana_id is None: result = o_node.title == a_node.name else: result = o_node_asana_id == a_node.id elif isinstance(o_node, o.FilenameNode): if isinstance(a_node, a.ProjectNode): o_node_project_id = lib.safe_int( getattr(o_node, 'asana_project_id', None)) if o_node_project_id is None: result = lib.basename_no_ext(o_node.id) == a_node.name else: result = o_node_project_id == a_node.id return result
def eql_fn(a_node, o_node): result = False if isinstance(a_node, a.TaskNode): if isinstance(o_node, o.HeadlineNode): tests = [ (a_node.name == o_node.title), (getattr(a_node, 'notes', None) == getattr(o_node, 'paragraph', None)), (a_node.completed == COMPLETED_FROM_TYPE[o_node.todo_type]), (getattr(o_node, 'deadline', None) == (getattr(a_node, 'due_at', None) or (getattr(a_node, 'due_on', None)))), (getattr(a_node, 'tags', None) == getattr(o_node, 'tags', None))] result = all(tests) elif isinstance(a_node, a.ProjectNode): if isinstance(o_node, o.FilenameNode): result = (a_node.name == h.basename_no_ext(o_node.id)) return result