# HG changeset patch # User Nicolas Dumazet # Date 2009-05-10 23:19:28 # Node ID 1536501ade621989a164c5d85c3bb0db24f1d476 # Parent 483d9b2103da22486521648def7d15b65a0689c8 inotify: Coding Style: name classes in lowercase. diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py --- a/hgext/inotify/__init__.py +++ b/hgext/inotify/__init__.py @@ -25,7 +25,7 @@ def serve(ui, repo, **opts): class service: def init(self): try: - self.master = server.Master(ui, repo, timeout) + self.master = server.master(ui, repo, timeout) except server.AlreadyStartedException, inst: raise util.Abort(str(inst)) diff --git a/hgext/inotify/linux/watcher.py b/hgext/inotify/linux/watcher.py --- a/hgext/inotify/linux/watcher.py +++ b/hgext/inotify/linux/watcher.py @@ -11,12 +11,12 @@ The inotify subsystem provides an efficient mechanism for file status monitoring and change notification. -The Watcher class hides the low-level details of the inotify +The watcher class hides the low-level details of the inotify interface, and provides a Pythonic wrapper around it. It generates events that provide somewhat more information than raw inotify makes available. -The AutoWatcher class is more useful, as it automatically watches +The autowatcher class is more useful, as it automatically watches newly-created directories on your behalf.''' __author__ = "Bryan O'Sullivan " @@ -29,7 +29,7 @@ import os import termios -class Event(object): +class event(object): '''Derived inotify event class. The following fields are available: @@ -72,7 +72,7 @@ class Event(object): def __repr__(self): r = repr(self.raw) - return 'Event(path=' + repr(self.path) + ', ' + r[r.find('(')+1:] + return 'event(path=' + repr(self.path) + ', ' + r[r.find('(')+1:] _event_props = { @@ -100,12 +100,12 @@ for k, v in _event_props.iteritems(): return self.mask & mask getter.__name__ = k getter.__doc__ = v - setattr(Event, k, property(getter, doc=v)) + setattr(event, k, property(getter, doc=v)) del _event_props -class Watcher(object): +class watcher(object): '''Provide a Pythonic interface to the low-level inotify API. Also adds derived information to each event that is not available @@ -177,7 +177,7 @@ class Watcher(object): events = [] for evt in inotify.read(self.fd, bufsize): - events.append(Event(evt, self._wds[evt.wd][0])) + events.append(event(evt, self._wds[evt.wd][0])) if evt.mask & inotify.IN_IGNORED: self._remove(evt.wd) elif evt.mask & inotify.IN_UNMOUNT: @@ -265,8 +265,8 @@ class Watcher(object): return [w for w in self.add_iter(path, mask, onerror)] -class AutoWatcher(Watcher): - '''Watcher class that automatically watches newly created directories.''' +class autowatcher(watcher): + '''watcher class that automatically watches newly created directories.''' __slots__ = ( 'addfilter', @@ -284,13 +284,13 @@ class AutoWatcher(Watcher): True, the directory will be watched if it still exists, otherwise, it will beb skipped.''' - super(AutoWatcher, self).__init__() + super(autowatcher, self).__init__() self.addfilter = addfilter _dir_create_mask = inotify.IN_ISDIR | inotify.IN_CREATE def read(self, bufsize=None): - events = super(AutoWatcher, self).read(bufsize) + events = super(autowatcher, self).read(bufsize) for evt in events: if evt.mask & self._dir_create_mask == self._dir_create_mask: if self.addfilter is None or self.addfilter(evt): @@ -305,7 +305,7 @@ class AutoWatcher(Watcher): return events -class Threshold(object): +class threshold(object): '''Class that indicates whether a file descriptor has reached a threshold of readable bytes available. diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py --- a/hgext/inotify/server.py +++ b/hgext/inotify/server.py @@ -113,7 +113,7 @@ def _explain_watch_limit(ui, repo, count raise util.Abort(_('cannot watch %s until inotify watch limit is raised') % repo.root) -class RepoWatcher(object): +class repowatcher(object): poll_events = select.POLLIN statuskeys = 'almr!?' mask = ( @@ -136,11 +136,11 @@ class RepoWatcher(object): self.timeout = None self.master = master try: - self.watcher = watcher.Watcher() + self.watcher = watcher.watcher() except OSError, err: raise util.Abort(_('inotify service not available: %s') % err.strerror) - self.threshold = watcher.Threshold(self.watcher) + self.threshold = watcher.threshold(self.watcher) self.registered = True self.fileno = self.watcher.fileno @@ -542,7 +542,7 @@ class RepoWatcher(object): def shutdown(self): self.watcher.close() -class Server(object): +class server(object): poll_events = select.POLLIN def __init__(self, ui, repo, repowatcher, timeout): @@ -658,13 +658,13 @@ class Server(object): if err.errno != errno.ENOENT: raise -class Master(object): +class master(object): def __init__(self, ui, repo, timeout=None): self.ui = ui self.repo = repo self.poll = select.poll() - self.repowatcher = RepoWatcher(ui, repo, self) - self.server = Server(ui, repo, self.repowatcher, timeout) + self.repowatcher = repowatcher(ui, repo, self) + self.server = server(ui, repo, self.repowatcher, timeout) self.table = {} for obj in (self.repowatcher, self.server): fd = obj.fileno() @@ -727,7 +727,7 @@ def start(ui, repo): except OSError: pass - m = Master(ui, repo) + m = master(ui, repo) sys.stdout.flush() sys.stderr.flush()