Commits

Christian Ebert committed 4010488

Mandatory arguments in class init, reorder, omit ui

Classes which are only initialized from *command do not need
an ui argument.
Use options, arguments order.

  • Participants
  • Parent commits 7b6644e

Comments (0)

Files changed (8)

muttils/sigpager.py

     '''
     sigs = [] # complete list of signature strings
 
-    def __init__(self, parentui=None,
-                 dest=None, sig='', sdir='', sep='-- \n', tail=''):
-        self.ui = parentui or ui.ui()
+    def __init__(self, sig, sdir, tail, sep, dest):
+        self.ui = ui.ui()
         tpager.tpager.__init__(self, self.ui, name='sig',
                                fmt='bf', qfunc='default sig', ckey='/')
         self.ui.updateconfig()

muttils/sigpagercommand.py

     del parser
 
     try:
-        s = sigpager.signature(dest=args,
-                               sig=options.defsig, sdir=options.sigdir,
-                               tail=options.tail, sep=options.sigsep)
+        s = sigpager.signature(options.defsig, options.sigdir, options.tail,
+                               options.sigsep, args)
         s.sign()
     except (util.DeadMan, IOError, OSError), inst:
         sys.exit(inst)

muttils/urlbatcher.py

     Browses all urls or creates a message tree in mutt.
     You can specify urls/ids by a regex pattern.
     '''
-    def __init__(self, parentui=None, files=None, opts={}):
-        self.ui = parentui or ui.ui()
+    def __init__(self, opts, args):
+        self.ui = ui.ui()
         self.ui.updateconfig()
         self.ui.resolveopts(opts)
-        urlcollector.urlcollector.__init__(self, self.ui, files=files)
+        urlcollector.urlcollector.__init__(self, self.ui, args)
 
     def urlgo(self):
         if self.ui.proto == 'mid':

muttils/urlbatchercommand.py

     del parser
 
     try:
-        u = urlbatcher.urlbatcher(files=args, opts=options.__dict__)
+        u = urlbatcher.urlbatcher(options.__dict__, args)
         u.urlsearch()
     except (util.DeadMan, IOError, KeyboardInterrupt), inst:
         sys.exit(inst)

muttils/urlpager.py

 from muttils import iterm, kiosk, pybrowser, tpager, ui, util, wget
 
 class urlpager(urlcollector.urlcollector, tpager.tpager):
-    def __init__(self, parentui=None, files=None, opts={}):
-        self.ui = parentui or ui.ui()
+    def __init__(self, opts, args):
+        self.ui = ui.ui()
         self.ui.updateconfig()
         self.ui.resolveopts(opts)
         self.mailer = self.ui.configitem('messages', 'mailer', default='mutt')
-        urlcollector.urlcollector.__init__(self, self.ui, files=files)
+        urlcollector.urlcollector.__init__(self, self.ui, args)
         tpager.tpager.__init__(self, self.ui, name='url')
 
     def rawinput(self, prompt, msg=''):

muttils/urlpagercommand.py

     del parser
 
     try:
-        u = urlpager.urlpager(files=args, opts=options.__dict__)
+        u = urlpager.urlpager(options.__dict__, args)
         u.urlselect()
     except (util.DeadMan, IOError, KeyboardInterrupt), inst:
         sys.exit(inst)

muttils/viewhtmlmsg.py

 from muttils import pybrowser, ui, util
 
 class viewhtml(pybrowser.browser):
-    def __init__(self, parentui=None, inp='', safe=False, keep=None, app=''):
-        self.ui = parentui or ui.ui()
+    def __init__(self, safe, keep, app, args):
+        self.ui = ui.ui()
         self.ui.updateconfig()
         pybrowser.browser.__init__(self, parentui=self.ui,
                                    app=app, evalurl=True)
-        self.inp = inp
+        self.inp = args
         self.safe = safe or self.ui.configbool('html', 'safe')
         self.keep = keep
         if self.keep is None:

muttils/viewhtmlmsgcommand.py

     del parser
 
     try:
-        v = viewhtmlmsg.viewhtml(inp=args, safe=options.safe,
-                                 keep=options.keep, app=options.app)
+        v = viewhtmlmsg.viewhtml(options.safe, options.keep, options.app, args)
         v.view()
     except (util.DeadMan, IOError, KeyboardInterrupt), inst:
         sys.exit(inst)