parameters: (mode, verbose, force, args, prefargs, watcher)
docstring: Engine for the main program
docstring_summary: Engine for the main program
docstring_tokens: Engine for the main program
function: def _run(mode, verbose, force, args, prefargs, watcher):
      """Engine for the main program"""
  
      prefs = PimpPreferences(**prefargs)
      if watcher:
          prefs.setWatcher(watcher)
      rv = prefs.check()
      if rv:
          sys.stdout.write(rv)
      db = PimpDatabase(prefs)
      db.appendURL(prefs.pimpDatabase)
  
      if mode == 'dump':
          db.dump(sys.stdout)
      elif mode =='list':
          if not args:
              args = db.listnames()
          print "%-20.20s\t%s" % ("Package", "Description")
          print
          for pkgname in args:
              pkg = db.find(pkgname)
              if pkg:
                  description = pkg.shortdescription()
                  pkgname = pkg.fullname()
              else:
                  description = 'Error: no such package'
              print "%-20.20s\t%s" % (pkgname, description)
              if verbose:
                  print "\tHome page:\t", pkg.homepage()
                  try:
                      print "\tDownload URL:\t", pkg.downloadURL()
                  except KeyError:
                      pass
                  description = pkg.description()
                  description = '\n\t\t\t\t\t'.join(description.splitlines())
                  print "\tDescription:\t%s" % description
      elif mode =='status':
          if not args:
              args = db.listnames()
              print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message")
              print
          for pkgname in args:
              pkg = db.find(pkgname)
              if pkg:
                  status, msg = pkg.installed()
                  pkgname = pkg.fullname()
              else:
                  status = 'error'
                  msg = 'No such package'
              print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg)
              if verbose and status == "no":
                  prereq = pkg.prerequisites()
                  for pkg, msg in prereq:
                      if not pkg:
                          pkg = ''
                      else:
                          pkg = pkg.fullname()
                      print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg)
      elif mode == 'install':
          if not args:
              print 'Please specify packages to install'
              sys.exit(1)
          inst = PimpInstaller(db)
          for pkgname in args:
              pkg = db.find(pkgname)
              if not pkg:
                  print '%s: No such package' % pkgname
                  continue
              list, messages = inst.prepareInstall(pkg, force)
              if messages and not force:
                  print "%s: Not installed:" % pkgname
                  for m in messages:
                      print "\t", m
              else:
                  if verbose:
                      output = sys.stdout
                  else:
                      output = None
                  messages = inst.install(list, output)
                  if messages:
                      print "%s: Not installed:" % pkgname
                      for m in messages:
                          print "\t", m
function_tokens: def _run ( mode , verbose , force , args , prefargs , watcher ) : prefs = PimpPreferences ( * * prefargs ) if watcher : prefs . setWatcher ( watcher ) rv = prefs . check ( ) if rv : sys . stdout . write ( rv ) db = PimpDatabase ( prefs ) db . appendURL ( prefs . pimpDatabase ) if mode == 'dump' : db . dump ( sys . stdout ) elif mode == 'list' : if not args : args = db . listnames ( ) print "%-20.20s\t%s" % ( "Package" , "Description" ) print for pkgname in args : pkg = db . find ( pkgname ) if pkg : description = pkg . shortdescription ( ) pkgname = pkg . fullname ( ) else : description = 'Error: no such package' print "%-20.20s\t%s" % ( pkgname , description ) if verbose : print "\tHome page:\t" , pkg . homepage ( ) try : print "\tDownload URL:\t" , pkg . downloadURL ( ) except KeyError : pass description = pkg . description ( ) description = '\n\t\t\t\t\t' . join ( description . splitlines ( ) ) print "\tDescription:\t%s" % description elif mode == 'status' : if not args : args = db . listnames ( ) print "%-20.20s\t%s\t%s" % ( "Package" , "Installed" , "Message" ) print for pkgname in args : pkg = db . find ( pkgname ) if pkg : status , msg = pkg . installed ( ) pkgname = pkg . fullname ( ) else : status = 'error' msg = 'No such package' print "%-20.20s\t%-9.9s\t%s" % ( pkgname , status , msg ) if verbose and status == "no" : prereq = pkg . prerequisites ( ) for pkg , msg in prereq : if not pkg : pkg = '' else : pkg = pkg . fullname ( ) print "%-20.20s\tRequirement: %s %s" % ( "" , pkg , msg ) elif mode == 'install' : if not args : print 'Please specify packages to install' sys . exit ( 1 ) inst = PimpInstaller ( db ) for pkgname in args : pkg = db . find ( pkgname ) if not pkg : print '%s: No such package' % pkgname continue list , messages = inst . prepareInstall ( pkg , force ) if messages and not force : print "%s: Not installed:" % pkgname for m in messages : print "\t" , m else : if verbose : output = sys . stdout else : output = None messages = inst . install ( list , output ) if messages : print "%s: Not installed:" % pkgname for m in messages : print "\t" , m