Commits

Ches Martin committed 0b79e90

Avoid problems with SCM directories like .git, .hg, etc.

Use os.listdir instead of os.walk -- I don't see that there is any
need to traverse a directory hierarchy at this point.

Comments (0)

Files changed (1)

 
     def get_notes_from_local(self):
         notes = []
-        # For each file in the local directory
-        for dirpath, dirnames, filenames in os.walk(self.settings.local_dir):
-            for filename in filenames:
-                if filename.startswith('.') or filename in IGNORE_FILES:
-                    continue
-                note_path = os.path.join(dirpath, filename)
-                # For a local note the timestamp is just the files last modified date
-                last_modified = time.gmtime(os.stat(note_path).st_mtime)
-                # TODO: Will above work on Windows - or does time need to be treated differently???
-                # However its title is preferrably from the Title: metadata, if this does
-                # not exist then it will be the filename (minus the file extension)
-                f = open(note_path, 'r')
-                note_name = None
+        dirpath = self.settings.local_dir
+        for filename in os.listdir(dirpath):
+            if filename.startswith('.') or filename in IGNORE_FILES:
+                continue
+            note_path = os.path.join(dirpath, filename)
+            # For a local note the timestamp is just the files last modified date
+            last_modified = time.gmtime(os.stat(note_path).st_mtime)
+            # TODO: Will above work on Windows - or does time need to be treated differently???
+            # However its title is preferrably from the Title: metadata, if this does
+            # not exist then it will be the filename (minus the file extension)
+            f = open(note_path, 'r')
+            note_name = None
+            line = f.readline()
+            while line:
+                if line.startswith('Title: '):
+                    note_name = line.split(':', 1)[1].strip()
+                    break
                 line = f.readline()
-                while line:
-                    if line.startswith('Title: '):
-                        note_name = line.split(':', 1)[1].strip()
-                        break
-                    line = f.readline()
-                f.close()
-                if not note_name:
-                    # Remove any file extension
-                    note_name = filename.rsplit('.', 1)[0]
-                notes.append(Note(note_name, last_modified, local_path=note_path))
+            f.close()
+            if not note_name:
+                # Remove any file extension
+                note_name = filename.rsplit('.', 1)[0]
+            notes.append(Note(note_name, last_modified, local_path=note_path))
         return notes
 
     def get_notes_from_lastsync(self):