Esempio n. 1
0
 def remove(self, *items, **attr):
     '''
     >>> cl = Checklist(['a','b','c'])
     >>> cl.remove('a','b').items()
     ['c']
     '''
     items = [str(i) for i in flatten(items)]
     todos = [i for i in self.story if i.value in items]
     for todo in todos:
         self.story.remove(todo)
     return self
Esempio n. 2
0
 def remove(self, *items, **attr):
     '''
     >>> cl = Checklist(['a','b','c'])
     >>> cl.remove('a','b').items()
     ['c']
     '''
     items = [str(i) for i in flatten(items)]
     todos = [i for i in self.story if i.value in items]
     for todo in todos:
         self.story.remove(todo)
     return self
Esempio n. 3
0
 def __init__(self, items=[], title='', pretext=''):
     super(Checklist, self).__init__(title, pretext)
     FRAMEBREAK = PDF.Item(_type='FRAMEBREAK',\
                           order=len(self.story) + 1,\
                           data=FrameBreak())    
     self.story.append(FRAMEBREAK)
     NEXTPAGETEMPLATE = PDF.Item(_type='TEMPLATE',\
                                 order=len(self.story) + 1,\
                                 data=NextPageTemplate('LaterPages'))
     self.story.append(NEXTPAGETEMPLATE)
     if items:
         items = flatten(items)
         self.add(items)
Esempio n. 4
0
 def __init__(self, items=[], title='', pretext=''):
     super(Checklist, self).__init__(title, pretext)
     FRAMEBREAK = PDF.Item(_type='FRAMEBREAK',\
                           order=len(self.story) + 1,\
                           data=FrameBreak())
     self.story.append(FRAMEBREAK)
     NEXTPAGETEMPLATE = PDF.Item(_type='TEMPLATE',\
                                 order=len(self.story) + 1,\
                                 data=NextPageTemplate('LaterPages'))
     self.story.append(NEXTPAGETEMPLATE)
     if items:
         items = flatten(items)
         self.add(items)
Esempio n. 5
0
 def highlight(self, items, color='red'):
     items = [str(i) for i in flatten(items)]
     todo_index = [(i.order - 1) for i in self.story if i._type is 'TODO']
     values = [{self.story[i].value: i} for i in todo_index]
     value_dict = {}
     for value in values:
         value_dict.update(value)
     for item in items:
         index = value_dict[item]
         todo = self.story[index]
         todo.color = color
         todo.render(self.two_column)
         self.story[index] = todo            
     return self
Esempio n. 6
0
 def highlight(self, items, color='red'):
     items = [str(i) for i in flatten(items)]
     todo_index = [(i.order - 1) for i in self.story if i._type is 'TODO']
     values = [{self.story[i].value: i} for i in todo_index]
     value_dict = {}
     for value in values:
         value_dict.update(value)
     for item in items:
         index = value_dict[item]
         todo = self.story[index]
         todo.color = color
         todo.render(self.two_column)
         self.story[index] = todo
     return self
Esempio n. 7
0
 def add(self, *items, **attr):
     '''
     >>> c1 = Checklist()
     >>> c1.add('a').items()
     ['a']
     >>> c1.add(['b','c',1,2,3]).items()
     ['a', 'b', 'c', '1', '2', '3']
     
     >>> c2 = Checklist()
     >>> c2.add(1,2,3,'a','b','c').items()
     ['1', '2', '3', 'a', 'b', 'c']
     
     >>> c3 = Checklist()
     >>> c3.add('one','two','three').items()
     ['one', 'two', 'three']
     
     >>> c4 = Checklist()
     >>> c4.add('one long task').items()
     ['one long task']
     
     >>> c5 = Checklist('one long task')
     >>> c5.items()
     ['one long task']
     '''
     items = [str(i) for i in flatten(items)]
     row_color = 'black'
     complete = attr['complete'] if 'complete' in attr.keys() else False
     if 'color' in attr.keys() and not complete:
         try:
             row_color = attr['color']
         except:
             row_color = 'black'
     if complete:
         row_color = 'gray'
     for item in items:      
         
         TODO = Checklist.Todo(value=item,\
                               order=len(self.story) + 1,\
                               color=row_color)
         TODO.render(self.two_column)
         self.story.append(TODO)
         self.add_spacer(5)
     return self        
Esempio n. 8
0
    def add(self, *items, **attr):
        '''
        >>> c1 = Checklist()
        >>> c1.add('a').items()
        ['a']
        >>> c1.add(['b','c',1,2,3]).items()
        ['a', 'b', 'c', '1', '2', '3']
        
        >>> c2 = Checklist()
        >>> c2.add(1,2,3,'a','b','c').items()
        ['1', '2', '3', 'a', 'b', 'c']
        
        >>> c3 = Checklist()
        >>> c3.add('one','two','three').items()
        ['one', 'two', 'three']
        
        >>> c4 = Checklist()
        >>> c4.add('one long task').items()
        ['one long task']
        
        >>> c5 = Checklist('one long task')
        >>> c5.items()
        ['one long task']
        '''
        items = [str(i) for i in flatten(items)]
        row_color = 'black'
        complete = attr['complete'] if 'complete' in attr.keys() else False
        if 'color' in attr.keys() and not complete:
            try:
                row_color = attr['color']
            except:
                row_color = 'black'
        if complete:
            row_color = 'gray'
        for item in items:

            TODO = Checklist.Todo(value=item,\
                                  order=len(self.story) + 1,\
                                  color=row_color)
            TODO.render(self.two_column)
            self.story.append(TODO)
            self.add_spacer(5)
        return self
Esempio n. 9
0
 def check(self, *items, **keywords):
     '''
     >>> cl = Checklist(['a','b','c'])
     >>> cl.check('a','b','c').completed()
     ['a', 'b', 'c']
     '''
     items = [str(i) for i in flatten(items)]
     todo_index = [(i.order - 1) for i in self.story if i._type is 'TODO']
     values = [{self.story[i].value: i} for i in todo_index]
     value_dict = {}
     for value in values:
         value_dict.update(value)
     for item in items:
         index = value_dict[item]
         todo = self.story[index]
         todo.complete = True
         todo.color = 'gray'
         todo.render(self.two_column)
         self.story[index] = todo            
     return self
Esempio n. 10
0
 def check(self, *items, **keywords):
     '''
     >>> cl = Checklist(['a','b','c'])
     >>> cl.check('a','b','c').completed()
     ['a', 'b', 'c']
     '''
     items = [str(i) for i in flatten(items)]
     todo_index = [(i.order - 1) for i in self.story if i._type is 'TODO']
     values = [{self.story[i].value: i} for i in todo_index]
     value_dict = {}
     for value in values:
         value_dict.update(value)
     for item in items:
         index = value_dict[item]
         todo = self.story[index]
         todo.complete = True
         todo.color = 'gray'
         todo.render(self.two_column)
         self.story[index] = todo
     return self