prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  aws configure get and aws configure set with multiword profile names are inconsistent
  It seems that `aws configure set --profile "two words"` will add single quotes around the profile name, but `aws configure get --profile "two words"` will search for a profile name that does not have single quotes around the profile name.
  
  These two methods should behave in a similar manner.
  
  To reproduce:
  
  ```
  $ aws --version
  aws-cli/1.15.10 Python/3.6.5 Darwin/17.4.0 botocore/1.10.10
  $ aws configure set aws_access_key_id test --profile "test profile"
  $ aws configure get aws_access_key_id --profile "test profile"
  The config profile (test profile) could not be found
  $ aws configure get aws_access_key_id --profile "'test profile'"
  test
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `awscli/customizations/configure/set.py`
  Content:
  ```
  1 # Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License"). You
  4 # may not use this file except in compliance with the License. A copy of
  5 # the License is located at
  6 #
  7 #     http://aws.amazon.com/apache2.0/
  8 #
  9 # or in the "license" file accompanying this file. This file is
  10 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  11 # ANY KIND, either express or implied. See the License for the specific
  12 # language governing permissions and limitations under the License.
  13 import os
  14 
  15 from awscli.customizations.commands import BasicCommand
  16 from awscli.customizations.configure.writer import ConfigFileWriter
  17 
  18 from . import PREDEFINED_SECTION_NAMES, profile_to_section
  19 
  20 
  21 class ConfigureSetCommand(BasicCommand):
  22     NAME = 'set'
  23     DESCRIPTION = BasicCommand.FROM_FILE('configure', 'set',
  24                                          '_description.rst')
  25     SYNOPSIS = 'aws configure set varname value [--profile profile-name]'
  26     EXAMPLES = BasicCommand.FROM_FILE('configure', 'set', '_examples.rst')
  27     ARG_TABLE = [
  28         {'name': 'varname',
  29          'help_text': 'The name of the config value to set.',
  30          'action': 'store',
  31          'cli_type_name': 'string', 'positional_arg': True},
  32         {'name': 'value',
  33          'help_text': 'The value to set.',
  34          'action': 'store',
  35          'no_paramfile': True,  # To disable the default paramfile behavior
  36          'cli_type_name': 'string', 'positional_arg': True},
  37     ]
  38     # Any variables specified in this list will be written to
  39     # the ~/.aws/credentials file instead of ~/.aws/config.
  40     _WRITE_TO_CREDS_FILE = ['aws_access_key_id', 'aws_secret_access_key',
  41                             'aws_session_token']
  42 
  43     def __init__(self, session, config_writer=None):
  44         super(ConfigureSetCommand, self).__init__(session)
  45         if config_writer is None:
  46             config_writer = ConfigFileWriter()
  47         self._config_writer = config_writer
  48 
  49     def _run_main(self, args, parsed_globals):
  50         varname = args.varname
  51         value = args.value
  52         section = 'default'
  53         # Before handing things off to the config writer,
  54         # we need to find out three things:
  55         # 1. What section we're writing to (section).
  56         # 2. The name of the config key (varname)
  57         # 3. The actual value (value).
  58         if '.' not in varname:
  59             # unqualified name, scope it to the current
  60             # profile (or leave it as the 'default' section if
  61             # no profile is set).
  62             if self._session.profile is not None:
  63                 section = profile_to_section(self._session.profile)
  64         else:
  65             # First figure out if it's been scoped to a profile.
  66             parts = varname.split('.')
  67             if parts[0] in ('default', 'profile'):
  68                 # Then we know we're scoped to a profile.
  69                 if parts[0] == 'default':
  70                     section = 'default'
  71                     remaining = parts[1:]
  72                 else:
  73                     # [profile, profile_name, ...]
  74                     section = profile_to_section(parts[1])
  75                     remaining = parts[2:]
  76                 varname = remaining[0]
  77                 if len(remaining) == 2:
  78                     value = {remaining[1]: value}
  79             elif parts[0] not in PREDEFINED_SECTION_NAMES:
  80                 if self._session.profile is not None:
  81                     section = profile_to_section(self._session.profile)
  82                 else:
  83                     profile_name = self._session.get_config_variable('profile')
  84                     if profile_name is not None:
  85                         section = profile_name
  86                 varname = parts[0]
  87                 if len(parts) == 2:
  88                     value = {parts[1]: value}
  89             elif len(parts) == 2:
  90                 # Otherwise it's something like "set preview.service true"
  91                 # of something in the [plugin] section.
  92                 section, varname = parts
  93         config_filename = os.path.expanduser(
  94             self._session.get_config_variable('config_file'))
  95         updated_config = {'__section__': section, varname: value}
  96         if varname in self._WRITE_TO_CREDS_FILE:
  97             config_filename = os.path.expanduser(
  98                 self._session.get_config_variable('credentials_file'))
  99             section_name = updated_config['__section__']
  100             if section_name.startswith('profile '):
  101                 updated_config['__section__'] = section_name[8:]
  102         self._config_writer.update_config(updated_config, config_filename)
  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/awscli/customizations/configure/set.py b/awscli/customizations/configure/set.py
  --- a/awscli/customizations/configure/set.py
  +++ b/awscli/customizations/configure/set.py
  @@ -46,13 +46,17 @@
               config_writer = ConfigFileWriter()
           self._config_writer = config_writer
   
  +    def _get_config_file(self, path):
  +        config_path = self._session.get_config_variable(path)
  +        return os.path.expanduser(config_path)
  +
       def _run_main(self, args, parsed_globals):
           varname = args.varname
           value = args.value
  -        section = 'default'
  +        profile = 'default'
           # Before handing things off to the config writer,
           # we need to find out three things:
  -        # 1. What section we're writing to (section).
  +        # 1. What section we're writing to (profile).
           # 2. The name of the config key (varname)
           # 3. The actual value (value).
           if '.' not in varname:
  @@ -60,43 +64,44 @@
               # profile (or leave it as the 'default' section if
               # no profile is set).
               if self._session.profile is not None:
  -                section = profile_to_section(self._session.profile)
  +                profile = self._session.profile
           else:
               # First figure out if it's been scoped to a profile.
               parts = varname.split('.')
               if parts[0] in ('default', 'profile'):
                   # Then we know we're scoped to a profile.
                   if parts[0] == 'default':
  -                    section = 'default'
  +                    profile = 'default'
                       remaining = parts[1:]
                   else:
                       # [profile, profile_name, ...]
  -                    section = profile_to_section(parts[1])
  +                    profile = parts[1]
                       remaining = parts[2:]
                   varname = remaining[0]
                   if len(remaining) == 2:
                       value = {remaining[1]: value}
               elif parts[0] not in PREDEFINED_SECTION_NAMES:
                   if self._session.profile is not None:
  -                    section = profile_to_section(self._session.profile)
  +                    profile = self._session.profile
                   else:
                       profile_name = self._session.get_config_variable('profile')
                       if profile_name is not None:
  -                        section = profile_name
  +                        profile = profile_name
                   varname = parts[0]
                   if len(parts) == 2:
                       value = {parts[1]: value}
               elif len(parts) == 2:
                   # Otherwise it's something like "set preview.service true"
                   # of something in the [plugin] section.
  -                section, varname = parts
  -        config_filename = os.path.expanduser(
  -            self._session.get_config_variable('config_file'))
  -        updated_config = {'__section__': section, varname: value}
  +                profile, varname = parts
  +        config_filename = self._get_config_file('config_file')
           if varname in self._WRITE_TO_CREDS_FILE:
  -            config_filename = os.path.expanduser(
  -                self._session.get_config_variable('credentials_file'))
  -            section_name = updated_config['__section__']
  -            if section_name.startswith('profile '):
  -                updated_config['__section__'] = section_name[8:]
  +            # When writing to the creds file, the section is just the profile
  +            section = profile
  +            config_filename = self._get_config_file('credentials_file')
  +        elif profile in PREDEFINED_SECTION_NAMES or profile == 'default':
  +            section = profile
  +        else:
  +            section = profile_to_section(profile)
  +        updated_config = {'__section__': section, varname: value}
           self._config_writer.update_config(updated_config, config_filename)
  
verification_info: {"golden_diff": "diff --git a/awscli/customizations/configure/set.py b/awscli/customizations/configure/set.py\n--- a/awscli/customizations/configure/set.py\n+++ b/awscli/customizations/configure/set.py\n@@ -46,13 +46,17 @@\n             config_writer = ConfigFileWriter()\n         self._config_writer = config_writer\n \n+    def _get_config_file(self, path):\n+        config_path = self._session.get_config_variable(path)\n+        return os.path.expanduser(config_path)\n+\n     def _run_main(self, args, parsed_globals):\n         varname = args.varname\n         value = args.value\n-        section = 'default'\n+        profile = 'default'\n         # Before handing things off to the config writer,\n         # we need to find out three things:\n-        # 1. What section we're writing to (section).\n+        # 1. What section we're writing to (profile).\n         # 2. The name of the config key (varname)\n         # 3. The actual value (value).\n         if '.' not in varname:\n@@ -60,43 +64,44 @@\n             # profile (or leave it as the 'default' section if\n             # no profile is set).\n             if self._session.profile is not None:\n-                section = profile_to_section(self._session.profile)\n+                profile = self._session.profile\n         else:\n             # First figure out if it's been scoped to a profile.\n             parts = varname.split('.')\n             if parts[0] in ('default', 'profile'):\n                 # Then we know we're scoped to a profile.\n                 if parts[0] == 'default':\n-                    section = 'default'\n+                    profile = 'default'\n                     remaining = parts[1:]\n                 else:\n                     # [profile, profile_name, ...]\n-                    section = profile_to_section(parts[1])\n+                    profile = parts[1]\n                     remaining = parts[2:]\n                 varname = remaining[0]\n                 if len(remaining) == 2:\n                     value = {remaining[1]: value}\n             elif parts[0] not in PREDEFINED_SECTION_NAMES:\n                 if self._session.profile is not None:\n-                    section = profile_to_section(self._session.profile)\n+                    profile = self._session.profile\n                 else:\n                     profile_name = self._session.get_config_variable('profile')\n                     if profile_name is not None:\n-                        section = profile_name\n+                        profile = profile_name\n                 varname = parts[0]\n                 if len(parts) == 2:\n                     value = {parts[1]: value}\n             elif len(parts) == 2:\n                 # Otherwise it's something like \"set preview.service true\"\n                 # of something in the [plugin] section.\n-                section, varname = parts\n-        config_filename = os.path.expanduser(\n-            self._session.get_config_variable('config_file'))\n-        updated_config = {'__section__': section, varname: value}\n+                profile, varname = parts\n+        config_filename = self._get_config_file('config_file')\n         if varname in self._WRITE_TO_CREDS_FILE:\n-            config_filename = os.path.expanduser(\n-                self._session.get_config_variable('credentials_file'))\n-            section_name = updated_config['__section__']\n-            if section_name.startswith('profile '):\n-                updated_config['__section__'] = section_name[8:]\n+            # When writing to the creds file, the section is just the profile\n+            section = profile\n+            config_filename = self._get_config_file('credentials_file')\n+        elif profile in PREDEFINED_SECTION_NAMES or profile == 'default':\n+            section = profile\n+        else:\n+            section = profile_to_section(profile)\n+        updated_config = {'__section__': section, varname: value}\n         self._config_writer.update_config(updated_config, config_filename)\n", "issue": "aws configure get and aws configure set with multiword profile names are inconsistent\nIt seems that `aws configure set --profile \"two words\"` will add single quotes around the profile name, but `aws configure get --profile \"two words\"` will search for a profile name that does not have single quotes around the profile name.\r\n\r\nThese two methods should behave in a similar manner.\r\n\r\nTo reproduce:\r\n\r\n```\r\n$ aws --version\r\naws-cli/1.15.10 Python/3.6.5 Darwin/17.4.0 botocore/1.10.10\r\n$ aws configure set aws_access_key_id test --profile \"test profile\"\r\n$ aws configure get aws_access_key_id --profile \"test profile\"\r\nThe config profile (test profile) could not be found\r\n$ aws configure get aws_access_key_id --profile \"'test profile'\"\r\ntest\r\n```\n", "before_files": [{"content": "# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport os\n\nfrom awscli.customizations.commands import BasicCommand\nfrom awscli.customizations.configure.writer import ConfigFileWriter\n\nfrom . import PREDEFINED_SECTION_NAMES, profile_to_section\n\n\nclass ConfigureSetCommand(BasicCommand):\n    NAME = 'set'\n    DESCRIPTION = BasicCommand.FROM_FILE('configure', 'set',\n                                         '_description.rst')\n    SYNOPSIS = 'aws configure set varname value [--profile profile-name]'\n    EXAMPLES = BasicCommand.FROM_FILE('configure', 'set', '_examples.rst')\n    ARG_TABLE = [\n        {'name': 'varname',\n         'help_text': 'The name of the config value to set.',\n         'action': 'store',\n         'cli_type_name': 'string', 'positional_arg': True},\n        {'name': 'value',\n         'help_text': 'The value to set.',\n         'action': 'store',\n         'no_paramfile': True,  # To disable the default paramfile behavior\n         'cli_type_name': 'string', 'positional_arg': True},\n    ]\n    # Any variables specified in this list will be written to\n    # the ~/.aws/credentials file instead of ~/.aws/config.\n    _WRITE_TO_CREDS_FILE = ['aws_access_key_id', 'aws_secret_access_key',\n                            'aws_session_token']\n\n    def __init__(self, session, config_writer=None):\n        super(ConfigureSetCommand, self).__init__(session)\n        if config_writer is None:\n            config_writer = ConfigFileWriter()\n        self._config_writer = config_writer\n\n    def _run_main(self, args, parsed_globals):\n        varname = args.varname\n        value = args.value\n        section = 'default'\n        # Before handing things off to the config writer,\n        # we need to find out three things:\n        # 1. What section we're writing to (section).\n        # 2. The name of the config key (varname)\n        # 3. The actual value (value).\n        if '.' not in varname:\n            # unqualified name, scope it to the current\n            # profile (or leave it as the 'default' section if\n            # no profile is set).\n            if self._session.profile is not None:\n                section = profile_to_section(self._session.profile)\n        else:\n            # First figure out if it's been scoped to a profile.\n            parts = varname.split('.')\n            if parts[0] in ('default', 'profile'):\n                # Then we know we're scoped to a profile.\n                if parts[0] == 'default':\n                    section = 'default'\n                    remaining = parts[1:]\n                else:\n                    # [profile, profile_name, ...]\n                    section = profile_to_section(parts[1])\n                    remaining = parts[2:]\n                varname = remaining[0]\n                if len(remaining) == 2:\n                    value = {remaining[1]: value}\n            elif parts[0] not in PREDEFINED_SECTION_NAMES:\n                if self._session.profile is not None:\n                    section = profile_to_section(self._session.profile)\n                else:\n                    profile_name = self._session.get_config_variable('profile')\n                    if profile_name is not None:\n                        section = profile_name\n                varname = parts[0]\n                if len(parts) == 2:\n                    value = {parts[1]: value}\n            elif len(parts) == 2:\n                # Otherwise it's something like \"set preview.service true\"\n                # of something in the [plugin] section.\n                section, varname = parts\n        config_filename = os.path.expanduser(\n            self._session.get_config_variable('config_file'))\n        updated_config = {'__section__': section, varname: value}\n        if varname in self._WRITE_TO_CREDS_FILE:\n            config_filename = os.path.expanduser(\n                self._session.get_config_variable('credentials_file'))\n            section_name = updated_config['__section__']\n            if section_name.startswith('profile '):\n                updated_config['__section__'] = section_name[8:]\n        self._config_writer.update_config(updated_config, config_filename)\n", "path": "awscli/customizations/configure/set.py"}], "after_files": [{"content": "# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport os\n\nfrom awscli.customizations.commands import BasicCommand\nfrom awscli.customizations.configure.writer import ConfigFileWriter\n\nfrom . import PREDEFINED_SECTION_NAMES, profile_to_section\n\n\nclass ConfigureSetCommand(BasicCommand):\n    NAME = 'set'\n    DESCRIPTION = BasicCommand.FROM_FILE('configure', 'set',\n                                         '_description.rst')\n    SYNOPSIS = 'aws configure set varname value [--profile profile-name]'\n    EXAMPLES = BasicCommand.FROM_FILE('configure', 'set', '_examples.rst')\n    ARG_TABLE = [\n        {'name': 'varname',\n         'help_text': 'The name of the config value to set.',\n         'action': 'store',\n         'cli_type_name': 'string', 'positional_arg': True},\n        {'name': 'value',\n         'help_text': 'The value to set.',\n         'action': 'store',\n         'no_paramfile': True,  # To disable the default paramfile behavior\n         'cli_type_name': 'string', 'positional_arg': True},\n    ]\n    # Any variables specified in this list will be written to\n    # the ~/.aws/credentials file instead of ~/.aws/config.\n    _WRITE_TO_CREDS_FILE = ['aws_access_key_id', 'aws_secret_access_key',\n                            'aws_session_token']\n\n    def __init__(self, session, config_writer=None):\n        super(ConfigureSetCommand, self).__init__(session)\n        if config_writer is None:\n            config_writer = ConfigFileWriter()\n        self._config_writer = config_writer\n\n    def _get_config_file(self, path):\n        config_path = self._session.get_config_variable(path)\n        return os.path.expanduser(config_path)\n\n    def _run_main(self, args, parsed_globals):\n        varname = args.varname\n        value = args.value\n        profile = 'default'\n        # Before handing things off to the config writer,\n        # we need to find out three things:\n        # 1. What section we're writing to (profile).\n        # 2. The name of the config key (varname)\n        # 3. The actual value (value).\n        if '.' not in varname:\n            # unqualified name, scope it to the current\n            # profile (or leave it as the 'default' section if\n            # no profile is set).\n            if self._session.profile is not None:\n                profile = self._session.profile\n        else:\n            # First figure out if it's been scoped to a profile.\n            parts = varname.split('.')\n            if parts[0] in ('default', 'profile'):\n                # Then we know we're scoped to a profile.\n                if parts[0] == 'default':\n                    profile = 'default'\n                    remaining = parts[1:]\n                else:\n                    # [profile, profile_name, ...]\n                    profile = parts[1]\n                    remaining = parts[2:]\n                varname = remaining[0]\n                if len(remaining) == 2:\n                    value = {remaining[1]: value}\n            elif parts[0] not in PREDEFINED_SECTION_NAMES:\n                if self._session.profile is not None:\n                    profile = self._session.profile\n                else:\n                    profile_name = self._session.get_config_variable('profile')\n                    if profile_name is not None:\n                        profile = profile_name\n                varname = parts[0]\n                if len(parts) == 2:\n                    value = {parts[1]: value}\n            elif len(parts) == 2:\n                # Otherwise it's something like \"set preview.service true\"\n                # of something in the [plugin] section.\n                profile, varname = parts\n        config_filename = self._get_config_file('config_file')\n        if varname in self._WRITE_TO_CREDS_FILE:\n            # When writing to the creds file, the section is just the profile\n            section = profile\n            config_filename = self._get_config_file('credentials_file')\n        elif profile in PREDEFINED_SECTION_NAMES or profile == 'default':\n            section = profile\n        else:\n            section = profile_to_section(profile)\n        updated_config = {'__section__': section, varname: value}\n        self._config_writer.update_config(updated_config, config_filename)\n", "path": "awscli/customizations/configure/set.py"}]}