We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
docs: Review and test examples on user's guide (section: Introduction)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `avocado/core/parser.py`
Content:
```
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 #
10 # See LICENSE for more details.
11 #
12 # Copyright: Red Hat Inc. 2013-2014
13 # Author: Ruda Moura <rmoura@redhat.com>
14 
15 """
16 Avocado application command line parsing.
17 """
18 
19 import argparse
20 from configparser import ConfigParser, NoOptionError
21 from glob import glob
22 
23 from . import exit_codes
24 from .nrunner import Runnable
25 from .output import LOG_UI
26 from .resolver import ReferenceResolution, ReferenceResolutionResult
27 from .settings import ConfigFileNotFound, SettingsError, settings
28 from .version import VERSION
29 
30 PROG = 'avocado'
31 DESCRIPTION = 'Avocado Test Runner'
32 
33 
34 class ArgumentParser(argparse.ArgumentParser):
35 
36     """
37     Class to override argparse functions
38     """
39 
40     def error(self, message):
41         LOG_UI.debug(self.format_help())
42         LOG_UI.error("%s: error: %s", self.prog, message)
43         if "unrecognized arguments" in message:
44             LOG_UI.warning("Perhaps a plugin is missing; run 'avocado"
45                            " plugins' to list the installed ones")
46         self.exit(exit_codes.AVOCADO_FAIL)
47 
48     def _get_option_tuples(self, option_string):
49         return []
50 
51 
52 class FileOrStdoutAction(argparse.Action):
53 
54     """
55     Controls claiming the right to write to the application standard output
56     """
57 
58     def __call__(self, parser, namespace, values, option_string=None):
59         if values == '-':
60             stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)
61             if stdout_claimed_by is not None:
62                 msg = ('Options %s %s are trying to use stdout '
63                        'simultaneously' % (stdout_claimed_by,
64                                            option_string))
65                 raise argparse.ArgumentError(self, msg)
66             else:
67                 setattr(namespace, 'stdout_claimed_by', option_string)
68         setattr(namespace, self.dest, values)
69 
70 
71 class Parser:
72 
73     """
74     Class to Parse the command line arguments.
75     """
76 
77     def __init__(self):
78         self.args = argparse.Namespace()
79         self.config = {}
80         self.subcommands = None
81         self.application = ArgumentParser(prog=PROG,
82                                           add_help=False,  # see parent parsing
83                                           description=DESCRIPTION)
84         self.application.add_argument('-v', '--version', action='version',
85                                       version='Avocado %s' % VERSION)
86         self.application.add_argument('--config', metavar='CONFIG_FILE',
87                                       nargs='?',
88                                       help='Use custom configuration from a file')
89 
90         help_msg = ('Turn the paginator on/off. Useful when outputs are too'
91                     'long. This will be a boolean soon.')
92         settings.register_option(section='core',
93                                  key='paginator',
94                                  help_msg=help_msg,
95                                  default='off',
96                                  choices=('on', 'off'),
97                                  parser=self.application,
98                                  long_arg='--paginator')
99 
100         help_msg = ('Some commands can produce more information. This option '
101                     'will enable the verbosity when applicable.')
102         settings.register_option(section='core',
103                                  key='verbose',
104                                  help_msg=help_msg,
105                                  default=False,
106                                  key_type=bool,
107                                  parser=self.application,
108                                  long_arg='--verbose',
109                                  short_arg='-V')
110 
111         settings.add_argparser_to_option(namespace='core.show',
112                                          parser=self.application,
113                                          long_arg='--show')
114 
115     def start(self):
116         """
117         Start to parsing arguments.
118 
119         At the end of this method, the support for subparsers is activated.
120         Side effect: update attribute `args` (the namespace).
121         """
122         self.args, _ = self.application.parse_known_args()
123 
124         # Load settings from file, if user provides one
125         if self.args.config is not None:
126             settings.process_config_path(self.args.config)
127 
128         # Use parent parsing to avoid breaking the output of --help option
129         self.application = ArgumentParser(prog=PROG,
130                                           description=DESCRIPTION,
131                                           parents=[self.application])
132 
133         # Subparsers where Avocado subcommands are plugged
134         self.subcommands = self.application.add_subparsers(
135             title='subcommands',
136             description='valid subcommands',
137             help='subcommand help',
138             dest='subcommand')
139         # On Python 2, required doesn't make a difference because a
140         # subparser is considered an unconsumed positional arguments,
141         # and not providing one will error with a "too few arguments"
142         # message.  On Python 3, required arguments are used instead.
143         # Unfortunately, there's no way to pass this as an option when
144         # constructing the sub parsers, but it is possible to set that
145         # option afterwards.
146         self.subcommands.required = True
147 
148     def finish(self):
149         """
150         Finish the process of parsing arguments.
151 
152         Side effect: set the final value on attribute `config`.
153         """
154         args, extra = self.application.parse_known_args(namespace=self.args)
155         if extra:
156             msg = 'unrecognized arguments: %s' % ' '.join(extra)
157             for sub in self.application._subparsers._actions:  # pylint: disable=W0212
158                 if sub.dest == 'subcommand':
159                     sub.choices[self.args.subcommand].error(msg)
160 
161             self.application.error(msg)
162         # from this point on, config is a dictionary based on a argparse.Namespace
163         self.config = vars(args)
164 
165 
166 class HintParser:
167     def __init__(self, filename):
168         self.filename = filename
169         self.config = None
170         self.hints = []
171         self._parse()
172 
173     def _get_args_from_section(self, section):
174         try:
175             args = self.config.get(section, 'args')
176             if args == '$testpath':
177                 return [args]
178             return args.split(',')
179         except NoOptionError:
180             return []
181 
182     def _get_kwargs_from_section(self, section):
183         result = {}
184         kwargs = self.config.get(section, 'kwargs', fallback='')
185         for kwarg in kwargs.split(','):
186             if kwarg == '':
187                 continue
188             key, value = kwarg.split('=')
189             result[key] = value
190         return result
191 
192     def _get_resolutions_by_kind(self, kind, paths):
193         self.validate_kind_section(kind)
194 
195         resolutions = []
196         success = ReferenceResolutionResult.SUCCESS
197 
198         config = {'uri': self._get_uri_from_section(kind),
199                   'args': self._get_args_from_section(kind),
200                   'kwargs': self._get_kwargs_from_section(kind)}
201         for path in paths:
202             uri = config.get('uri')
203             args = config.get('args')
204             kwargs = config.get('kwargs')
205             if uri == '$testpath':
206                 uri = path
207             if '$testpath' in args:
208                 args = [item.replace('$testpath', path) for item in args]
209             if '$testpath' in kwargs.values():
210                 kwargs = {k: v.replace('$testpath', path)
211                           for k, v in kwargs.items()}
212             runnable = Runnable(kind, uri, *args, **kwargs)
213             resolutions.append(ReferenceResolution(reference=path,
214                                                    result=success,
215                                                    resolutions=[runnable],
216                                                    origin=path))
217         return resolutions
218 
219     def _get_uri_from_section(self, section):
220         return self.config.get(section, 'uri')
221 
222     def _parse(self):
223         self.config = ConfigParser()
224         config_paths = self.config.read(self.filename)
225         if not config_paths:
226             raise ConfigFileNotFound(self.filename)
227 
228     def get_resolutions(self):
229         """Return a list of resolutions based on the file definitions."""
230         resolutions = []
231         for kind in self.config['kinds']:
232             files = self.config.get('kinds', kind)
233             resolutions.extend(self._get_resolutions_by_kind(kind,
234                                                              glob(files)))
235         return resolutions
236 
237     def validate_kind_section(self, kind):
238         """Validates a specific "kind section".
239 
240         This method will raise a `settings.SettingsError` if any problem is
241         found on the file.
242 
243         :param kind: a string with the specific section.
244         """
245         if kind not in self.config:
246             msg = 'Section {} is not defined. Please check your hint file.'
247             raise SettingsError(msg.format(kind))
248 
249         uri = self._get_uri_from_section(kind)
250         if uri is None:
251             msg = "uri needs to be defined inside {}".format(kind)
252             raise SettingsError(msg)
253
```
--- 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()

```

diff --git a/avocado/core/parser.py b/avocado/core/parser.py
--- a/avocado/core/parser.py
+++ b/avocado/core/parser.py
@@ -59,9 +59,9 @@
         if values == '-':
             stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)
             if stdout_claimed_by is not None:
-                msg = ('Options %s %s are trying to use stdout '
-                       'simultaneously' % (stdout_claimed_by,
-                                           option_string))
+                msg = ('Options %s %s are trying to use stdout simultaneously.'
+                       ' Please set at least one of them to a file to avoid '
+                       'conflicts' % (stdout_claimed_by, option_string))
                 raise argparse.ArgumentError(self, msg)
             else:
                 setattr(namespace, 'stdout_claimed_by', option_string)

{"golden_diff": "diff --git a/avocado/core/parser.py b/avocado/core/parser.py\n--- a/avocado/core/parser.py\n+++ b/avocado/core/parser.py\n@@ -59,9 +59,9 @@\n         if values == '-':\n             stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)\n             if stdout_claimed_by is not None:\n-                msg = ('Options %s %s are trying to use stdout '\n-                       'simultaneously' % (stdout_claimed_by,\n-                                           option_string))\n+                msg = ('Options %s %s are trying to use stdout simultaneously.'\n+                       ' Please set at least one of them to a file to avoid '\n+                       'conflicts' % (stdout_claimed_by, option_string))\n                 raise argparse.ArgumentError(self, msg)\n             else:\n                 setattr(namespace, 'stdout_claimed_by', option_string)\n", "issue": "docs: Review and test examples on user's guide (section: Introduction)\n\n", "before_files": [{"content": "# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n#\n# See LICENSE for more details.\n#\n# Copyright: Red Hat Inc. 2013-2014\n# Author: Ruda Moura <rmoura@redhat.com>\n\n\"\"\"\nAvocado application command line parsing.\n\"\"\"\n\nimport argparse\nfrom configparser import ConfigParser, NoOptionError\nfrom glob import glob\n\nfrom . import exit_codes\nfrom .nrunner import Runnable\nfrom .output import LOG_UI\nfrom .resolver import ReferenceResolution, ReferenceResolutionResult\nfrom .settings import ConfigFileNotFound, SettingsError, settings\nfrom .version import VERSION\n\nPROG = 'avocado'\nDESCRIPTION = 'Avocado Test Runner'\n\n\nclass ArgumentParser(argparse.ArgumentParser):\n\n    \"\"\"\n    Class to override argparse functions\n    \"\"\"\n\n    def error(self, message):\n        LOG_UI.debug(self.format_help())\n        LOG_UI.error(\"%s: error: %s\", self.prog, message)\n        if \"unrecognized arguments\" in message:\n            LOG_UI.warning(\"Perhaps a plugin is missing; run 'avocado\"\n                           \" plugins' to list the installed ones\")\n        self.exit(exit_codes.AVOCADO_FAIL)\n\n    def _get_option_tuples(self, option_string):\n        return []\n\n\nclass FileOrStdoutAction(argparse.Action):\n\n    \"\"\"\n    Controls claiming the right to write to the application standard output\n    \"\"\"\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        if values == '-':\n            stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)\n            if stdout_claimed_by is not None:\n                msg = ('Options %s %s are trying to use stdout '\n                       'simultaneously' % (stdout_claimed_by,\n                                           option_string))\n                raise argparse.ArgumentError(self, msg)\n            else:\n                setattr(namespace, 'stdout_claimed_by', option_string)\n        setattr(namespace, self.dest, values)\n\n\nclass Parser:\n\n    \"\"\"\n    Class to Parse the command line arguments.\n    \"\"\"\n\n    def __init__(self):\n        self.args = argparse.Namespace()\n        self.config = {}\n        self.subcommands = None\n        self.application = ArgumentParser(prog=PROG,\n                                          add_help=False,  # see parent parsing\n                                          description=DESCRIPTION)\n        self.application.add_argument('-v', '--version', action='version',\n                                      version='Avocado %s' % VERSION)\n        self.application.add_argument('--config', metavar='CONFIG_FILE',\n                                      nargs='?',\n                                      help='Use custom configuration from a file')\n\n        help_msg = ('Turn the paginator on/off. Useful when outputs are too'\n                    'long. This will be a boolean soon.')\n        settings.register_option(section='core',\n                                 key='paginator',\n                                 help_msg=help_msg,\n                                 default='off',\n                                 choices=('on', 'off'),\n                                 parser=self.application,\n                                 long_arg='--paginator')\n\n        help_msg = ('Some commands can produce more information. This option '\n                    'will enable the verbosity when applicable.')\n        settings.register_option(section='core',\n                                 key='verbose',\n                                 help_msg=help_msg,\n                                 default=False,\n                                 key_type=bool,\n                                 parser=self.application,\n                                 long_arg='--verbose',\n                                 short_arg='-V')\n\n        settings.add_argparser_to_option(namespace='core.show',\n                                         parser=self.application,\n                                         long_arg='--show')\n\n    def start(self):\n        \"\"\"\n        Start to parsing arguments.\n\n        At the end of this method, the support for subparsers is activated.\n        Side effect: update attribute `args` (the namespace).\n        \"\"\"\n        self.args, _ = self.application.parse_known_args()\n\n        # Load settings from file, if user provides one\n        if self.args.config is not None:\n            settings.process_config_path(self.args.config)\n\n        # Use parent parsing to avoid breaking the output of --help option\n        self.application = ArgumentParser(prog=PROG,\n                                          description=DESCRIPTION,\n                                          parents=[self.application])\n\n        # Subparsers where Avocado subcommands are plugged\n        self.subcommands = self.application.add_subparsers(\n            title='subcommands',\n            description='valid subcommands',\n            help='subcommand help',\n            dest='subcommand')\n        # On Python 2, required doesn't make a difference because a\n        # subparser is considered an unconsumed positional arguments,\n        # and not providing one will error with a \"too few arguments\"\n        # message.  On Python 3, required arguments are used instead.\n        # Unfortunately, there's no way to pass this as an option when\n        # constructing the sub parsers, but it is possible to set that\n        # option afterwards.\n        self.subcommands.required = True\n\n    def finish(self):\n        \"\"\"\n        Finish the process of parsing arguments.\n\n        Side effect: set the final value on attribute `config`.\n        \"\"\"\n        args, extra = self.application.parse_known_args(namespace=self.args)\n        if extra:\n            msg = 'unrecognized arguments: %s' % ' '.join(extra)\n            for sub in self.application._subparsers._actions:  # pylint: disable=W0212\n                if sub.dest == 'subcommand':\n                    sub.choices[self.args.subcommand].error(msg)\n\n            self.application.error(msg)\n        # from this point on, config is a dictionary based on a argparse.Namespace\n        self.config = vars(args)\n\n\nclass HintParser:\n    def __init__(self, filename):\n        self.filename = filename\n        self.config = None\n        self.hints = []\n        self._parse()\n\n    def _get_args_from_section(self, section):\n        try:\n            args = self.config.get(section, 'args')\n            if args == '$testpath':\n                return [args]\n            return args.split(',')\n        except NoOptionError:\n            return []\n\n    def _get_kwargs_from_section(self, section):\n        result = {}\n        kwargs = self.config.get(section, 'kwargs', fallback='')\n        for kwarg in kwargs.split(','):\n            if kwarg == '':\n                continue\n            key, value = kwarg.split('=')\n            result[key] = value\n        return result\n\n    def _get_resolutions_by_kind(self, kind, paths):\n        self.validate_kind_section(kind)\n\n        resolutions = []\n        success = ReferenceResolutionResult.SUCCESS\n\n        config = {'uri': self._get_uri_from_section(kind),\n                  'args': self._get_args_from_section(kind),\n                  'kwargs': self._get_kwargs_from_section(kind)}\n        for path in paths:\n            uri = config.get('uri')\n            args = config.get('args')\n            kwargs = config.get('kwargs')\n            if uri == '$testpath':\n                uri = path\n            if '$testpath' in args:\n                args = [item.replace('$testpath', path) for item in args]\n            if '$testpath' in kwargs.values():\n                kwargs = {k: v.replace('$testpath', path)\n                          for k, v in kwargs.items()}\n            runnable = Runnable(kind, uri, *args, **kwargs)\n            resolutions.append(ReferenceResolution(reference=path,\n                                                   result=success,\n                                                   resolutions=[runnable],\n                                                   origin=path))\n        return resolutions\n\n    def _get_uri_from_section(self, section):\n        return self.config.get(section, 'uri')\n\n    def _parse(self):\n        self.config = ConfigParser()\n        config_paths = self.config.read(self.filename)\n        if not config_paths:\n            raise ConfigFileNotFound(self.filename)\n\n    def get_resolutions(self):\n        \"\"\"Return a list of resolutions based on the file definitions.\"\"\"\n        resolutions = []\n        for kind in self.config['kinds']:\n            files = self.config.get('kinds', kind)\n            resolutions.extend(self._get_resolutions_by_kind(kind,\n                                                             glob(files)))\n        return resolutions\n\n    def validate_kind_section(self, kind):\n        \"\"\"Validates a specific \"kind section\".\n\n        This method will raise a `settings.SettingsError` if any problem is\n        found on the file.\n\n        :param kind: a string with the specific section.\n        \"\"\"\n        if kind not in self.config:\n            msg = 'Section {} is not defined. Please check your hint file.'\n            raise SettingsError(msg.format(kind))\n\n        uri = self._get_uri_from_section(kind)\n        if uri is None:\n            msg = \"uri needs to be defined inside {}\".format(kind)\n            raise SettingsError(msg)\n", "path": "avocado/core/parser.py"}], "after_files": [{"content": "# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n#\n# See LICENSE for more details.\n#\n# Copyright: Red Hat Inc. 2013-2014\n# Author: Ruda Moura <rmoura@redhat.com>\n\n\"\"\"\nAvocado application command line parsing.\n\"\"\"\n\nimport argparse\nfrom configparser import ConfigParser, NoOptionError\nfrom glob import glob\n\nfrom . import exit_codes\nfrom .nrunner import Runnable\nfrom .output import LOG_UI\nfrom .resolver import ReferenceResolution, ReferenceResolutionResult\nfrom .settings import ConfigFileNotFound, SettingsError, settings\nfrom .version import VERSION\n\nPROG = 'avocado'\nDESCRIPTION = 'Avocado Test Runner'\n\n\nclass ArgumentParser(argparse.ArgumentParser):\n\n    \"\"\"\n    Class to override argparse functions\n    \"\"\"\n\n    def error(self, message):\n        LOG_UI.debug(self.format_help())\n        LOG_UI.error(\"%s: error: %s\", self.prog, message)\n        if \"unrecognized arguments\" in message:\n            LOG_UI.warning(\"Perhaps a plugin is missing; run 'avocado\"\n                           \" plugins' to list the installed ones\")\n        self.exit(exit_codes.AVOCADO_FAIL)\n\n    def _get_option_tuples(self, option_string):\n        return []\n\n\nclass FileOrStdoutAction(argparse.Action):\n\n    \"\"\"\n    Controls claiming the right to write to the application standard output\n    \"\"\"\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        if values == '-':\n            stdout_claimed_by = getattr(namespace, 'stdout_claimed_by', None)\n            if stdout_claimed_by is not None:\n                msg = ('Options %s %s are trying to use stdout simultaneously.'\n                       ' Please set at least one of them to a file to avoid '\n                       'conflicts' % (stdout_claimed_by, option_string))\n                raise argparse.ArgumentError(self, msg)\n            else:\n                setattr(namespace, 'stdout_claimed_by', option_string)\n        setattr(namespace, self.dest, values)\n\n\nclass Parser:\n\n    \"\"\"\n    Class to Parse the command line arguments.\n    \"\"\"\n\n    def __init__(self):\n        self.args = argparse.Namespace()\n        self.config = {}\n        self.subcommands = None\n        self.application = ArgumentParser(prog=PROG,\n                                          add_help=False,  # see parent parsing\n                                          description=DESCRIPTION)\n        self.application.add_argument('-v', '--version', action='version',\n                                      version='Avocado %s' % VERSION)\n        self.application.add_argument('--config', metavar='CONFIG_FILE',\n                                      nargs='?',\n                                      help='Use custom configuration from a file')\n\n        help_msg = ('Turn the paginator on/off. Useful when outputs are too'\n                    'long. This will be a boolean soon.')\n        settings.register_option(section='core',\n                                 key='paginator',\n                                 help_msg=help_msg,\n                                 default='off',\n                                 choices=('on', 'off'),\n                                 parser=self.application,\n                                 long_arg='--paginator')\n\n        help_msg = ('Some commands can produce more information. This option '\n                    'will enable the verbosity when applicable.')\n        settings.register_option(section='core',\n                                 key='verbose',\n                                 help_msg=help_msg,\n                                 default=False,\n                                 key_type=bool,\n                                 parser=self.application,\n                                 long_arg='--verbose',\n                                 short_arg='-V')\n\n        settings.add_argparser_to_option(namespace='core.show',\n                                         parser=self.application,\n                                         long_arg='--show')\n\n    def start(self):\n        \"\"\"\n        Start to parsing arguments.\n\n        At the end of this method, the support for subparsers is activated.\n        Side effect: update attribute `args` (the namespace).\n        \"\"\"\n        self.args, _ = self.application.parse_known_args()\n\n        # Load settings from file, if user provides one\n        if self.args.config is not None:\n            settings.process_config_path(self.args.config)\n\n        # Use parent parsing to avoid breaking the output of --help option\n        self.application = ArgumentParser(prog=PROG,\n                                          description=DESCRIPTION,\n                                          parents=[self.application])\n\n        # Subparsers where Avocado subcommands are plugged\n        self.subcommands = self.application.add_subparsers(\n            title='subcommands',\n            description='valid subcommands',\n            help='subcommand help',\n            dest='subcommand')\n        # On Python 2, required doesn't make a difference because a\n        # subparser is considered an unconsumed positional arguments,\n        # and not providing one will error with a \"too few arguments\"\n        # message.  On Python 3, required arguments are used instead.\n        # Unfortunately, there's no way to pass this as an option when\n        # constructing the sub parsers, but it is possible to set that\n        # option afterwards.\n        self.subcommands.required = True\n\n    def finish(self):\n        \"\"\"\n        Finish the process of parsing arguments.\n\n        Side effect: set the final value on attribute `config`.\n        \"\"\"\n        args, extra = self.application.parse_known_args(namespace=self.args)\n        if extra:\n            msg = 'unrecognized arguments: %s' % ' '.join(extra)\n            for sub in self.application._subparsers._actions:  # pylint: disable=W0212\n                if sub.dest == 'subcommand':\n                    sub.choices[self.args.subcommand].error(msg)\n\n            self.application.error(msg)\n        # from this point on, config is a dictionary based on a argparse.Namespace\n        self.config = vars(args)\n\n\nclass HintParser:\n    def __init__(self, filename):\n        self.filename = filename\n        self.config = None\n        self.hints = []\n        self._parse()\n\n    def _get_args_from_section(self, section):\n        try:\n            args = self.config.get(section, 'args')\n            if args == '$testpath':\n                return [args]\n            return args.split(',')\n        except NoOptionError:\n            return []\n\n    def _get_kwargs_from_section(self, section):\n        result = {}\n        kwargs = self.config.get(section, 'kwargs', fallback='')\n        for kwarg in kwargs.split(','):\n            if kwarg == '':\n                continue\n            key, value = kwarg.split('=')\n            result[key] = value\n        return result\n\n    def _get_resolutions_by_kind(self, kind, paths):\n        self.validate_kind_section(kind)\n\n        resolutions = []\n        success = ReferenceResolutionResult.SUCCESS\n\n        config = {'uri': self._get_uri_from_section(kind),\n                  'args': self._get_args_from_section(kind),\n                  'kwargs': self._get_kwargs_from_section(kind)}\n        for path in paths:\n            uri = config.get('uri')\n            args = config.get('args')\n            kwargs = config.get('kwargs')\n            if uri == '$testpath':\n                uri = path\n            if '$testpath' in args:\n                args = [item.replace('$testpath', path) for item in args]\n            if '$testpath' in kwargs.values():\n                kwargs = {k: v.replace('$testpath', path)\n                          for k, v in kwargs.items()}\n            runnable = Runnable(kind, uri, *args, **kwargs)\n            resolutions.append(ReferenceResolution(reference=path,\n                                                   result=success,\n                                                   resolutions=[runnable],\n                                                   origin=path))\n        return resolutions\n\n    def _get_uri_from_section(self, section):\n        return self.config.get(section, 'uri')\n\n    def _parse(self):\n        self.config = ConfigParser()\n        config_paths = self.config.read(self.filename)\n        if not config_paths:\n            raise ConfigFileNotFound(self.filename)\n\n    def get_resolutions(self):\n        \"\"\"Return a list of resolutions based on the file definitions.\"\"\"\n        resolutions = []\n        for kind in self.config['kinds']:\n            files = self.config.get('kinds', kind)\n            resolutions.extend(self._get_resolutions_by_kind(kind,\n                                                             glob(files)))\n        return resolutions\n\n    def validate_kind_section(self, kind):\n        \"\"\"Validates a specific \"kind section\".\n\n        This method will raise a `settings.SettingsError` if any problem is\n        found on the file.\n\n        :param kind: a string with the specific section.\n        \"\"\"\n        if kind not in self.config:\n            msg = 'Section {} is not defined. Please check your hint file.'\n            raise SettingsError(msg.format(kind))\n\n        uri = self._get_uri_from_section(kind)\n        if uri is None:\n            msg = \"uri needs to be defined inside {}\".format(kind)\n            raise SettingsError(msg)\n", "path": "avocado/core/parser.py"}]}