Nikolaj Sjujskij  committed 99a388a

Fix imports, docstrings, newlines and other stuff

  • Participants
  • Parent commits 8ec4cc6
  • Branches default

Comments (0)

Files changed (1)


 Distributed under the terms of the GNU General Public License v3
-from optparse import OptionParser, OptionGroup
+from optparse import OptionParser
 import os.path
+import time
 import inotifyx
 import docutils.core
 from pygments import highlight
-from pygments.lexers import guess_lexer, guess_lexer_for_filename
+from pygments.lexers import guess_lexer_for_filename
 from pygments.formatters import TerminalFormatter
 implemented_actions = {}
 def register_action(name=None, catalogue=implemented_actions):
-    ''' Registration decorator, maintaining dictionary of implemented actions'''
+    ''' Registration decorator, maintaining dict of implemented actions'''
     name = name or f.__name__
     def register_closure(f):
         catalogue[name] = f
         def tmp(*args, **kwargs):
             return f(*args, **kwargs)
         return tmp
     return register_closure
 def highlight_watched(filename):
     ''' File contents highlighter '''
 def view_rst_as_html(filename):
     ''' Function converting reStructuredText to HTML for display in browser '''
     docutils.core.publish_file(source_path=filename, destination_path=htmlfile,
 def ino_watch(file_to_watch, action, action_args=[], action_kwargs={}):
-    ''' ``inotify``-based watcher, applying function on modification events '''
+    ''' ``inotify``-based watcher, applying function upon
+        *write-and-close* events '''
     watcher = inotifyx.init()
     dirname = os.path.dirname(file_to_watch) or '.'
     basename = os.path.basename(file_to_watch)
             action(file_to_watch, *action_args, **action_kwargs)
         events = inotifyx.get_events(watcher)
 def main():
     ''' Mainloop function handling arguments and control flow '''
     usage = '''Usage: %prog [options] file_to_watch'''
     if len(args) > 1:
         print("How should I know what to watch from this list?\n"
               "Watching only first one, '%s'" % args[0])
-        sleep(7)
+        time.sleep(7)
     file_to_watch = args[0]
     action = implemented_actions.get(options.action)
     if not action:
     except KeyboardInterrupt:
         print('\nCaught keyboard interrupt, exiting')
 if __name__ == "__main__":