prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  glob/collecting: Accept strings too
  the methods there want a list but `glob("string")` makes sense too (and behaves very strangely), we should support that.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `coalib/collecting/Collectors.py`
  Content:
  ```
  1 import os
  2 
  3 from coalib.collecting.Importers import iimport_objects
  4 from coalib.misc.Decorators import yield_once
  5 from coalib.misc.i18n import _
  6 from coalib.parsing.Globbing import iglob
  7 
  8 
  9 def _yield_if_right_kind(bear_class, kinds):
  10     try:
  11         if bear_class.kind() in kinds:
  12             yield bear_class
  13     except NotImplementedError:
  14         pass
  15 
  16 
  17 def _import_bears(file_path, kinds):
  18     # recursive imports:
  19     for bear_list in iimport_objects(file_path,
  20                                      names='__additional_bears__',
  21                                      types=list):
  22         for bear_class in bear_list:
  23             for valid_bear_class in _yield_if_right_kind(bear_class, kinds):
  24                 yield valid_bear_class
  25     # normal import
  26     for bear_class in iimport_objects(file_path,
  27                                       attributes='kind',
  28                                       local=True):
  29         for valid_bear_class in _yield_if_right_kind(bear_class, kinds):
  30             yield valid_bear_class
  31 
  32 
  33 @yield_once
  34 def icollect(file_paths):
  35     """
  36     Evaluate globs in file paths and return all matching files.
  37 
  38     :param file_paths:  list of file paths that can include globs
  39     :return:            iterator that yields paths of all matching files
  40     """
  41     for file_path in file_paths:
  42         for match in iglob(file_path):
  43             yield match
  44 
  45 
  46 def collect_files(file_paths):
  47     """
  48     Evaluate globs in file paths and return all matching files
  49 
  50     :param file_paths: list of file paths that can include globs
  51     :return:           list of paths of all matching files
  52     """
  53     return list(filter(os.path.isfile, icollect(file_paths)))
  54 
  55 
  56 def collect_dirs(dir_paths):
  57     """
  58     Evaluate globs in directory paths and return all matching directories
  59 
  60     :param dir_paths: list of file paths that can include globs
  61     :return:          list of paths of all matching directories
  62     """
  63     return list(filter(os.path.isdir, icollect(dir_paths)))
  64 
  65 
  66 @yield_once
  67 def icollect_bears(bear_dirs, bear_names, kinds, log_printer):
  68     """
  69     Collect all bears from bear directories that have a matching kind.
  70 
  71     :param bear_dirs:   directories that can contain bears
  72     :param bear_names:  names of bears
  73     :param kinds:       list of bear kinds to be collected
  74     :param log_printer: log_printer to handle logging
  75     :return:            iterator that yields bear classes
  76     """
  77     for bear_dir in filter(os.path.isdir, icollect(bear_dirs)):
  78         for bear_name in bear_names:
  79             for matching_file in iglob(
  80                     os.path.join(bear_dir, bear_name + '.py')):
  81 
  82                 try:
  83                     for bear in _import_bears(matching_file, kinds):
  84                         yield bear
  85                 except:
  86                     log_printer.warn(_("Unable to collect bears from {file}. "
  87                                        "Probably the file is malformed or "
  88                                        "the module code raises an exception.")
  89                                      .format(file=matching_file))
  90 
  91 
  92 def collect_bears(bear_dirs, bear_names, kinds, log_printer):
  93     """
  94     Collect all bears from bear directories that have a matching kind.
  95 
  96     :param bear_dirs:   directories that can contain bears
  97     :param bear_names:  names of bears
  98     :param kinds: list  of bear kinds to be collected
  99     :param log_printer: log_printer to handle logging
  100     :return:            list of matching bear classes
  101     """
  102     return list(icollect_bears(bear_dirs, bear_names, kinds, log_printer))
  103
  ```
  --- 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/coalib/collecting/Collectors.py b/coalib/collecting/Collectors.py
  --- a/coalib/collecting/Collectors.py
  +++ b/coalib/collecting/Collectors.py
  @@ -35,9 +35,12 @@
       """
       Evaluate globs in file paths and return all matching files.
   
  -    :param file_paths:  list of file paths that can include globs
  +    :param file_paths:  file path or list of such that can include globs
       :return:            iterator that yields paths of all matching files
       """
  +    if isinstance(file_paths, str):
  +        file_paths = [file_paths]
  +
       for file_path in file_paths:
           for match in iglob(file_path):
               yield match
  @@ -47,7 +50,7 @@
       """
       Evaluate globs in file paths and return all matching files
   
  -    :param file_paths: list of file paths that can include globs
  +    :param file_paths: file path or list of such that can include globs
       :return:           list of paths of all matching files
       """
       return list(filter(os.path.isfile, icollect(file_paths)))
  @@ -57,7 +60,7 @@
       """
       Evaluate globs in directory paths and return all matching directories
   
  -    :param dir_paths: list of file paths that can include globs
  +    :param dir_paths: file path or list of such that can include globs
       :return:          list of paths of all matching directories
       """
       return list(filter(os.path.isdir, icollect(dir_paths)))
  @@ -68,7 +71,7 @@
       """
       Collect all bears from bear directories that have a matching kind.
   
  -    :param bear_dirs:   directories that can contain bears
  +    :param bear_dirs:   directory name or list of such that can contain bears
       :param bear_names:  names of bears
       :param kinds:       list of bear kinds to be collected
       :param log_printer: log_printer to handle logging
  @@ -93,7 +96,7 @@
       """
       Collect all bears from bear directories that have a matching kind.
   
  -    :param bear_dirs:   directories that can contain bears
  +    :param bear_dirs:   directory name or list of such that can contain bears
       :param bear_names:  names of bears
       :param kinds: list  of bear kinds to be collected
       :param log_printer: log_printer to handle logging
  
verification_info: {"golden_diff": "diff --git a/coalib/collecting/Collectors.py b/coalib/collecting/Collectors.py\n--- a/coalib/collecting/Collectors.py\n+++ b/coalib/collecting/Collectors.py\n@@ -35,9 +35,12 @@\n     \"\"\"\n     Evaluate globs in file paths and return all matching files.\n \n-    :param file_paths:  list of file paths that can include globs\n+    :param file_paths:  file path or list of such that can include globs\n     :return:            iterator that yields paths of all matching files\n     \"\"\"\n+    if isinstance(file_paths, str):\n+        file_paths = [file_paths]\n+\n     for file_path in file_paths:\n         for match in iglob(file_path):\n             yield match\n@@ -47,7 +50,7 @@\n     \"\"\"\n     Evaluate globs in file paths and return all matching files\n \n-    :param file_paths: list of file paths that can include globs\n+    :param file_paths: file path or list of such that can include globs\n     :return:           list of paths of all matching files\n     \"\"\"\n     return list(filter(os.path.isfile, icollect(file_paths)))\n@@ -57,7 +60,7 @@\n     \"\"\"\n     Evaluate globs in directory paths and return all matching directories\n \n-    :param dir_paths: list of file paths that can include globs\n+    :param dir_paths: file path or list of such that can include globs\n     :return:          list of paths of all matching directories\n     \"\"\"\n     return list(filter(os.path.isdir, icollect(dir_paths)))\n@@ -68,7 +71,7 @@\n     \"\"\"\n     Collect all bears from bear directories that have a matching kind.\n \n-    :param bear_dirs:   directories that can contain bears\n+    :param bear_dirs:   directory name or list of such that can contain bears\n     :param bear_names:  names of bears\n     :param kinds:       list of bear kinds to be collected\n     :param log_printer: log_printer to handle logging\n@@ -93,7 +96,7 @@\n     \"\"\"\n     Collect all bears from bear directories that have a matching kind.\n \n-    :param bear_dirs:   directories that can contain bears\n+    :param bear_dirs:   directory name or list of such that can contain bears\n     :param bear_names:  names of bears\n     :param kinds: list  of bear kinds to be collected\n     :param log_printer: log_printer to handle logging\n", "issue": "glob/collecting: Accept strings too\nthe methods there want a list but `glob(\"string\")` makes sense too (and behaves very strangely), we should support that.\n\n", "before_files": [{"content": "import os\n\nfrom coalib.collecting.Importers import iimport_objects\nfrom coalib.misc.Decorators import yield_once\nfrom coalib.misc.i18n import _\nfrom coalib.parsing.Globbing import iglob\n\n\ndef _yield_if_right_kind(bear_class, kinds):\n    try:\n        if bear_class.kind() in kinds:\n            yield bear_class\n    except NotImplementedError:\n        pass\n\n\ndef _import_bears(file_path, kinds):\n    # recursive imports:\n    for bear_list in iimport_objects(file_path,\n                                     names='__additional_bears__',\n                                     types=list):\n        for bear_class in bear_list:\n            for valid_bear_class in _yield_if_right_kind(bear_class, kinds):\n                yield valid_bear_class\n    # normal import\n    for bear_class in iimport_objects(file_path,\n                                      attributes='kind',\n                                      local=True):\n        for valid_bear_class in _yield_if_right_kind(bear_class, kinds):\n            yield valid_bear_class\n\n\n@yield_once\ndef icollect(file_paths):\n    \"\"\"\n    Evaluate globs in file paths and return all matching files.\n\n    :param file_paths:  list of file paths that can include globs\n    :return:            iterator that yields paths of all matching files\n    \"\"\"\n    for file_path in file_paths:\n        for match in iglob(file_path):\n            yield match\n\n\ndef collect_files(file_paths):\n    \"\"\"\n    Evaluate globs in file paths and return all matching files\n\n    :param file_paths: list of file paths that can include globs\n    :return:           list of paths of all matching files\n    \"\"\"\n    return list(filter(os.path.isfile, icollect(file_paths)))\n\n\ndef collect_dirs(dir_paths):\n    \"\"\"\n    Evaluate globs in directory paths and return all matching directories\n\n    :param dir_paths: list of file paths that can include globs\n    :return:          list of paths of all matching directories\n    \"\"\"\n    return list(filter(os.path.isdir, icollect(dir_paths)))\n\n\n@yield_once\ndef icollect_bears(bear_dirs, bear_names, kinds, log_printer):\n    \"\"\"\n    Collect all bears from bear directories that have a matching kind.\n\n    :param bear_dirs:   directories that can contain bears\n    :param bear_names:  names of bears\n    :param kinds:       list of bear kinds to be collected\n    :param log_printer: log_printer to handle logging\n    :return:            iterator that yields bear classes\n    \"\"\"\n    for bear_dir in filter(os.path.isdir, icollect(bear_dirs)):\n        for bear_name in bear_names:\n            for matching_file in iglob(\n                    os.path.join(bear_dir, bear_name + '.py')):\n\n                try:\n                    for bear in _import_bears(matching_file, kinds):\n                        yield bear\n                except:\n                    log_printer.warn(_(\"Unable to collect bears from {file}. \"\n                                       \"Probably the file is malformed or \"\n                                       \"the module code raises an exception.\")\n                                     .format(file=matching_file))\n\n\ndef collect_bears(bear_dirs, bear_names, kinds, log_printer):\n    \"\"\"\n    Collect all bears from bear directories that have a matching kind.\n\n    :param bear_dirs:   directories that can contain bears\n    :param bear_names:  names of bears\n    :param kinds: list  of bear kinds to be collected\n    :param log_printer: log_printer to handle logging\n    :return:            list of matching bear classes\n    \"\"\"\n    return list(icollect_bears(bear_dirs, bear_names, kinds, log_printer))\n", "path": "coalib/collecting/Collectors.py"}], "after_files": [{"content": "import os\n\nfrom coalib.collecting.Importers import iimport_objects\nfrom coalib.misc.Decorators import yield_once\nfrom coalib.misc.i18n import _\nfrom coalib.parsing.Globbing import iglob\n\n\ndef _yield_if_right_kind(bear_class, kinds):\n    try:\n        if bear_class.kind() in kinds:\n            yield bear_class\n    except NotImplementedError:\n        pass\n\n\ndef _import_bears(file_path, kinds):\n    # recursive imports:\n    for bear_list in iimport_objects(file_path,\n                                     names='__additional_bears__',\n                                     types=list):\n        for bear_class in bear_list:\n            for valid_bear_class in _yield_if_right_kind(bear_class, kinds):\n                yield valid_bear_class\n    # normal import\n    for bear_class in iimport_objects(file_path,\n                                      attributes='kind',\n                                      local=True):\n        for valid_bear_class in _yield_if_right_kind(bear_class, kinds):\n            yield valid_bear_class\n\n\n@yield_once\ndef icollect(file_paths):\n    \"\"\"\n    Evaluate globs in file paths and return all matching files.\n\n    :param file_paths:  file path or list of such that can include globs\n    :return:            iterator that yields paths of all matching files\n    \"\"\"\n    if isinstance(file_paths, str):\n        file_paths = [file_paths]\n\n    for file_path in file_paths:\n        for match in iglob(file_path):\n            yield match\n\n\ndef collect_files(file_paths):\n    \"\"\"\n    Evaluate globs in file paths and return all matching files\n\n    :param file_paths: file path or list of such that can include globs\n    :return:           list of paths of all matching files\n    \"\"\"\n    return list(filter(os.path.isfile, icollect(file_paths)))\n\n\ndef collect_dirs(dir_paths):\n    \"\"\"\n    Evaluate globs in directory paths and return all matching directories\n\n    :param dir_paths: file path or list of such that can include globs\n    :return:          list of paths of all matching directories\n    \"\"\"\n    return list(filter(os.path.isdir, icollect(dir_paths)))\n\n\n@yield_once\ndef icollect_bears(bear_dirs, bear_names, kinds, log_printer):\n    \"\"\"\n    Collect all bears from bear directories that have a matching kind.\n\n    :param bear_dirs:   directory name or list of such that can contain bears\n    :param bear_names:  names of bears\n    :param kinds:       list of bear kinds to be collected\n    :param log_printer: log_printer to handle logging\n    :return:            iterator that yields bear classes\n    \"\"\"\n    for bear_dir in filter(os.path.isdir, icollect(bear_dirs)):\n        for bear_name in bear_names:\n            for matching_file in iglob(\n                    os.path.join(bear_dir, bear_name + '.py')):\n\n                try:\n                    for bear in _import_bears(matching_file, kinds):\n                        yield bear\n                except:\n                    log_printer.warn(_(\"Unable to collect bears from {file}. \"\n                                       \"Probably the file is malformed or \"\n                                       \"the module code raises an exception.\")\n                                     .format(file=matching_file))\n\n\ndef collect_bears(bear_dirs, bear_names, kinds, log_printer):\n    \"\"\"\n    Collect all bears from bear directories that have a matching kind.\n\n    :param bear_dirs:   directory name or list of such that can contain bears\n    :param bear_names:  names of bears\n    :param kinds: list  of bear kinds to be collected\n    :param log_printer: log_printer to handle logging\n    :return:            list of matching bear classes\n    \"\"\"\n    return list(icollect_bears(bear_dirs, bear_names, kinds, log_printer))\n", "path": "coalib/collecting/Collectors.py"}]}