From 04bb97442c1b7d032748cc9627a3635dd4acf540 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 20 Mar 2012 19:27:49 -0700 Subject: [PATCH] inotify: Outdent conditions for readability Add `continue` statements so that the code stays nice and flat. We were getting a little too nested in here. Signed-off-by: David Aguilar --- cola/inotify.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/cola/inotify.py b/cola/inotify.py index f365adfc..e48bc1e8 100644 --- a/cola/inotify.py +++ b/cola/inotify.py @@ -209,7 +209,7 @@ class GitNotifier(QtCore.QThread): def run_win32(self): """Generate notifications using pywin32""" - hDir = win32file.CreateFile( + hdir = win32file.CreateFile( self._path, 0x0001, win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE, @@ -232,21 +232,19 @@ class GitNotifier(QtCore.QThread): handler = Handler() while self._running: - win32file.ReadDirectoryChangesW(hDir, - buf, - True, - flags, - overlapped) - - rc = win32event.WaitForSingleObject(overlapped.hEvent, self._timeout) - if rc == win32event.WAIT_OBJECT_0: - nbytes = win32file.GetOverlappedResult(hDir, overlapped, True) - if nbytes: - results = win32file.FILE_NOTIFY_INFORMATION(buf, nbytes) - for action, path in results: - if not self._running: - break - - path = path.replace('\\', '/') - if not path.startswith('.git/') and os.path.isfile(path): - handler.handle(path) + win32file.ReadDirectoryChangesW(hdir, buf, True, flags, overlapped) + + rc = win32event.WaitForSingleObject(overlapped.hEvent, + self._timeout) + if rc != win32event.WAIT_OBJECT_0: + continue + nbytes = win32file.GetOverlappedResult(hdir, overlapped, True) + if not nbytes: + continue + results = win32file.FILE_NOTIFY_INFORMATION(buf, nbytes) + for action, path in results: + if not self._running: + break + path = path.replace('\\', '/') + if not path.startswith('.git/') and os.path.isfile(path): + handler.handle(path) -- 2.11.4.GIT