# Buggy code
def accept(self, match, include_rejected=False):
    """
    Accept the keys matched
    """

    def _print_accepted(matches, after_match):
        if "minions" in after_match:
            accepted = sorted(
                set(after_match["minions"]).difference(set(matches.get("minions", [])))
            )
            for key in accepted:
                print("Key for minion {0} accepted.".format(key))

    matches = self.key.name_match(match)
    keys = {}
    if "minions_pre" in matches:
        keys["minions_pre"] = matches["minions_pre"]
    if include_rejected and bool(matches.get("minions_rejected")):
        keys["minions_rejected"] = matches["minions_rejected"]
    if not keys:
        msg = "The key glob {0!r} does not match any unaccepted {1}keys.".format(
            match, "or rejected " if include_rejected else ""
        )
        print(msg)
        return
    if not self.opts.get("yes", False):
        print("The following keys are going to be accepted:")
        salt.output.display_output(keys, "key", self.opts)
        try:
            veri = raw_input("Proceed? [n/Y] ")
        except KeyboardInterrupt:
            raise SystemExit("\nExiting on CTRL-c")
        if not veri or veri.lower().startswith("y"):
            _print_accepted(
                matches, self.key.accept(match, include_rejected=include_rejected)
            )
    else:
        print("The following keys are going to be accepted:")
        salt.output.display_output(keys, "key", self.opts)
        _print_accepted(
            matches, self.key.accept(match, include_rejected=include_rejected)
        )


# Traceback (AttributeError)
[ERROR   ] Error in function _master_opts:
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/salt/master.py", line 1444, in run_func
ret = getattr(self, func)(load)
File "/usr/lib/pymodules/python2.7/salt/master.py", line 891, in _master_opts
envs = self._file_envs()
File "/usr/lib/pymodules/python2.7/salt/fileserver/__init__.py", line 153, in envs
ret.update(self.servers[fstr]())
File "/usr/lib/pymodules/python2.7/salt/fileserver/hgfs.py", line 176, in envs
tags = repo.get_tags()
AttributeError: 'hgclient' object has no attribute 'get_tags'

# Fixed code
def accept(self, match, include_rejected=False):
    """
    Accept the keys matched
    """

    def _print_accepted(matches, after_match):
        if "minions" in after_match:
            accepted = sorted(
                set(after_match["minions"]).difference(set(matches.get("minions", [])))
            )
            for key in accepted:
                print("Key for minion {0} accepted.".format(key))

    matches = self.key.name_match(match)
    keys = {}
    if "minions_pre" in matches:
        keys["minions_pre"] = matches["minions_pre"]
    if include_rejected and bool(matches.get("minions_rejected")):
        keys["minions_rejected"] = matches["minions_rejected"]
    if not keys:
        msg = "The key glob {0!r} does not match any unaccepted {1}keys.".format(
            match, "or rejected " if include_rejected else ""
        )
        print(msg)
        return
    if not self.opts.get("yes", False):
        print("The following keys are going to be accepted:")
        salt.output.display_output(keys, "key", self.opts)
        try:
            veri = raw_input("Proceed? [n/Y] ")
        except KeyboardInterrupt:
            raise SystemExit("\nExiting on CTRL-c")
        if not veri or veri.lower().startswith("y"):
            _print_accepted(
                matches,
                self.key.accept(match_dict=keys, include_rejected=include_rejected),
            )
    else:
        print("The following keys are going to be accepted:")
        salt.output.display_output(keys, "key", self.opts)
        _print_accepted(
            matches, self.key.accept(match_dict=keys, include_rejected=include_rejected)
        )