We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Calling conda smithy github-create with --user raises exception
When I invoke `oncda smithy` to create a github repo (after setting the token correctly) I get this:

``` python
$ conda smithy github-create --user mwcraig mrjob-feedstock/
Traceback (most recent call last):
  File "/Users/mcraig/miniconda/bin/conda-smithy", line 9, in <module>
    load_entry_point('conda-smithy==0.1.0.dev0', 'console_scripts', 'conda-smithy')()
  File "/Users/mcraig/miniconda/lib/python2.7/site-packages/conda_smithy-0.1.0.dev0-py2.7.egg/conda_smithy/conda_smithy.py", line 164, in main
    args.subcommand_func(args)
  File "/Users/mcraig/miniconda/lib/python2.7/site-packages/conda_smithy-0.1.0.dev0-py2.7.egg/conda_smithy/conda_smithy.py", line 94, in __call__
    user_or_org.get_user(args.user)
UnboundLocalError: local variable 'user_or_org' referenced before assignment
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conda_smithy/conda_smithy.py`
Content:
```
1 #!/usr/bin/env python
2 from __future__ import print_function, absolute_import
3 
4 import os
5 import requests
6 import subprocess
7 import sys
8 import argparse
9 
10 from conda_build.metadata import MetaData
11 
12 import conda_smithy.configure_circle_ci as configure_circle_ci
13 import conda_smithy.configure_feedstock as configure_feedstock
14 
15 
16 def generate_feedstock_content(target_directory, recipe_dir):
17     target_recipe_dir = os.path.join(target_directory, 'recipe')
18     if not os.path.exists(target_recipe_dir):
19         os.makedirs(target_recipe_dir)
20     configure_feedstock.copytree(recipe_dir, target_recipe_dir)
21 
22     forge_yml = os.path.join(target_directory, 'conda-forge.yml')
23     with open(forge_yml, 'w') as fh:
24         fh.write('[]')
25 
26     configure_feedstock.main(target_directory)
27 
28 
29 def init_git_repo(target):
30     subprocess.check_call(['git', 'init'], cwd=target)
31 
32 
33 def create_git_repo(target, meta):
34     init_git_repo(target)
35     subprocess.check_call(['git', 'add', '*'], cwd=target)
36     msg = 'Initial commit of the {} feedstock.'.format(meta.name())
37     subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)
38 
39 
40 class Subcommand(object):
41     #: The name of the subcommand
42     subcommand = None
43     def __init__(self, parser):
44         subcommand_parser = parser.add_parser(self.subcommand)
45         subcommand_parser.set_defaults(subcommand_func=self)
46         return subcommand_parser
47 
48     def __call__(self, args):
49         pass
50 
51 
52 class Init(Subcommand):
53     subcommand = 'init'
54     def __init__(self, parser):
55         # conda-smithy init /path/to/udunits-recipe ./
56         subcommand_parser = Subcommand.__init__(self, parser)
57         subcommand_parser.add_argument("recipe_directory")
58         subcommand_parser.add_argument("--feedstock-directory",
59                                        default='./{package.name}-feedstock')
60         subcommand_parser.add_argument("--no-git-repo", action='store_true',
61                                        default=False)
62 
63     def __call__(self, args):
64         meta = MetaData(args.recipe_directory)
65         feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))
66         generate_feedstock_content(feedstock_directory, args.recipe_directory)
67         if not args.no_git_repo:
68             create_git_repo(feedstock_directory, meta)
69 
70 
71 class GithubCreate(Subcommand):
72     subcommand = 'github-create'
73     def __init__(self, parser):
74         #  conda-smithy github-create ./ --organization=conda-forge
75         subcommand_parser = Subcommand.__init__(self, parser)
76         subcommand_parser.add_argument("feedstock_directory")
77         group = subcommand_parser.add_mutually_exclusive_group()
78         group.add_argument("--user")
79         group.add_argument("--organization", default="conda-forge")
80 
81     def __call__(self, args):
82         try:
83             with open(os.path.expanduser('~/.conda-smithy/github.token'), 'r') as fh:
84                 token = fh.read().strip()
85         except IOError:
86             print('No github token. Put one in ~/.conda-smithy/github.token')
87         meta = configure_feedstock.meta_of_feedstock(args.feedstock_directory)
88 
89         from github import Github
90         gh = Github(token)
91         if args.user is not None:
92             pass
93             # User has been defined, and organization has not.
94             user_or_org.get_user(args.user)
95         else:
96             # Use the organization provided.
97             user_or_org = gh.get_organization(args.organization)
98         repo = user_or_org.create_repo(os.path.basename(os.path.abspath(args.feedstock_directory)),
99                                        has_wiki=False,
100                                        description='A conda-smithy repository for {}.'.format(meta.name()))
101         print('Created {} on github'.format(repo.full_name))
102 
103 
104 class RegisterFeedstockCI(Subcommand):
105     subcommand = 'register-feedstock-ci'
106     def __init__(self, parser):
107         # conda-smithy register-feedstock-ci ./
108         subcommand_parser = Subcommand.__init__(self, parser)
109         subcommand_parser.add_argument("feedstock_directory")
110         group = subcommand_parser.add_mutually_exclusive_group()
111         group.add_argument("--user")
112         group.add_argument("--organization", default="conda-forge")
113 
114     def add_project_to_appveyor(self, user, project):
115         headers = {'Authorization': 'Bearer {}'.format(appveyor_token),
116                    'Content-Type': 'application/json'}
117         url = 'https://ci.appveyor.com/api/projects'
118 
119         data = {'repositoryProvider': 'gitHub', 'repositoryName': '{}/{}'.format(user, project)}
120 
121         response = requests.post(url, headers=headers, data=data)
122         response = requests.get(url, headers=headers)
123         if response.status_code != 201:
124             response.raise_for_status()
125 
126     def __call__(self, args):
127         owner = args.user or args.organization
128         repo = os.path.basename(os.path.abspath(args.feedstock_directory))
129 
130         print('CI Summary for {}/{} (may take some time):'.format(owner, repo))
131         configure_circle_ci.add_project_to_circle(owner, repo)
132         configure_circle_ci.add_project_to_appveyor(owner, repo)
133         configure_circle_ci.add_project_to_travis(owner, repo)
134 
135 
136 def main():
137 #     UX:
138 #         conda-smithy init /path/to/udunits-recipe ./
139 #         conda-smithy github-create ./ --organization=conda-forge --remote-name=upstream
140 #         conda-smithy register-feedstock-ci ./
141 
142 #      How about:
143 #         conda smithy config
144 #         conda smithy create-forge ./recipe
145 
146 #        conda smithy clone-all
147 
148     parser = argparse.ArgumentParser("conda-smithy - conda recipe building, made powerful.")
149     subparser = parser.add_subparsers()
150     # TODO: Consider allowing plugins/extensions using entry_points.
151     # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html
152     for subcommand in Subcommand.__subclasses__():
153         subcommand(subparser)
154 
155     if not sys.argv[1:]:
156 #         args = parser.parse_args(['--help'])
157         args = parser.parse_args(['init', '../udunits-feedstock/recipe',
158                                   '--feedstock-directory=../{package.name}-delme-feedstock'])
159 #         args = parser.parse_args(['github-create', '../udunits-delme-feedstock'])
160 #         args = parser.parse_args(['register-feedstock-ci', '../udunits-delme-feedstock'])
161     else:
162         args = parser.parse_args()
163 
164     args.subcommand_func(args)
165 
166 
167 if __name__ == '__main__':
168     main()
169
```
--- 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/conda_smithy/conda_smithy.py b/conda_smithy/conda_smithy.py
--- a/conda_smithy/conda_smithy.py
+++ b/conda_smithy/conda_smithy.py
@@ -91,7 +91,7 @@
         if args.user is not None:
             pass
             # User has been defined, and organization has not.
-            user_or_org.get_user(args.user)
+            user_or_org = gh.get_user()
         else:
             # Use the organization provided.
             user_or_org = gh.get_organization(args.organization)

{"golden_diff": "diff --git a/conda_smithy/conda_smithy.py b/conda_smithy/conda_smithy.py\n--- a/conda_smithy/conda_smithy.py\n+++ b/conda_smithy/conda_smithy.py\n@@ -91,7 +91,7 @@\n         if args.user is not None:\n             pass\n             # User has been defined, and organization has not.\n-            user_or_org.get_user(args.user)\n+            user_or_org = gh.get_user()\n         else:\n             # Use the organization provided.\n             user_or_org = gh.get_organization(args.organization)\n", "issue": "Calling conda smithy github-create with --user raises exception\nWhen I invoke `oncda smithy` to create a github repo (after setting the token correctly) I get this:\n\n``` python\n$ conda smithy github-create --user mwcraig mrjob-feedstock/\nTraceback (most recent call last):\n  File \"/Users/mcraig/miniconda/bin/conda-smithy\", line 9, in <module>\n    load_entry_point('conda-smithy==0.1.0.dev0', 'console_scripts', 'conda-smithy')()\n  File \"/Users/mcraig/miniconda/lib/python2.7/site-packages/conda_smithy-0.1.0.dev0-py2.7.egg/conda_smithy/conda_smithy.py\", line 164, in main\n    args.subcommand_func(args)\n  File \"/Users/mcraig/miniconda/lib/python2.7/site-packages/conda_smithy-0.1.0.dev0-py2.7.egg/conda_smithy/conda_smithy.py\", line 94, in __call__\n    user_or_org.get_user(args.user)\nUnboundLocalError: local variable 'user_or_org' referenced before assignment\n```\n\n", "before_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function, absolute_import\n\nimport os\nimport requests\nimport subprocess\nimport sys\nimport argparse\n\nfrom conda_build.metadata import MetaData\n\nimport conda_smithy.configure_circle_ci as configure_circle_ci\nimport conda_smithy.configure_feedstock as configure_feedstock\n\n\ndef generate_feedstock_content(target_directory, recipe_dir):\n    target_recipe_dir = os.path.join(target_directory, 'recipe')\n    if not os.path.exists(target_recipe_dir):\n        os.makedirs(target_recipe_dir)\n    configure_feedstock.copytree(recipe_dir, target_recipe_dir)\n\n    forge_yml = os.path.join(target_directory, 'conda-forge.yml')\n    with open(forge_yml, 'w') as fh:\n        fh.write('[]')\n\n    configure_feedstock.main(target_directory)\n\n\ndef init_git_repo(target):\n    subprocess.check_call(['git', 'init'], cwd=target)\n\n\ndef create_git_repo(target, meta):\n    init_git_repo(target)\n    subprocess.check_call(['git', 'add', '*'], cwd=target)\n    msg = 'Initial commit of the {} feedstock.'.format(meta.name())\n    subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)\n\n\nclass Subcommand(object):\n    #: The name of the subcommand\n    subcommand = None\n    def __init__(self, parser):\n        subcommand_parser = parser.add_parser(self.subcommand)\n        subcommand_parser.set_defaults(subcommand_func=self)\n        return subcommand_parser\n\n    def __call__(self, args):\n        pass\n\n\nclass Init(Subcommand):\n    subcommand = 'init'\n    def __init__(self, parser):\n        # conda-smithy init /path/to/udunits-recipe ./\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"recipe_directory\")\n        subcommand_parser.add_argument(\"--feedstock-directory\",\n                                       default='./{package.name}-feedstock')\n        subcommand_parser.add_argument(\"--no-git-repo\", action='store_true',\n                                       default=False)\n\n    def __call__(self, args):\n        meta = MetaData(args.recipe_directory)\n        feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))\n        generate_feedstock_content(feedstock_directory, args.recipe_directory)\n        if not args.no_git_repo:\n            create_git_repo(feedstock_directory, meta)\n\n\nclass GithubCreate(Subcommand):\n    subcommand = 'github-create'\n    def __init__(self, parser):\n        #  conda-smithy github-create ./ --organization=conda-forge\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"feedstock_directory\")\n        group = subcommand_parser.add_mutually_exclusive_group()\n        group.add_argument(\"--user\")\n        group.add_argument(\"--organization\", default=\"conda-forge\")\n\n    def __call__(self, args):\n        try:\n            with open(os.path.expanduser('~/.conda-smithy/github.token'), 'r') as fh:\n                token = fh.read().strip()\n        except IOError:\n            print('No github token. Put one in ~/.conda-smithy/github.token')\n        meta = configure_feedstock.meta_of_feedstock(args.feedstock_directory)\n\n        from github import Github\n        gh = Github(token)\n        if args.user is not None:\n            pass\n            # User has been defined, and organization has not.\n            user_or_org.get_user(args.user)\n        else:\n            # Use the organization provided.\n            user_or_org = gh.get_organization(args.organization)\n        repo = user_or_org.create_repo(os.path.basename(os.path.abspath(args.feedstock_directory)),\n                                       has_wiki=False,\n                                       description='A conda-smithy repository for {}.'.format(meta.name()))\n        print('Created {} on github'.format(repo.full_name))\n\n\nclass RegisterFeedstockCI(Subcommand):\n    subcommand = 'register-feedstock-ci'\n    def __init__(self, parser):\n        # conda-smithy register-feedstock-ci ./\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"feedstock_directory\")\n        group = subcommand_parser.add_mutually_exclusive_group()\n        group.add_argument(\"--user\")\n        group.add_argument(\"--organization\", default=\"conda-forge\")\n\n    def add_project_to_appveyor(self, user, project):\n        headers = {'Authorization': 'Bearer {}'.format(appveyor_token),\n                   'Content-Type': 'application/json'}\n        url = 'https://ci.appveyor.com/api/projects'\n\n        data = {'repositoryProvider': 'gitHub', 'repositoryName': '{}/{}'.format(user, project)}\n\n        response = requests.post(url, headers=headers, data=data)\n        response = requests.get(url, headers=headers)\n        if response.status_code != 201:\n            response.raise_for_status()\n\n    def __call__(self, args):\n        owner = args.user or args.organization\n        repo = os.path.basename(os.path.abspath(args.feedstock_directory))\n\n        print('CI Summary for {}/{} (may take some time):'.format(owner, repo))\n        configure_circle_ci.add_project_to_circle(owner, repo)\n        configure_circle_ci.add_project_to_appveyor(owner, repo)\n        configure_circle_ci.add_project_to_travis(owner, repo)\n\n\ndef main():\n#     UX:\n#         conda-smithy init /path/to/udunits-recipe ./\n#         conda-smithy github-create ./ --organization=conda-forge --remote-name=upstream\n#         conda-smithy register-feedstock-ci ./\n\n#      How about:\n#         conda smithy config\n#         conda smithy create-forge ./recipe\n\n#        conda smithy clone-all\n\n    parser = argparse.ArgumentParser(\"conda-smithy - conda recipe building, made powerful.\")\n    subparser = parser.add_subparsers()\n    # TODO: Consider allowing plugins/extensions using entry_points.\n    # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html\n    for subcommand in Subcommand.__subclasses__():\n        subcommand(subparser)\n\n    if not sys.argv[1:]:\n#         args = parser.parse_args(['--help'])\n        args = parser.parse_args(['init', '../udunits-feedstock/recipe',\n                                  '--feedstock-directory=../{package.name}-delme-feedstock'])\n#         args = parser.parse_args(['github-create', '../udunits-delme-feedstock'])\n#         args = parser.parse_args(['register-feedstock-ci', '../udunits-delme-feedstock'])\n    else:\n        args = parser.parse_args()\n\n    args.subcommand_func(args)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "conda_smithy/conda_smithy.py"}], "after_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import print_function, absolute_import\n\nimport os\nimport requests\nimport subprocess\nimport sys\nimport argparse\n\nfrom conda_build.metadata import MetaData\n\nimport conda_smithy.configure_circle_ci as configure_circle_ci\nimport conda_smithy.configure_feedstock as configure_feedstock\n\n\ndef generate_feedstock_content(target_directory, recipe_dir):\n    target_recipe_dir = os.path.join(target_directory, 'recipe')\n    if not os.path.exists(target_recipe_dir):\n        os.makedirs(target_recipe_dir)\n    configure_feedstock.copytree(recipe_dir, target_recipe_dir)\n\n    forge_yml = os.path.join(target_directory, 'conda-forge.yml')\n    with open(forge_yml, 'w') as fh:\n        fh.write('[]')\n\n    configure_feedstock.main(target_directory)\n\n\ndef init_git_repo(target):\n    subprocess.check_call(['git', 'init'], cwd=target)\n\n\ndef create_git_repo(target, meta):\n    init_git_repo(target)\n    subprocess.check_call(['git', 'add', '*'], cwd=target)\n    msg = 'Initial commit of the {} feedstock.'.format(meta.name())\n    subprocess.check_call(['git', 'commit', '-m', msg], cwd=target)\n\n\nclass Subcommand(object):\n    #: The name of the subcommand\n    subcommand = None\n    def __init__(self, parser):\n        subcommand_parser = parser.add_parser(self.subcommand)\n        subcommand_parser.set_defaults(subcommand_func=self)\n        return subcommand_parser\n\n    def __call__(self, args):\n        pass\n\n\nclass Init(Subcommand):\n    subcommand = 'init'\n    def __init__(self, parser):\n        # conda-smithy init /path/to/udunits-recipe ./\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"recipe_directory\")\n        subcommand_parser.add_argument(\"--feedstock-directory\",\n                                       default='./{package.name}-feedstock')\n        subcommand_parser.add_argument(\"--no-git-repo\", action='store_true',\n                                       default=False)\n\n    def __call__(self, args):\n        meta = MetaData(args.recipe_directory)\n        feedstock_directory = args.feedstock_directory.format(package=argparse.Namespace(name=meta.name()))\n        generate_feedstock_content(feedstock_directory, args.recipe_directory)\n        if not args.no_git_repo:\n            create_git_repo(feedstock_directory, meta)\n\n\nclass GithubCreate(Subcommand):\n    subcommand = 'github-create'\n    def __init__(self, parser):\n        #  conda-smithy github-create ./ --organization=conda-forge\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"feedstock_directory\")\n        group = subcommand_parser.add_mutually_exclusive_group()\n        group.add_argument(\"--user\")\n        group.add_argument(\"--organization\", default=\"conda-forge\")\n\n    def __call__(self, args):\n        try:\n            with open(os.path.expanduser('~/.conda-smithy/github.token'), 'r') as fh:\n                token = fh.read().strip()\n        except IOError:\n            print('No github token. Put one in ~/.conda-smithy/github.token')\n        meta = configure_feedstock.meta_of_feedstock(args.feedstock_directory)\n\n        from github import Github\n        gh = Github(token)\n        if args.user is not None:\n            pass\n            # User has been defined, and organization has not.\n            user_or_org = gh.get_user()\n        else:\n            # Use the organization provided.\n            user_or_org = gh.get_organization(args.organization)\n        repo = user_or_org.create_repo(os.path.basename(os.path.abspath(args.feedstock_directory)),\n                                       has_wiki=False,\n                                       description='A conda-smithy repository for {}.'.format(meta.name()))\n        print('Created {} on github'.format(repo.full_name))\n\n\nclass RegisterFeedstockCI(Subcommand):\n    subcommand = 'register-feedstock-ci'\n    def __init__(self, parser):\n        # conda-smithy register-feedstock-ci ./\n        subcommand_parser = Subcommand.__init__(self, parser)\n        subcommand_parser.add_argument(\"feedstock_directory\")\n        group = subcommand_parser.add_mutually_exclusive_group()\n        group.add_argument(\"--user\")\n        group.add_argument(\"--organization\", default=\"conda-forge\")\n\n    def add_project_to_appveyor(self, user, project):\n        headers = {'Authorization': 'Bearer {}'.format(appveyor_token),\n                   'Content-Type': 'application/json'}\n        url = 'https://ci.appveyor.com/api/projects'\n\n        data = {'repositoryProvider': 'gitHub', 'repositoryName': '{}/{}'.format(user, project)}\n\n        response = requests.post(url, headers=headers, data=data)\n        response = requests.get(url, headers=headers)\n        if response.status_code != 201:\n            response.raise_for_status()\n\n    def __call__(self, args):\n        owner = args.user or args.organization\n        repo = os.path.basename(os.path.abspath(args.feedstock_directory))\n\n        print('CI Summary for {}/{} (may take some time):'.format(owner, repo))\n        configure_circle_ci.add_project_to_circle(owner, repo)\n        configure_circle_ci.add_project_to_appveyor(owner, repo)\n        configure_circle_ci.add_project_to_travis(owner, repo)\n\n\ndef main():\n#     UX:\n#         conda-smithy init /path/to/udunits-recipe ./\n#         conda-smithy github-create ./ --organization=conda-forge --remote-name=upstream\n#         conda-smithy register-feedstock-ci ./\n\n#      How about:\n#         conda smithy config\n#         conda smithy create-forge ./recipe\n\n#        conda smithy clone-all\n\n    parser = argparse.ArgumentParser(\"conda-smithy - conda recipe building, made powerful.\")\n    subparser = parser.add_subparsers()\n    # TODO: Consider allowing plugins/extensions using entry_points.\n    # http://reinout.vanrees.org/weblog/2010/01/06/zest-releaser-entry-points.html\n    for subcommand in Subcommand.__subclasses__():\n        subcommand(subparser)\n\n    if not sys.argv[1:]:\n#         args = parser.parse_args(['--help'])\n        args = parser.parse_args(['init', '../udunits-feedstock/recipe',\n                                  '--feedstock-directory=../{package.name}-delme-feedstock'])\n#         args = parser.parse_args(['github-create', '../udunits-delme-feedstock'])\n#         args = parser.parse_args(['register-feedstock-ci', '../udunits-delme-feedstock'])\n    else:\n        args = parser.parse_args()\n\n    args.subcommand_func(args)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "conda_smithy/conda_smithy.py"}]}