Exemple #1
0
 def dispatch(self, event):
     """
     Only dispatch an event if it satisfies our requirements.
     """
     if event.is_directory \
     or valid_note(event.src_path) \
     and (not hasattr(event, 'dest_path') or valid_note(event.dest_path)):
         super(Handler, self).dispatch(event)
Exemple #2
0
 def contents(self):
     """names of all files and directories
     in this notebook, _not_ recursively"""
     notebooks, notes = [], []
     for name in os.listdir(self.path.abs):
         p = os.path.join(self.path.abs, name)
         if os.path.isfile(p) and valid_note(p):
             notes.append(Note(p))
         else:
             if valid_notebook(p):
                 notebooks.append(Notebook(p))
     return notebooks, notes
Exemple #3
0
 def contents(self):
     """names of all files and directories
     in this notebook, _not_ recursively"""
     notebooks, notes = [], []
     for name in os.listdir(self.path.abs):
         p = os.path.join(self.path.abs, name)
         if os.path.isfile(p) and valid_note(p):
             notes.append(Note(p))
         else:
             if valid_notebook(p):
                 notebooks.append(Notebook(p))
     return notebooks, notes
Exemple #4
0
    def walk(self):
        """walks the notebook, yielding only
        valid directories and files."""
        for root, dirs, files in os.walk(self.path.abs):
            if valid_notebook(root):
                notebooks, notes = [], []
                for dir in dirs:
                    path = os.path.join(root, dir)
                    if valid_notebook(path):
                        notebooks.append(Notebook(path))
                for file in files:
                    if valid_note(file):
                        path = os.path.join(root, file)
                        notes.append(Note(path))

                yield root, notebooks, notes
Exemple #5
0
    def walk(self):
        """walks the notebook, yielding only
        valid directories and files."""
        for root, dirs, files in os.walk(self.path.abs):
            if valid_notebook(root):
                notebooks, notes = [], []
                for dir in dirs:
                    path = os.path.join(root, dir)
                    if valid_notebook(path):
                        notebooks.append(Notebook(path))
                for file in files:
                    if valid_note(file):
                        path = os.path.join(root, file)
                        notes.append(Note(path))

                yield root, notebooks, notes