We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Incorrectly lower casing table_name for csv
It looks like we're lower casing manually set table/directory names, at least for csv but probably for all flat file engines.

```
$ mkdir TESTER
$ retriever install csv mammal-masses --table_name TESTER/test.csv
=> Installing mammal-masses
[Errno 2] No such file or directory: 'tester/test.csv'
Done!

$ mkdir tester
$ retriever install csv mammal-masses --table_name TESTER/test.csv
=> Installing mammal-masses
Progress: 5731/5731 rows inserted into tester/test.csv totaling 5731:

Done!
```

This is causing issues for the R package, see https://github.com/ropensci/rdataretriever/issues/131, but is also a general problem since directory names are case sensitive for 2/3 OSs.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `retriever/__main__.py`
Content:
```
1 """Data Retriever Wizard
2 
3 Running this module directly will launch the download wizard, allowing the user
4 to choose from all scripts.
5 
6 The main() function can be used for bootstrapping.
7 
8 """
9 from __future__ import absolute_import
10 from __future__ import print_function
11 
12 import os
13 import sys
14 from builtins import input
15 from imp import reload
16 
17 from retriever.engines import engine_list, choose_engine
18 from retriever.lib.datapackage import create_json, edit_json, delete_json, get_script_filename
19 from retriever.lib.datasets import datasets, dataset_names, license
20 from retriever.lib.defaults import sample_script, CITATION, ENCODING, SCRIPT_SEARCH_PATHS
21 from retriever.lib.get_opts import parser
22 from retriever.lib.repository import check_for_updates
23 from retriever.lib.scripts import SCRIPT_LIST, get_script
24 from retriever.lib.engine_tools import name_matches, reset_retriever
25 
26 encoding = ENCODING.lower()
27 # sys removes the setdefaultencoding method at startup; reload to get it back
28 reload(sys)
29 if hasattr(sys, 'setdefaultencoding'):
30     sys.setdefaultencoding(encoding)
31 
32 
33 def main():
34     """This function launches the Data Retriever."""
35     sys.argv[1:] = [arg.lower() for arg in sys.argv[1:]]
36     if len(sys.argv) == 1:
37         # if no command line args are passed, show the help options
38         parser.parse_args(['-h'])
39 
40     else:
41         # otherwise, parse them
42 
43         if not os.path.isdir(SCRIPT_SEARCH_PATHS[1]) and not \
44                 [f for f in os.listdir(SCRIPT_SEARCH_PATHS[-1])
45                  if os.path.exists(SCRIPT_SEARCH_PATHS[-1])]:
46             check_for_updates()
47         script_list = SCRIPT_LIST()
48 
49         args = parser.parse_args()
50 
51         if args.command == "install" and not args.engine:
52             parser.parse_args(['install', '-h'])
53 
54         if args.quiet:
55             sys.stdout = open(os.devnull, 'w')
56 
57         if args.command == 'help':
58             parser.parse_args(['-h'])
59 
60         if hasattr(args, 'compile') and args.compile:
61             script_list = SCRIPT_LIST(force_compile=True)
62 
63         if args.command == 'defaults':
64             for engine_item in engine_list:
65                 print("Default options for engine ", engine_item.name)
66                 for default_opts in engine_item.required_opts:
67                     print(default_opts[0], " ", default_opts[2])
68                 print()
69             return
70 
71         if args.command == 'update':
72             check_for_updates(False)
73             script_list = SCRIPT_LIST()
74             return
75 
76         elif args.command == 'citation':
77             if args.dataset is None:
78                 print("\nCitation for retriever:\n")
79                 print(CITATION)
80             else:
81                 scripts = name_matches(script_list, args.dataset)
82                 for dataset in scripts:
83                     print("\nDataset:  {}".format(dataset.name))
84                     print("Citation:   {}".format(dataset.citation))
85                     print("Description:   {}\n".format(dataset.description))
86 
87             return
88 
89         elif args.command == 'license':
90             dataset_license = license(args.dataset)
91             if dataset_license:
92                 print(dataset_license)
93             else:
94                 print("There is no license information for {}".format(args.dataset))
95             return
96 
97         elif args.command == 'new':
98             f = open(args.filename, 'w')
99             f.write(sample_script)
100             f.close()
101 
102             return
103 
104         elif args.command == 'reset':
105             reset_retriever(args.scope)
106             return
107 
108         elif args.command == 'new_json':
109             # create new JSON script
110             create_json()
111             return
112 
113         elif args.command == 'edit_json':
114             # edit existing JSON script
115             json_file = get_script_filename(args.dataset.lower())
116             edit_json(json_file)
117             return
118 
119         elif args.command == 'delete_json':
120             # delete existing JSON script from home directory and or script directory if exists in current dir
121             confirm = input("Really remove " + args.dataset.lower() +
122                             " and all its contents? (y/N): ")
123             if confirm.lower().strip() in ['y', 'yes']:
124                 json_file = get_script_filename(args.dataset.lower())
125                 delete_json(json_file)
126             return
127 
128         if args.command == 'ls':
129             # If scripts have never been downloaded there is nothing to list
130             if not script_list:
131                 print("No scripts are currently available. Updating scripts now...")
132                 check_for_updates(False)
133                 print("\n\nScripts downloaded.\n")
134             if not (args.l or args.k or (type(args.v) is list)):
135                 all_scripts = dataset_names()
136                 print("Available datasets : {}\n".format(len(all_scripts)))
137                 from retriever import lscolumns
138                 lscolumns.printls(all_scripts)
139             
140             elif type(args.v) is list:
141                 if args.v:
142                     try:
143                         all_scripts = [get_script(dataset) for dataset in args.v]
144                     except KeyError:
145                         all_scripts = []
146                         print("Dataset(s) is not found.")
147                 else:
148                     all_scripts = datasets()
149                 count = 1
150                 for script in all_scripts:
151                     print("{}. {}\n{}\n{}\n{}\n".format(
152                         count, script.title,
153                         script.name,
154                         script.keywords,
155                         script.description,
156                         str(script.licenses[0]['name']),
157                         script.citation
158                     ))
159                     count += 1
160  
161             else:
162                 param_licenses = args.l if args.l else None
163                 keywords = args.k if args.k else None
164 
165                 # search
166                 searched_scripts = datasets(keywords, param_licenses)
167                 if not searched_scripts:
168                     print("No available datasets found")
169                 else:
170                     print("Available datasets : {}\n".format(len(searched_scripts)))
171                     count = 1
172                     for script in searched_scripts:
173                         print("{}. {}\n{}\n{}\n{}\n".format(
174                                 count, script.title,
175                                 script.name,
176                                 script.keywords,
177                                 str(script.licenses[0]['name'])
178                         ))
179                         count += 1
180             return
181 
182         engine = choose_engine(args.__dict__)
183 
184         if hasattr(args, 'debug') and args.debug:
185             debug = True
186         else:
187             debug = False
188             sys.tracebacklimit = 0
189 
190         if hasattr(args, 'debug') and args.not_cached:
191             engine.use_cache = False
192         else:
193             engine.use_cache = True
194 
195         if args.dataset is not None:
196             scripts = name_matches(script_list, args.dataset)
197         else:
198             raise Exception("no dataset specified.")
199         if scripts:
200             for dataset in scripts:
201                 print("=> Installing", dataset.name)
202                 try:
203                     dataset.download(engine, debug=debug)
204                     dataset.engine.final_cleanup()
205                 except KeyboardInterrupt:
206                     pass
207                 except Exception as e:
208                     print(e)
209                     if debug:
210                         raise
211             print("Done!")
212         else:
213             print("Run 'retriever ls' to see a list of currently available datasets.")
214 
215 
216 if __name__ == "__main__":
217     main()
218
```
--- 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/retriever/__main__.py b/retriever/__main__.py
--- a/retriever/__main__.py
+++ b/retriever/__main__.py
@@ -32,7 +32,6 @@
 
 def main():
     """This function launches the Data Retriever."""
-    sys.argv[1:] = [arg.lower() for arg in sys.argv[1:]]
     if len(sys.argv) == 1:
         # if no command line args are passed, show the help options
         parser.parse_args(['-h'])

{"golden_diff": "diff --git a/retriever/__main__.py b/retriever/__main__.py\n--- a/retriever/__main__.py\n+++ b/retriever/__main__.py\n@@ -32,7 +32,6 @@\n \n def main():\n     \"\"\"This function launches the Data Retriever.\"\"\"\n-    sys.argv[1:] = [arg.lower() for arg in sys.argv[1:]]\n     if len(sys.argv) == 1:\n         # if no command line args are passed, show the help options\n         parser.parse_args(['-h'])\n", "issue": "Incorrectly lower casing table_name for csv\nIt looks like we're lower casing manually set table/directory names, at least for csv but probably for all flat file engines.\r\n\r\n```\r\n$ mkdir TESTER\r\n$ retriever install csv mammal-masses --table_name TESTER/test.csv\r\n=> Installing mammal-masses\r\n[Errno 2] No such file or directory: 'tester/test.csv'\r\nDone!\r\n\r\n$ mkdir tester\r\n$ retriever install csv mammal-masses --table_name TESTER/test.csv\r\n=> Installing mammal-masses\r\nProgress: 5731/5731 rows inserted into tester/test.csv totaling 5731:\r\n\r\nDone!\r\n```\r\n\r\nThis is causing issues for the R package, see https://github.com/ropensci/rdataretriever/issues/131, but is also a general problem since directory names are case sensitive for 2/3 OSs.\n", "before_files": [{"content": "\"\"\"Data Retriever Wizard\n\nRunning this module directly will launch the download wizard, allowing the user\nto choose from all scripts.\n\nThe main() function can be used for bootstrapping.\n\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimport os\nimport sys\nfrom builtins import input\nfrom imp import reload\n\nfrom retriever.engines import engine_list, choose_engine\nfrom retriever.lib.datapackage import create_json, edit_json, delete_json, get_script_filename\nfrom retriever.lib.datasets import datasets, dataset_names, license\nfrom retriever.lib.defaults import sample_script, CITATION, ENCODING, SCRIPT_SEARCH_PATHS\nfrom retriever.lib.get_opts import parser\nfrom retriever.lib.repository import check_for_updates\nfrom retriever.lib.scripts import SCRIPT_LIST, get_script\nfrom retriever.lib.engine_tools import name_matches, reset_retriever\n\nencoding = ENCODING.lower()\n# sys removes the setdefaultencoding method at startup; reload to get it back\nreload(sys)\nif hasattr(sys, 'setdefaultencoding'):\n    sys.setdefaultencoding(encoding)\n\n\ndef main():\n    \"\"\"This function launches the Data Retriever.\"\"\"\n    sys.argv[1:] = [arg.lower() for arg in sys.argv[1:]]\n    if len(sys.argv) == 1:\n        # if no command line args are passed, show the help options\n        parser.parse_args(['-h'])\n\n    else:\n        # otherwise, parse them\n\n        if not os.path.isdir(SCRIPT_SEARCH_PATHS[1]) and not \\\n                [f for f in os.listdir(SCRIPT_SEARCH_PATHS[-1])\n                 if os.path.exists(SCRIPT_SEARCH_PATHS[-1])]:\n            check_for_updates()\n        script_list = SCRIPT_LIST()\n\n        args = parser.parse_args()\n\n        if args.command == \"install\" and not args.engine:\n            parser.parse_args(['install', '-h'])\n\n        if args.quiet:\n            sys.stdout = open(os.devnull, 'w')\n\n        if args.command == 'help':\n            parser.parse_args(['-h'])\n\n        if hasattr(args, 'compile') and args.compile:\n            script_list = SCRIPT_LIST(force_compile=True)\n\n        if args.command == 'defaults':\n            for engine_item in engine_list:\n                print(\"Default options for engine \", engine_item.name)\n                for default_opts in engine_item.required_opts:\n                    print(default_opts[0], \" \", default_opts[2])\n                print()\n            return\n\n        if args.command == 'update':\n            check_for_updates(False)\n            script_list = SCRIPT_LIST()\n            return\n\n        elif args.command == 'citation':\n            if args.dataset is None:\n                print(\"\\nCitation for retriever:\\n\")\n                print(CITATION)\n            else:\n                scripts = name_matches(script_list, args.dataset)\n                for dataset in scripts:\n                    print(\"\\nDataset:  {}\".format(dataset.name))\n                    print(\"Citation:   {}\".format(dataset.citation))\n                    print(\"Description:   {}\\n\".format(dataset.description))\n\n            return\n\n        elif args.command == 'license':\n            dataset_license = license(args.dataset)\n            if dataset_license:\n                print(dataset_license)\n            else:\n                print(\"There is no license information for {}\".format(args.dataset))\n            return\n\n        elif args.command == 'new':\n            f = open(args.filename, 'w')\n            f.write(sample_script)\n            f.close()\n\n            return\n\n        elif args.command == 'reset':\n            reset_retriever(args.scope)\n            return\n\n        elif args.command == 'new_json':\n            # create new JSON script\n            create_json()\n            return\n\n        elif args.command == 'edit_json':\n            # edit existing JSON script\n            json_file = get_script_filename(args.dataset.lower())\n            edit_json(json_file)\n            return\n\n        elif args.command == 'delete_json':\n            # delete existing JSON script from home directory and or script directory if exists in current dir\n            confirm = input(\"Really remove \" + args.dataset.lower() +\n                            \" and all its contents? (y/N): \")\n            if confirm.lower().strip() in ['y', 'yes']:\n                json_file = get_script_filename(args.dataset.lower())\n                delete_json(json_file)\n            return\n\n        if args.command == 'ls':\n            # If scripts have never been downloaded there is nothing to list\n            if not script_list:\n                print(\"No scripts are currently available. Updating scripts now...\")\n                check_for_updates(False)\n                print(\"\\n\\nScripts downloaded.\\n\")\n            if not (args.l or args.k or (type(args.v) is list)):\n                all_scripts = dataset_names()\n                print(\"Available datasets : {}\\n\".format(len(all_scripts)))\n                from retriever import lscolumns\n                lscolumns.printls(all_scripts)\n            \n            elif type(args.v) is list:\n                if args.v:\n                    try:\n                        all_scripts = [get_script(dataset) for dataset in args.v]\n                    except KeyError:\n                        all_scripts = []\n                        print(\"Dataset(s) is not found.\")\n                else:\n                    all_scripts = datasets()\n                count = 1\n                for script in all_scripts:\n                    print(\"{}. {}\\n{}\\n{}\\n{}\\n\".format(\n                        count, script.title,\n                        script.name,\n                        script.keywords,\n                        script.description,\n                        str(script.licenses[0]['name']),\n                        script.citation\n                    ))\n                    count += 1\n \n            else:\n                param_licenses = args.l if args.l else None\n                keywords = args.k if args.k else None\n\n                # search\n                searched_scripts = datasets(keywords, param_licenses)\n                if not searched_scripts:\n                    print(\"No available datasets found\")\n                else:\n                    print(\"Available datasets : {}\\n\".format(len(searched_scripts)))\n                    count = 1\n                    for script in searched_scripts:\n                        print(\"{}. {}\\n{}\\n{}\\n{}\\n\".format(\n                                count, script.title,\n                                script.name,\n                                script.keywords,\n                                str(script.licenses[0]['name'])\n                        ))\n                        count += 1\n            return\n\n        engine = choose_engine(args.__dict__)\n\n        if hasattr(args, 'debug') and args.debug:\n            debug = True\n        else:\n            debug = False\n            sys.tracebacklimit = 0\n\n        if hasattr(args, 'debug') and args.not_cached:\n            engine.use_cache = False\n        else:\n            engine.use_cache = True\n\n        if args.dataset is not None:\n            scripts = name_matches(script_list, args.dataset)\n        else:\n            raise Exception(\"no dataset specified.\")\n        if scripts:\n            for dataset in scripts:\n                print(\"=> Installing\", dataset.name)\n                try:\n                    dataset.download(engine, debug=debug)\n                    dataset.engine.final_cleanup()\n                except KeyboardInterrupt:\n                    pass\n                except Exception as e:\n                    print(e)\n                    if debug:\n                        raise\n            print(\"Done!\")\n        else:\n            print(\"Run 'retriever ls' to see a list of currently available datasets.\")\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "retriever/__main__.py"}], "after_files": [{"content": "\"\"\"Data Retriever Wizard\n\nRunning this module directly will launch the download wizard, allowing the user\nto choose from all scripts.\n\nThe main() function can be used for bootstrapping.\n\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import print_function\n\nimport os\nimport sys\nfrom builtins import input\nfrom imp import reload\n\nfrom retriever.engines import engine_list, choose_engine\nfrom retriever.lib.datapackage import create_json, edit_json, delete_json, get_script_filename\nfrom retriever.lib.datasets import datasets, dataset_names, license\nfrom retriever.lib.defaults import sample_script, CITATION, ENCODING, SCRIPT_SEARCH_PATHS\nfrom retriever.lib.get_opts import parser\nfrom retriever.lib.repository import check_for_updates\nfrom retriever.lib.scripts import SCRIPT_LIST, get_script\nfrom retriever.lib.engine_tools import name_matches, reset_retriever\n\nencoding = ENCODING.lower()\n# sys removes the setdefaultencoding method at startup; reload to get it back\nreload(sys)\nif hasattr(sys, 'setdefaultencoding'):\n    sys.setdefaultencoding(encoding)\n\n\ndef main():\n    \"\"\"This function launches the Data Retriever.\"\"\"\n    if len(sys.argv) == 1:\n        # if no command line args are passed, show the help options\n        parser.parse_args(['-h'])\n\n    else:\n        # otherwise, parse them\n\n        if not os.path.isdir(SCRIPT_SEARCH_PATHS[1]) and not \\\n                [f for f in os.listdir(SCRIPT_SEARCH_PATHS[-1])\n                 if os.path.exists(SCRIPT_SEARCH_PATHS[-1])]:\n            check_for_updates()\n        script_list = SCRIPT_LIST()\n\n        args = parser.parse_args()\n\n        if args.command == \"install\" and not args.engine:\n            parser.parse_args(['install', '-h'])\n\n        if args.quiet:\n            sys.stdout = open(os.devnull, 'w')\n\n        if args.command == 'help':\n            parser.parse_args(['-h'])\n\n        if hasattr(args, 'compile') and args.compile:\n            script_list = SCRIPT_LIST(force_compile=True)\n\n        if args.command == 'defaults':\n            for engine_item in engine_list:\n                print(\"Default options for engine \", engine_item.name)\n                for default_opts in engine_item.required_opts:\n                    print(default_opts[0], \" \", default_opts[2])\n                print()\n            return\n\n        if args.command == 'update':\n            check_for_updates(False)\n            script_list = SCRIPT_LIST()\n            return\n\n        elif args.command == 'citation':\n            if args.dataset is None:\n                print(\"\\nCitation for retriever:\\n\")\n                print(CITATION)\n            else:\n                scripts = name_matches(script_list, args.dataset)\n                for dataset in scripts:\n                    print(\"\\nDataset:  {}\".format(dataset.name))\n                    print(\"Citation:   {}\".format(dataset.citation))\n                    print(\"Description:   {}\\n\".format(dataset.description))\n\n            return\n\n        elif args.command == 'license':\n            dataset_license = license(args.dataset)\n            if dataset_license:\n                print(dataset_license)\n            else:\n                print(\"There is no license information for {}\".format(args.dataset))\n            return\n\n        elif args.command == 'new':\n            f = open(args.filename, 'w')\n            f.write(sample_script)\n            f.close()\n\n            return\n\n        elif args.command == 'reset':\n            reset_retriever(args.scope)\n            return\n\n        elif args.command == 'new_json':\n            # create new JSON script\n            create_json()\n            return\n\n        elif args.command == 'edit_json':\n            # edit existing JSON script\n            json_file = get_script_filename(args.dataset.lower())\n            edit_json(json_file)\n            return\n\n        elif args.command == 'delete_json':\n            # delete existing JSON script from home directory and or script directory if exists in current dir\n            confirm = input(\"Really remove \" + args.dataset.lower() +\n                            \" and all its contents? (y/N): \")\n            if confirm.lower().strip() in ['y', 'yes']:\n                json_file = get_script_filename(args.dataset.lower())\n                delete_json(json_file)\n            return\n\n        if args.command == 'ls':\n            # If scripts have never been downloaded there is nothing to list\n            if not script_list:\n                print(\"No scripts are currently available. Updating scripts now...\")\n                check_for_updates(False)\n                print(\"\\n\\nScripts downloaded.\\n\")\n            if not (args.l or args.k or (type(args.v) is list)):\n                all_scripts = dataset_names()\n                print(\"Available datasets : {}\\n\".format(len(all_scripts)))\n                from retriever import lscolumns\n                lscolumns.printls(all_scripts)\n            \n            elif type(args.v) is list:\n                if args.v:\n                    try:\n                        all_scripts = [get_script(dataset) for dataset in args.v]\n                    except KeyError:\n                        all_scripts = []\n                        print(\"Dataset(s) is not found.\")\n                else:\n                    all_scripts = datasets()\n                count = 1\n                for script in all_scripts:\n                    print(\"{}. {}\\n{}\\n{}\\n{}\\n\".format(\n                        count, script.title,\n                        script.name,\n                        script.keywords,\n                        script.description,\n                        str(script.licenses[0]['name']),\n                        script.citation\n                    ))\n                    count += 1\n \n            else:\n                param_licenses = args.l if args.l else None\n                keywords = args.k if args.k else None\n\n                # search\n                searched_scripts = datasets(keywords, param_licenses)\n                if not searched_scripts:\n                    print(\"No available datasets found\")\n                else:\n                    print(\"Available datasets : {}\\n\".format(len(searched_scripts)))\n                    count = 1\n                    for script in searched_scripts:\n                        print(\"{}. {}\\n{}\\n{}\\n{}\\n\".format(\n                                count, script.title,\n                                script.name,\n                                script.keywords,\n                                str(script.licenses[0]['name'])\n                        ))\n                        count += 1\n            return\n\n        engine = choose_engine(args.__dict__)\n\n        if hasattr(args, 'debug') and args.debug:\n            debug = True\n        else:\n            debug = False\n            sys.tracebacklimit = 0\n\n        if hasattr(args, 'debug') and args.not_cached:\n            engine.use_cache = False\n        else:\n            engine.use_cache = True\n\n        if args.dataset is not None:\n            scripts = name_matches(script_list, args.dataset)\n        else:\n            raise Exception(\"no dataset specified.\")\n        if scripts:\n            for dataset in scripts:\n                print(\"=> Installing\", dataset.name)\n                try:\n                    dataset.download(engine, debug=debug)\n                    dataset.engine.final_cleanup()\n                except KeyboardInterrupt:\n                    pass\n                except Exception as e:\n                    print(e)\n                    if debug:\n                        raise\n            print(\"Done!\")\n        else:\n            print(\"Run 'retriever ls' to see a list of currently available datasets.\")\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "retriever/__main__.py"}]}