def generate_export_view(): feedback_items = [] todos = itemlist.get_todo_list() if len(todos) == 0: feedback_items.append(generate_noitems()) else: items = [] items.append({ 'title': 'Export all items as plain text', 'subtitle': 'Will be copied to your clipboard', 'arg': 'txt', 'icon': 'export_txt.png' }) todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: tags[i['group']].append(1) for tag in tags: if tag != 'default': items.append({ 'title': 'Export #' + tag, 'subtitle': 'Will be copied to your clipboard', 'arg': 'txt ' + tag, 'icon': 'export_txt.png' }) feedback_items = map(lambda x: generate_feedbackitem(x), items) alfred.write(alfred.xml(feedback_items))
def generate_view(query): if len(query) == 0 and config.get('todo.command.last') == 'quick_create': add_query = config.get('todo.user.query') add_tag = config.get('todo.tag.recent') itemlist.save_todo(add_query,silent=True) config.update_state(command='', query='') info = parser.parse(query) tag = info['tag'] q = info['task'] todos = itemlist.get_todo_list() # view for pinned items # pinned items should have unique uuid and different logo pinned = [t for t in todos if itemlist.feature(t,'pinned') == True] pinned = [t for t in pinned if (tag is None or t['group'] == tag)] pinned = [t for t in pinned if (q is None or t['title'].lower().find(q.lower()) >= 0)] pinned = pinned[::-1] # view for non-pinned items normal = [t for t in todos if itemlist.feature(t,'pinned') == False] normal = [t for t in normal if (tag is None or t['group'] == tag)] normal = [t for t in normal if (q is None or t['title'].lower().find(q.lower()) >= 0)] normal = normal[::-1] feedback_items = [] if len(normal) == 0 and len(pinned) == 0: feedback_items.append( generate_add_feedbackitem(query, info) ) else: pinned = map(lambda x: generate_pinned_feedbackitem(x), pinned) normal = map(lambda x: generate_todo_feedbackitem(x), normal) feedback_items = pinned + normal alfred.write(alfred.xml(feedback_items))
def generate_export_view(): feedback_items = [] todos = itemlist.get_todo_list() if len(todos) == 0: feedback_items.append(generate_noitems()) else: items = [] items.append({'title':'Export all items as plain text', 'subtitle':'Will be copied to your clipboard', 'arg':'txt', 'icon':'export_txt.png'}) todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: tags[i['group']].append(1) for tag in tags: if tag != 'default': items.append({'title':'Export #' + tag, 'subtitle':'Will be copied to your clipboard', 'arg':'txt ' + tag, 'icon':'export_txt.png'}) feedback_items = map(lambda x: generate_feedbackitem(x), items) alfred.write(alfred.xml(feedback_items))
def generate_export_view(): feedback_items = [] todos = itemlist.get_todo_list() if len(todos) == 0: feedback_items.append(generate_noitems()) else: items = [] items.append({'title': 'Export as plain text - clipboard', 'subtitle': '', 'arg': 'txt', 'icon': 'export_txt.png'}) # Export by tag name todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: tags[i['group']].append(1) for tag in tags: if tag != 'default': items.append({'title': u'Export #' + tag, 'subtitle': '{0} {1}'.format(len(tags[tag]), 'item' if len(tags[tag]) == 1 else 'items'), 'arg': 'txt ' + tag, 'icon': 'export_txt.png'}) feedback_items = map(lambda x: generate_feedbackitem(x), items) alfred.write(alfred.xml(feedback_items))
def generate_view(query): info = parser.parse(query) tag = info['tag'] task = info['task'] due = info['due'] todos = itemlist.get_todo_list() done = [t for t in todos if helpers.apply_filter(t, task, tag, due, q_done=True)] done = done[::-1] feedback_items = [] if len(done) == 0: feedback_items.append(generate_noitems_feedbackitem(query, info)) else: done = map(lambda x: generate_done_feedbackitem(x, info), done) feedback_items = done alfred.write(alfred.xml(feedback_items))
def export_txt(_tag=None): todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: tags[i['group']].append({ 'title': i['title'], 'created': i['created'], 'pinned': itemlist.feature(i, 'pinned'), 'rating': itemlist.feature(i, 'rating') }) for tag in tags: if _tag is None or tag == _tag: print '#' + tag pinned = [t for t in tags[tag] if t['pinned']] normal = [t for t in tags[tag] if not t['pinned']] for todo in pinned: print todo['title'] + ' [pinned]' for todo in normal: print todo['title'] print " "
def export_txt(_tag=None): todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: tags[i['group']].append( { 'title' : i['title'], 'created': i['created'], 'pinned' : itemlist.feature(i,'pinned'), 'rating' : itemlist.feature(i,'rating') } ) for tag in tags: if _tag is None or tag==_tag: print '#' + tag pinned = [t for t in tags[tag] if t['pinned']] normal = [t for t in tags[tag] if not t['pinned']] for todo in pinned: print todo['title'] + ' [pinned]' for todo in normal: print todo['title'] print " "
def export_txt(_tag=None): todos = itemlist.get_todo_list() tags = defaultdict(list) for i in todos: if not itemlist.feature(i, 'done'): tags[i['group']].append( { 'title': i['title'], 'created': i['created'], 'pinned': itemlist.feature(i, 'pinned'), 'due': itemlist.feature(i, 'due') } ) sorted_tags = sorted(tags, key=lambda x: x) for tag in sorted_tags: if _tag is None or tag == _tag: print u'#' + tag.encode('utf-8') pinned = [t for t in tags[tag] if t['pinned']] normal = [t for t in tags[tag] if not t['pinned']] for todo in pinned: print get_todo_text(todo) for todo in normal: print get_todo_text(todo) print " "