Ejemplo n.º 1
0
 def ask_time(self, prompt='', default=None):
     """ interactively ask the user for time string
     """
     if default:
         default_time_str = isotime(default)
         extra_text = '[%s]' % default_time_str
         prompt = '%s %s: ' % (prompt, extra_text)
         time_str = interact.readstr(prompt)
         time_str = time_str if time_str else default_time_str
     else:
         prompt = '%s: ' % prompt
         time_str = interact.readstr(prompt)
     if time_str:
         second = strtosecond(time_str)
         return second
     else:
         print('bad value, exit')
         exit(1)
Ejemplo n.º 2
0
 def ask_time(self, prompt='', default=None):
     """ interactively ask the user for time string
     """
     if default:
         default_time_str = isotime(default)
         extra_text = '[%s]' % default_time_str
         prompt = '%s %s: ' % (prompt, extra_text)
         time_str = interact.readstr(prompt)
         time_str = time_str if time_str else default_time_str
     else:
         prompt = '%s: ' % prompt
         time_str = interact.readstr(prompt)
     if time_str:
         second = strtosecond(time_str)
         return second
     else:
         print('bad value, exit')
         exit(1)
Ejemplo n.º 3
0
 def list(self):
     cont = self.opendb()
     notes = sorted(cont.items(), key=lambda x: int(x[0]))
     text_list = []
     for time, note in notes:
         text = isotime(int(time)) + '\n' + note.content[:80]
         text_list.append(text)
     res = interact.printAndPick(text_list)
     if res:
         idx = res[0]
     else:
         return
     key = notes[idx][0]
     note = notes[idx][1]
     print('-' * 80)
     print('Book: %s' % note.book)
     print('Chapter: %s' % note.chapter)
     print('Subject: %s' % note.subject)
     print('Content:\n%s' % note.content)
Ejemplo n.º 4
0
 def list(self):
     cont = self.opendb()
     notes = sorted(cont.items(), key=lambda x: int(x[0]))
     text_list = []
     for time, note in notes:
         text = isotime(int(time)) + '\n' + note.content[:80]
         text_list.append(text)
     res = interact.printAndPick(text_list)
     if res:
         idx = res[0]
     else:
         return
     key  = notes[idx][0]
     note = notes[idx][1]
     print('-' * 80)
     print('Book: %s' % note.book)
     print('Chapter: %s' % note.chapter)
     print('Subject: %s' % note.subject)
     print('Content:\n%s' % note.content)
Ejemplo n.º 5
0
    def edit(self):
        """ change an existing note
        """
        cont = self.opendb()
        notes = sorted(cont.items(), key=lambda x: int(x[0]))
        text_list = []
        for time, note in notes:
            text = isotime(int(time)) + '\n' + note.content[:80]
            text_list.append(text)
        idx, junk = interact.printAndPick(text_list)

        key = notes[idx][0]
        note = notes[idx][1]

        prompt = 'Chapter [%s]: ' % note.chapter
        note.chapter = interact.readint(prompt, default=note.chapter)
        prompt = 'Subject [%s]: ' % note.subject
        note.subject = interact.readstr(prompt, default='') or note.subject
        note.content = self.edit_content(data=note.content)
        self.save(key, note)
Ejemplo n.º 6
0
    def edit(self):
        """ change an existing note
        """
        cont = self.opendb()
        notes = sorted(cont.items(), key=lambda x: int(x[0]))
        text_list = []
        for time, note in notes:
            text = isotime(int(time)) + '\n' + note.content[:80]
            text_list.append(text)
        idx, junk = interact.printAndPick(text_list)

        key  = notes[idx][0]
        note = notes[idx][1]

        prompt = 'Chapter [%s]: ' % note.chapter
        note.chapter = interact.readint(prompt, default=note.chapter)
        prompt = 'Subject [%s]: ' % note.subject
        note.subject = interact.readstr(prompt, default='') or note.subject
        note.content = self.edit_content(data=note.content)
        self.save(key, note)