prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  InsightsEvaluator ignores its stream argument during construction
  The [InsightsEvaluator](https://github.com/RedHatInsights/insights-core/blob/master/insights/core/evaluators.py#L121) ignores its stream argument and passes `sys.stdout` to its superclass constructor.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `insights/core/evaluators.py`
  Content:
  ```
  1 import logging
  2 import six
  3 import sys
  4 
  5 from collections import defaultdict
  6 
  7 from ..formats import Formatter
  8 from ..specs import Specs
  9 from ..combiners.hostname import hostname as combiner_hostname
  10 from ..parsers.branch_info import BranchInfo
  11 from . import dr, plugins
  12 
  13 log = logging.getLogger(__name__)
  14 
  15 
  16 def get_simple_module_name(obj):
  17     return dr.BASE_MODULE_NAMES.get(obj, None)
  18 
  19 
  20 class Evaluator(Formatter):
  21     def __init__(self, broker=None, stream=sys.stdout, incremental=False):
  22         super(Evaluator, self).__init__(broker or dr.Broker(), stream)
  23         self.results = defaultdict(list)
  24         self.rule_skips = []
  25         self.hostname = None
  26         self.metadata = {}
  27         self.metadata_keys = {}
  28         self.incremental = incremental
  29 
  30     def observer(self, comp, broker):
  31         if comp is combiner_hostname and comp in broker:
  32             self.hostname = broker[comp].fqdn
  33 
  34         if plugins.is_rule(comp) and comp in broker:
  35             self.handle_result(comp, broker[comp])
  36 
  37     def preprocess(self):
  38         self.broker.add_observer(self.observer)
  39 
  40     def run_serial(self, graph=None):
  41         dr.run(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker)
  42 
  43     def run_incremental(self, graph=None):
  44         for _ in dr.run_incremental(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker):
  45             pass
  46 
  47     def format_response(self, response):
  48         """
  49         To be overridden by subclasses to format the response sent back to the
  50         client.
  51         """
  52         return response
  53 
  54     def format_result(self, result):
  55         """
  56         To be overridden by subclasses to format individual rule results.
  57         """
  58         return result
  59 
  60     def process(self, graph=None):
  61         with self:
  62             if self.incremental:
  63                 self.run_incremental(graph)
  64             else:
  65                 self.run_serial(graph)
  66         return self.get_response()
  67 
  68 
  69 class SingleEvaluator(Evaluator):
  70     def append_metadata(self, r):
  71         for k, v in r.items():
  72             if k != "type":
  73                 self.metadata[k] = v
  74 
  75     def format_response(self, response):
  76         return response
  77 
  78     def get_response(self):
  79         r = dict(self.metadata_keys)
  80         r.update({
  81             "system": {
  82                 "metadata": self.metadata,
  83                 "hostname": self.hostname
  84             },
  85             "reports": self.results["rule"],
  86             "fingerprints": self.results["fingerprint"],
  87             "skips": self.rule_skips,
  88         })
  89 
  90         for k, v in six.iteritems(self.results):
  91             if k not in ("rule", "fingerprint"):
  92                 r[k] = v
  93 
  94         return self.format_response(r)
  95 
  96     def handle_result(self, plugin, r):
  97         type_ = r["type"]
  98 
  99         if type_ == "skip":
  100             self.rule_skips.append(r)
  101         elif type_ == "metadata":
  102             self.append_metadata(r)
  103         elif type_ == "metadata_key":
  104             self.metadata_keys[r.get_key()] = r["value"]
  105         else:
  106             response_id = "%s_id" % r.response_type
  107             key = r.get_key()
  108             self.results[type_].append(self.format_result({
  109                 response_id: "{0}|{1}".format(get_simple_module_name(plugin), key),
  110                 "component": dr.get_name(plugin),
  111                 "type": type_,
  112                 "key": key,
  113                 "details": r,
  114                 "tags": list(dr.get_tags(plugin)),
  115                 "links": dr.get_delegate(plugin).links or {}
  116             }))
  117 
  118 
  119 class InsightsEvaluator(SingleEvaluator):
  120     def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):
  121         super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)
  122         self.system_id = system_id
  123         self.branch_info = {}
  124         self.product = "rhel"
  125         self.type = "host"
  126         self.release = None
  127 
  128     def observer(self, comp, broker):
  129         super(InsightsEvaluator, self).observer(comp, broker)
  130         if comp is Specs.machine_id and comp in broker:
  131             self.system_id = broker[Specs.machine_id].content[0].strip()
  132 
  133         if comp is Specs.redhat_release and comp in broker:
  134             self.release = broker[comp].content[0].strip()
  135 
  136         if comp is BranchInfo and BranchInfo in broker:
  137             self.branch_info = broker[comp].data
  138 
  139         if comp is Specs.metadata_json and comp in broker:
  140             md = broker[comp]
  141             self.product = md.get("product_code")
  142             self.type = md.get("role")
  143 
  144     def format_result(self, result):
  145         result["system_id"] = self.system_id
  146         return result
  147 
  148     def format_response(self, response):
  149         system = response["system"]
  150         system["remote_branch"] = self.branch_info.get("remote_branch")
  151         system["remote_leaf"] = self.branch_info.get("remote_leaf")
  152         system["system_id"] = self.system_id
  153         system["product"] = self.product
  154         system["type"] = self.type
  155         if self.release:
  156             system["metadata"]["release"] = self.release
  157 
  158         return response
  159
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/insights/core/evaluators.py b/insights/core/evaluators.py
  --- a/insights/core/evaluators.py
  +++ b/insights/core/evaluators.py
  @@ -118,7 +118,7 @@
   
   class InsightsEvaluator(SingleEvaluator):
       def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):
  -        super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)
  +        super(InsightsEvaluator, self).__init__(broker, stream=stream, incremental=incremental)
           self.system_id = system_id
           self.branch_info = {}
           self.product = "rhel"
  
verification_info: {"golden_diff": "diff --git a/insights/core/evaluators.py b/insights/core/evaluators.py\n--- a/insights/core/evaluators.py\n+++ b/insights/core/evaluators.py\n@@ -118,7 +118,7 @@\n \n class InsightsEvaluator(SingleEvaluator):\n     def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):\n-        super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)\n+        super(InsightsEvaluator, self).__init__(broker, stream=stream, incremental=incremental)\n         self.system_id = system_id\n         self.branch_info = {}\n         self.product = \"rhel\"\n", "issue": "InsightsEvaluator ignores its stream argument during construction\nThe [InsightsEvaluator](https://github.com/RedHatInsights/insights-core/blob/master/insights/core/evaluators.py#L121) ignores its stream argument and passes `sys.stdout` to its superclass constructor.\n", "before_files": [{"content": "import logging\nimport six\nimport sys\n\nfrom collections import defaultdict\n\nfrom ..formats import Formatter\nfrom ..specs import Specs\nfrom ..combiners.hostname import hostname as combiner_hostname\nfrom ..parsers.branch_info import BranchInfo\nfrom . import dr, plugins\n\nlog = logging.getLogger(__name__)\n\n\ndef get_simple_module_name(obj):\n    return dr.BASE_MODULE_NAMES.get(obj, None)\n\n\nclass Evaluator(Formatter):\n    def __init__(self, broker=None, stream=sys.stdout, incremental=False):\n        super(Evaluator, self).__init__(broker or dr.Broker(), stream)\n        self.results = defaultdict(list)\n        self.rule_skips = []\n        self.hostname = None\n        self.metadata = {}\n        self.metadata_keys = {}\n        self.incremental = incremental\n\n    def observer(self, comp, broker):\n        if comp is combiner_hostname and comp in broker:\n            self.hostname = broker[comp].fqdn\n\n        if plugins.is_rule(comp) and comp in broker:\n            self.handle_result(comp, broker[comp])\n\n    def preprocess(self):\n        self.broker.add_observer(self.observer)\n\n    def run_serial(self, graph=None):\n        dr.run(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker)\n\n    def run_incremental(self, graph=None):\n        for _ in dr.run_incremental(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker):\n            pass\n\n    def format_response(self, response):\n        \"\"\"\n        To be overridden by subclasses to format the response sent back to the\n        client.\n        \"\"\"\n        return response\n\n    def format_result(self, result):\n        \"\"\"\n        To be overridden by subclasses to format individual rule results.\n        \"\"\"\n        return result\n\n    def process(self, graph=None):\n        with self:\n            if self.incremental:\n                self.run_incremental(graph)\n            else:\n                self.run_serial(graph)\n        return self.get_response()\n\n\nclass SingleEvaluator(Evaluator):\n    def append_metadata(self, r):\n        for k, v in r.items():\n            if k != \"type\":\n                self.metadata[k] = v\n\n    def format_response(self, response):\n        return response\n\n    def get_response(self):\n        r = dict(self.metadata_keys)\n        r.update({\n            \"system\": {\n                \"metadata\": self.metadata,\n                \"hostname\": self.hostname\n            },\n            \"reports\": self.results[\"rule\"],\n            \"fingerprints\": self.results[\"fingerprint\"],\n            \"skips\": self.rule_skips,\n        })\n\n        for k, v in six.iteritems(self.results):\n            if k not in (\"rule\", \"fingerprint\"):\n                r[k] = v\n\n        return self.format_response(r)\n\n    def handle_result(self, plugin, r):\n        type_ = r[\"type\"]\n\n        if type_ == \"skip\":\n            self.rule_skips.append(r)\n        elif type_ == \"metadata\":\n            self.append_metadata(r)\n        elif type_ == \"metadata_key\":\n            self.metadata_keys[r.get_key()] = r[\"value\"]\n        else:\n            response_id = \"%s_id\" % r.response_type\n            key = r.get_key()\n            self.results[type_].append(self.format_result({\n                response_id: \"{0}|{1}\".format(get_simple_module_name(plugin), key),\n                \"component\": dr.get_name(plugin),\n                \"type\": type_,\n                \"key\": key,\n                \"details\": r,\n                \"tags\": list(dr.get_tags(plugin)),\n                \"links\": dr.get_delegate(plugin).links or {}\n            }))\n\n\nclass InsightsEvaluator(SingleEvaluator):\n    def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):\n        super(InsightsEvaluator, self).__init__(broker, stream=sys.stdout, incremental=incremental)\n        self.system_id = system_id\n        self.branch_info = {}\n        self.product = \"rhel\"\n        self.type = \"host\"\n        self.release = None\n\n    def observer(self, comp, broker):\n        super(InsightsEvaluator, self).observer(comp, broker)\n        if comp is Specs.machine_id and comp in broker:\n            self.system_id = broker[Specs.machine_id].content[0].strip()\n\n        if comp is Specs.redhat_release and comp in broker:\n            self.release = broker[comp].content[0].strip()\n\n        if comp is BranchInfo and BranchInfo in broker:\n            self.branch_info = broker[comp].data\n\n        if comp is Specs.metadata_json and comp in broker:\n            md = broker[comp]\n            self.product = md.get(\"product_code\")\n            self.type = md.get(\"role\")\n\n    def format_result(self, result):\n        result[\"system_id\"] = self.system_id\n        return result\n\n    def format_response(self, response):\n        system = response[\"system\"]\n        system[\"remote_branch\"] = self.branch_info.get(\"remote_branch\")\n        system[\"remote_leaf\"] = self.branch_info.get(\"remote_leaf\")\n        system[\"system_id\"] = self.system_id\n        system[\"product\"] = self.product\n        system[\"type\"] = self.type\n        if self.release:\n            system[\"metadata\"][\"release\"] = self.release\n\n        return response\n", "path": "insights/core/evaluators.py"}], "after_files": [{"content": "import logging\nimport six\nimport sys\n\nfrom collections import defaultdict\n\nfrom ..formats import Formatter\nfrom ..specs import Specs\nfrom ..combiners.hostname import hostname as combiner_hostname\nfrom ..parsers.branch_info import BranchInfo\nfrom . import dr, plugins\n\nlog = logging.getLogger(__name__)\n\n\ndef get_simple_module_name(obj):\n    return dr.BASE_MODULE_NAMES.get(obj, None)\n\n\nclass Evaluator(Formatter):\n    def __init__(self, broker=None, stream=sys.stdout, incremental=False):\n        super(Evaluator, self).__init__(broker or dr.Broker(), stream)\n        self.results = defaultdict(list)\n        self.rule_skips = []\n        self.hostname = None\n        self.metadata = {}\n        self.metadata_keys = {}\n        self.incremental = incremental\n\n    def observer(self, comp, broker):\n        if comp is combiner_hostname and comp in broker:\n            self.hostname = broker[comp].fqdn\n\n        if plugins.is_rule(comp) and comp in broker:\n            self.handle_result(comp, broker[comp])\n\n    def preprocess(self):\n        self.broker.add_observer(self.observer)\n\n    def run_serial(self, graph=None):\n        dr.run(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker)\n\n    def run_incremental(self, graph=None):\n        for _ in dr.run_incremental(graph or dr.COMPONENTS[dr.GROUPS.single], broker=self.broker):\n            pass\n\n    def format_response(self, response):\n        \"\"\"\n        To be overridden by subclasses to format the response sent back to the\n        client.\n        \"\"\"\n        return response\n\n    def format_result(self, result):\n        \"\"\"\n        To be overridden by subclasses to format individual rule results.\n        \"\"\"\n        return result\n\n    def process(self, graph=None):\n        with self:\n            if self.incremental:\n                self.run_incremental(graph)\n            else:\n                self.run_serial(graph)\n        return self.get_response()\n\n\nclass SingleEvaluator(Evaluator):\n    def append_metadata(self, r):\n        for k, v in r.items():\n            if k != \"type\":\n                self.metadata[k] = v\n\n    def format_response(self, response):\n        return response\n\n    def get_response(self):\n        r = dict(self.metadata_keys)\n        r.update({\n            \"system\": {\n                \"metadata\": self.metadata,\n                \"hostname\": self.hostname\n            },\n            \"reports\": self.results[\"rule\"],\n            \"fingerprints\": self.results[\"fingerprint\"],\n            \"skips\": self.rule_skips,\n        })\n\n        for k, v in six.iteritems(self.results):\n            if k not in (\"rule\", \"fingerprint\"):\n                r[k] = v\n\n        return self.format_response(r)\n\n    def handle_result(self, plugin, r):\n        type_ = r[\"type\"]\n\n        if type_ == \"skip\":\n            self.rule_skips.append(r)\n        elif type_ == \"metadata\":\n            self.append_metadata(r)\n        elif type_ == \"metadata_key\":\n            self.metadata_keys[r.get_key()] = r[\"value\"]\n        else:\n            response_id = \"%s_id\" % r.response_type\n            key = r.get_key()\n            self.results[type_].append(self.format_result({\n                response_id: \"{0}|{1}\".format(get_simple_module_name(plugin), key),\n                \"component\": dr.get_name(plugin),\n                \"type\": type_,\n                \"key\": key,\n                \"details\": r,\n                \"tags\": list(dr.get_tags(plugin)),\n                \"links\": dr.get_delegate(plugin).links or {}\n            }))\n\n\nclass InsightsEvaluator(SingleEvaluator):\n    def __init__(self, broker=None, system_id=None, stream=sys.stdout, incremental=False):\n        super(InsightsEvaluator, self).__init__(broker, stream=stream, incremental=incremental)\n        self.system_id = system_id\n        self.branch_info = {}\n        self.product = \"rhel\"\n        self.type = \"host\"\n        self.release = None\n\n    def observer(self, comp, broker):\n        super(InsightsEvaluator, self).observer(comp, broker)\n        if comp is Specs.machine_id and comp in broker:\n            self.system_id = broker[Specs.machine_id].content[0].strip()\n\n        if comp is Specs.redhat_release and comp in broker:\n            self.release = broker[comp].content[0].strip()\n\n        if comp is BranchInfo and BranchInfo in broker:\n            self.branch_info = broker[comp].data\n\n        if comp is Specs.metadata_json and comp in broker:\n            md = broker[comp]\n            self.product = md.get(\"product_code\")\n            self.type = md.get(\"role\")\n\n    def format_result(self, result):\n        result[\"system_id\"] = self.system_id\n        return result\n\n    def format_response(self, response):\n        system = response[\"system\"]\n        system[\"remote_branch\"] = self.branch_info.get(\"remote_branch\")\n        system[\"remote_leaf\"] = self.branch_info.get(\"remote_leaf\")\n        system[\"system_id\"] = self.system_id\n        system[\"product\"] = self.product\n        system[\"type\"] = self.type\n        if self.release:\n            system[\"metadata\"][\"release\"] = self.release\n\n        return response\n", "path": "insights/core/evaluators.py"}]}