def do_reassign(self, arg, opts=None): """Reassign a wiseguy to another boss""" if not opts.boss: print "Must provide a status!" return if not opts.id: print "Must provide an ID!" return # Locate the wiseguy wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return # Locate the boss boss = Wiseguy.find_one(id=opts.boss) if not boss: print "No Boss found!" return wiseguy.reassign_to(boss) print "Done. %s has been reassigned to %s" % (wiseguy, boss)
def do_compare(self, arg, opts=None): """Compare N wiseguys in terms of followers. Accepts N arguments, ID of each mafia you want to compare. """ wid_list = arg.split(" ") followers = {} invalid = [] print "Follower counts: %s" % (",".join(invalid)) for wid in wid_list: wiseguy = Wiseguy.find_one(id=wid) if wiseguy: followers[wiseguy] = len(wiseguy.followers()) print "%s: %s" % ( wiseguy, str(followers[wiseguy]) ) else: invalid.append(wid) if len(invalid): print "Invalid IDs: %s" % (",".join(invalid))
def do_find(self, arg, opts=None): """Find wiseguy(s) matching query""" query = opts.__dict__ wiseguy = Wiseguy.find_all(**query) if opts.all else Wiseguy.find_one(**query) if isinstance(wiseguy, Wiseguy): print "%s" % wiseguy if opts.detail: self.print_wiseguy(wiseguy) elif isinstance(wiseguy, list): for w in wiseguy: print "%s" % w if opts.detail: self.print_wiseguy(w) print "Found %d wiseguys" % len(wiseguy) else: print "No Wiseguy found!"
def do_boss(self, arg, opts=None): """Check the boss of a given wiseguy """ wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return print "Boss of ", wiseguy.to_string(), ":\n" boss = Wiseguy.find_one(id=wiseguy.get('boss_id')) if not boss: print "No boss found! Might be a godfather or decommissioned wiseguy. :)" return self.print_wiseguy(boss)
def do_tree(self, arg, opts=None): """Draw an ASCII chart of the hierarchy under the given wiseguy. """ wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return print draw_tree(wiseguy.tree())
def do_heir(self, arg, opts=None): """Check who is next in line to a wiseguy to inherit followers """ wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return heir = wiseguy.heir() if not heir: print "No heir found!" return print "Heir to %s is:\n\t %s" % (wiseguy, heir)
def do_followers(self, arg, opts=None): """Find the followers of a wiseguy""" wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return followers = wiseguy.followers(level=opts.level) if isinstance(followers, list): print "Followers of %s:\n" % wiseguy for f in followers: print f print "\nFound %d wiseguy(s) who are followers of %s.\n" % ( len(followers), wiseguy ) else: print "No followers found!"
def do_recommission(self, arg, opts=None): """Reinstate a wiseguy to active duty with given status. """ if not opts.status: print "Must provide a status!" return if not opts.id: print "Must provide an ID!" return # Locate the wiseguy wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return # Reactivate the wiseguy wiseguy.reactivate(status=opts.status) print "Done reactivating", wiseguy
def do_decommission(self, arg, opts=None): """Remove a wiseguy from active duty and set a status """ if not opts.status: print "Must provide a status!" return if not opts.id: print "Must provide an ID!" return # Locate the wiseguy wiseguy = Wiseguy.find_one(id=opts.id) if not wiseguy: print "No Wiseguy found!" return # Deactivate the wiseguy wiseguy.deactivate(status=opts.status) print "Done deactivating", wiseguy