prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Reading/writing EMR key_pair_file configuration options behaves oddly
  Version:
  
  ```
  $ aws --version
  aws-cli/1.11.75 Python/2.7.10 Darwin/15.6.0 botocore/1.5.38
  ```
  
  [It's suggested that one can set a default key_pair_file argument here](https://github.com/aws/aws-cli/blob/master/awscli/customizations/emr/ssh.py#L25) by running `aws configure set emr.key_pair_file <value>`
  
  By that token, I would expect `aws configure get emr.key_pair_file` to retrieve this item and to exit with a exit code of 0.
  
  ```
  $ aws configure set emr.key_pair_file /tmp/foo
  
  $ cat config
  [default]
  emr =
      key_pair_file = /tmp/foo
  
  $ aws configure get emr.key_pair_file
  
  $ echo $?
  1
  ```
  
  As you can see, setting this and trying to retrieve it exits with a non-zero exit code which makes it a pain to check for this config item being set as part of shell scripts prior to do other EMR-based commands (such as create-cluster).
  
  As an aside, trying to get the top level `emr` config item fails too;
  
  ```
  $ aws configure get emr
  
  expected a character buffer object
  ```
  
  Additionally this item doesn't show up when `aws configure list` is run either;
  
  ```
  $ aws configure list
        Name                    Value             Type    Location
        ----                    -----             ----    --------
     profile                <not set>             None    None
  access_key     REDACTED                    shared-credentials-file
  secret_key      REDACTED                    shared-credentials-file
      region                <not set>             None    None
  
  ```
  
  
  </issue>
  <code>
  [start of awscli/customizations/configure/get.py]
  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 sys
  14 
  15 from awscli.customizations.commands import BasicCommand
  16 
  17 from . import PREDEFINED_SECTION_NAMES
  18 
  19 
  20 class ConfigureGetCommand(BasicCommand):
  21     NAME = 'get'
  22     DESCRIPTION = BasicCommand.FROM_FILE('configure', 'get',
  23                                          '_description.rst')
  24     SYNOPSIS = ('aws configure get varname [--profile profile-name]')
  25     EXAMPLES = BasicCommand.FROM_FILE('configure', 'get', '_examples.rst')
  26     ARG_TABLE = [
  27         {'name': 'varname',
  28          'help_text': 'The name of the config value to retrieve.',
  29          'action': 'store',
  30          'cli_type_name': 'string', 'positional_arg': True},
  31     ]
  32 
  33     def __init__(self, session, stream=sys.stdout):
  34         super(ConfigureGetCommand, self).__init__(session)
  35         self._stream = stream
  36 
  37     def _run_main(self, args, parsed_globals):
  38         varname = args.varname
  39         value = None
  40         if '.' not in varname:
  41             # get_scoped_config() returns the config variables in the config
  42             # file (not the logical_var names), which is what we want.
  43             config = self._session.get_scoped_config()
  44             value = config.get(varname)
  45         else:
  46             value = self._get_dotted_config_value(varname)
  47         if value is not None:
  48             self._stream.write(value)
  49             self._stream.write('\n')
  50             return 0
  51         else:
  52             return 1
  53 
  54     def _get_dotted_config_value(self, varname):
  55         parts = varname.split('.')
  56         num_dots = varname.count('.')
  57         # Logic to deal with predefined sections like [preview], [plugin] and etc.
  58         if num_dots == 1 and parts[0] in PREDEFINED_SECTION_NAMES:
  59             full_config = self._session.full_config
  60             section, config_name = varname.split('.')
  61             value = full_config.get(section, {}).get(config_name)
  62             if value is None:
  63                 # Try to retrieve it from the profile config.
  64                 value = full_config['profiles'].get(
  65                     section, {}).get(config_name)
  66             return value
  67         if parts[0] == 'profile':
  68             profile_name = parts[1]
  69             config_name = parts[2]
  70             remaining = parts[3:]
  71         # Check if varname starts with 'default' profile (e.g. default.emr-dev.emr.instance_profile)
  72         # If not, go further to check if varname starts with a known profile name
  73         elif parts[0] == 'default' or (parts[0] in self._session.full_config['profiles']):
  74             profile_name = parts[0]
  75             config_name = parts[1]
  76             remaining = parts[2:]
  77         else:
  78             profile_name = self._session.get_config_variable('profile')
  79             config_name = parts[0]
  80             remaining = parts[1:]
  81 
  82         value = self._session.full_config['profiles'].get(
  83             profile_name, {}).get(config_name)
  84         if len(remaining) == 1:
  85             try:
  86                 value = value.get(remaining[-1])
  87             except AttributeError:
  88                 value = None
  89         return value
  90
  [end of awscli/customizations/configure/get.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/awscli/customizations/configure/get.py b/awscli/customizations/configure/get.py
  --- a/awscli/customizations/configure/get.py
  +++ b/awscli/customizations/configure/get.py
  @@ -11,17 +11,21 @@
   # ANY KIND, either express or implied. See the License for the specific
   # language governing permissions and limitations under the License.
   import sys
  +import logging
   
   from awscli.customizations.commands import BasicCommand
  +from awscli.compat import six
   
   from . import PREDEFINED_SECTION_NAMES
   
  +LOG = logging.getLogger(__name__)
  +
   
   class ConfigureGetCommand(BasicCommand):
       NAME = 'get'
       DESCRIPTION = BasicCommand.FROM_FILE('configure', 'get',
                                            '_description.rst')
  -    SYNOPSIS = ('aws configure get varname [--profile profile-name]')
  +    SYNOPSIS = 'aws configure get varname [--profile profile-name]'
       EXAMPLES = BasicCommand.FROM_FILE('configure', 'get', '_examples.rst')
       ARG_TABLE = [
           {'name': 'varname',
  @@ -30,13 +34,14 @@
            'cli_type_name': 'string', 'positional_arg': True},
       ]
   
  -    def __init__(self, session, stream=sys.stdout):
  +    def __init__(self, session, stream=sys.stdout, error_stream=sys.stderr):
           super(ConfigureGetCommand, self).__init__(session)
           self._stream = stream
  +        self._error_stream = error_stream
   
       def _run_main(self, args, parsed_globals):
           varname = args.varname
  -        value = None
  +
           if '.' not in varname:
               # get_scoped_config() returns the config variables in the config
               # file (not the logical_var names), which is what we want.
  @@ -44,17 +49,30 @@
               value = config.get(varname)
           else:
               value = self._get_dotted_config_value(varname)
  -        if value is not None:
  +
  +        LOG.debug(u'Config value retrieved: %s' % value)
  +
  +        if isinstance(value, six.string_types):
               self._stream.write(value)
               self._stream.write('\n')
               return 0
  +        elif isinstance(value, dict):
  +            # TODO: add support for this. We would need to print it off in
  +            # the same format as the config file.
  +            self._error_stream.write(
  +                'varname (%s) must reference a value, not a section or '
  +                'sub-section.' % varname
  +            )
  +            return 1
           else:
               return 1
   
       def _get_dotted_config_value(self, varname):
           parts = varname.split('.')
           num_dots = varname.count('.')
  -        # Logic to deal with predefined sections like [preview], [plugin] and etc.
  +
  +        # Logic to deal with predefined sections like [preview], [plugin] and
  +        # etc.
           if num_dots == 1 and parts[0] in PREDEFINED_SECTION_NAMES:
               full_config = self._session.full_config
               section, config_name = varname.split('.')
  @@ -64,18 +82,23 @@
                   value = full_config['profiles'].get(
                       section, {}).get(config_name)
               return value
  +
           if parts[0] == 'profile':
               profile_name = parts[1]
               config_name = parts[2]
               remaining = parts[3:]
  -        # Check if varname starts with 'default' profile (e.g. default.emr-dev.emr.instance_profile)
  -        # If not, go further to check if varname starts with a known profile name
  -        elif parts[0] == 'default' or (parts[0] in self._session.full_config['profiles']):
  +        # Check if varname starts with 'default' profile (e.g.
  +        # default.emr-dev.emr.instance_profile) If not, go further to check
  +        # if varname starts with a known profile name
  +        elif parts[0] == 'default' or (
  +                parts[0] in self._session.full_config['profiles']):
               profile_name = parts[0]
               config_name = parts[1]
               remaining = parts[2:]
           else:
               profile_name = self._session.get_config_variable('profile')
  +            if profile_name is None:
  +                profile_name = 'default'
               config_name = parts[0]
               remaining = parts[1:]
  
verification_info: {"golden_diff": "diff --git a/awscli/customizations/configure/get.py b/awscli/customizations/configure/get.py\n--- a/awscli/customizations/configure/get.py\n+++ b/awscli/customizations/configure/get.py\n@@ -11,17 +11,21 @@\n # ANY KIND, either express or implied. See the License for the specific\n # language governing permissions and limitations under the License.\n import sys\n+import logging\n \n from awscli.customizations.commands import BasicCommand\n+from awscli.compat import six\n \n from . import PREDEFINED_SECTION_NAMES\n \n+LOG = logging.getLogger(__name__)\n+\n \n class ConfigureGetCommand(BasicCommand):\n     NAME = 'get'\n     DESCRIPTION = BasicCommand.FROM_FILE('configure', 'get',\n                                          '_description.rst')\n-    SYNOPSIS = ('aws configure get varname [--profile profile-name]')\n+    SYNOPSIS = 'aws configure get varname [--profile profile-name]'\n     EXAMPLES = BasicCommand.FROM_FILE('configure', 'get', '_examples.rst')\n     ARG_TABLE = [\n         {'name': 'varname',\n@@ -30,13 +34,14 @@\n          'cli_type_name': 'string', 'positional_arg': True},\n     ]\n \n-    def __init__(self, session, stream=sys.stdout):\n+    def __init__(self, session, stream=sys.stdout, error_stream=sys.stderr):\n         super(ConfigureGetCommand, self).__init__(session)\n         self._stream = stream\n+        self._error_stream = error_stream\n \n     def _run_main(self, args, parsed_globals):\n         varname = args.varname\n-        value = None\n+\n         if '.' not in varname:\n             # get_scoped_config() returns the config variables in the config\n             # file (not the logical_var names), which is what we want.\n@@ -44,17 +49,30 @@\n             value = config.get(varname)\n         else:\n             value = self._get_dotted_config_value(varname)\n-        if value is not None:\n+\n+        LOG.debug(u'Config value retrieved: %s' % value)\n+\n+        if isinstance(value, six.string_types):\n             self._stream.write(value)\n             self._stream.write('\\n')\n             return 0\n+        elif isinstance(value, dict):\n+            # TODO: add support for this. We would need to print it off in\n+            # the same format as the config file.\n+            self._error_stream.write(\n+                'varname (%s) must reference a value, not a section or '\n+                'sub-section.' % varname\n+            )\n+            return 1\n         else:\n             return 1\n \n     def _get_dotted_config_value(self, varname):\n         parts = varname.split('.')\n         num_dots = varname.count('.')\n-        # Logic to deal with predefined sections like [preview], [plugin] and etc.\n+\n+        # Logic to deal with predefined sections like [preview], [plugin] and\n+        # etc.\n         if num_dots == 1 and parts[0] in PREDEFINED_SECTION_NAMES:\n             full_config = self._session.full_config\n             section, config_name = varname.split('.')\n@@ -64,18 +82,23 @@\n                 value = full_config['profiles'].get(\n                     section, {}).get(config_name)\n             return value\n+\n         if parts[0] == 'profile':\n             profile_name = parts[1]\n             config_name = parts[2]\n             remaining = parts[3:]\n-        # Check if varname starts with 'default' profile (e.g. default.emr-dev.emr.instance_profile)\n-        # If not, go further to check if varname starts with a known profile name\n-        elif parts[0] == 'default' or (parts[0] in self._session.full_config['profiles']):\n+        # Check if varname starts with 'default' profile (e.g.\n+        # default.emr-dev.emr.instance_profile) If not, go further to check\n+        # if varname starts with a known profile name\n+        elif parts[0] == 'default' or (\n+                parts[0] in self._session.full_config['profiles']):\n             profile_name = parts[0]\n             config_name = parts[1]\n             remaining = parts[2:]\n         else:\n             profile_name = self._session.get_config_variable('profile')\n+            if profile_name is None:\n+                profile_name = 'default'\n             config_name = parts[0]\n             remaining = parts[1:]\n", "issue": "Reading/writing EMR key_pair_file configuration options behaves oddly\nVersion:\r\n\r\n```\r\n$ aws --version\r\naws-cli/1.11.75 Python/2.7.10 Darwin/15.6.0 botocore/1.5.38\r\n```\r\n\r\n[It's suggested that one can set a default key_pair_file argument here](https://github.com/aws/aws-cli/blob/master/awscli/customizations/emr/ssh.py#L25) by running `aws configure set emr.key_pair_file <value>`\r\n\r\nBy that token, I would expect `aws configure get emr.key_pair_file` to retrieve this item and to exit with a exit code of 0.\r\n\r\n```\r\n$ aws configure set emr.key_pair_file /tmp/foo\r\n\r\n$ cat config\r\n[default]\r\nemr =\r\n    key_pair_file = /tmp/foo\r\n\r\n$ aws configure get emr.key_pair_file\r\n\r\n$ echo $?\r\n1\r\n```\r\n\r\nAs you can see, setting this and trying to retrieve it exits with a non-zero exit code which makes it a pain to check for this config item being set as part of shell scripts prior to do other EMR-based commands (such as create-cluster).\r\n\r\nAs an aside, trying to get the top level `emr` config item fails too;\r\n\r\n```\r\n$ aws configure get emr\r\n\r\nexpected a character buffer object\r\n```\r\n\r\nAdditionally this item doesn't show up when `aws configure list` is run either;\r\n\r\n```\r\n$ aws configure list\r\n      Name                    Value             Type    Location\r\n      ----                    -----             ----    --------\r\n   profile                <not set>             None    None\r\naccess_key     REDACTED                    shared-credentials-file\r\nsecret_key      REDACTED                    shared-credentials-file\r\n    region                <not set>             None    None\r\n\r\n```\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 sys\n\nfrom awscli.customizations.commands import BasicCommand\n\nfrom . import PREDEFINED_SECTION_NAMES\n\n\nclass ConfigureGetCommand(BasicCommand):\n    NAME = 'get'\n    DESCRIPTION = BasicCommand.FROM_FILE('configure', 'get',\n                                         '_description.rst')\n    SYNOPSIS = ('aws configure get varname [--profile profile-name]')\n    EXAMPLES = BasicCommand.FROM_FILE('configure', 'get', '_examples.rst')\n    ARG_TABLE = [\n        {'name': 'varname',\n         'help_text': 'The name of the config value to retrieve.',\n         'action': 'store',\n         'cli_type_name': 'string', 'positional_arg': True},\n    ]\n\n    def __init__(self, session, stream=sys.stdout):\n        super(ConfigureGetCommand, self).__init__(session)\n        self._stream = stream\n\n    def _run_main(self, args, parsed_globals):\n        varname = args.varname\n        value = None\n        if '.' not in varname:\n            # get_scoped_config() returns the config variables in the config\n            # file (not the logical_var names), which is what we want.\n            config = self._session.get_scoped_config()\n            value = config.get(varname)\n        else:\n            value = self._get_dotted_config_value(varname)\n        if value is not None:\n            self._stream.write(value)\n            self._stream.write('\\n')\n            return 0\n        else:\n            return 1\n\n    def _get_dotted_config_value(self, varname):\n        parts = varname.split('.')\n        num_dots = varname.count('.')\n        # Logic to deal with predefined sections like [preview], [plugin] and etc.\n        if num_dots == 1 and parts[0] in PREDEFINED_SECTION_NAMES:\n            full_config = self._session.full_config\n            section, config_name = varname.split('.')\n            value = full_config.get(section, {}).get(config_name)\n            if value is None:\n                # Try to retrieve it from the profile config.\n                value = full_config['profiles'].get(\n                    section, {}).get(config_name)\n            return value\n        if parts[0] == 'profile':\n            profile_name = parts[1]\n            config_name = parts[2]\n            remaining = parts[3:]\n        # Check if varname starts with 'default' profile (e.g. default.emr-dev.emr.instance_profile)\n        # If not, go further to check if varname starts with a known profile name\n        elif parts[0] == 'default' or (parts[0] in self._session.full_config['profiles']):\n            profile_name = parts[0]\n            config_name = parts[1]\n            remaining = parts[2:]\n        else:\n            profile_name = self._session.get_config_variable('profile')\n            config_name = parts[0]\n            remaining = parts[1:]\n\n        value = self._session.full_config['profiles'].get(\n            profile_name, {}).get(config_name)\n        if len(remaining) == 1:\n            try:\n                value = value.get(remaining[-1])\n            except AttributeError:\n                value = None\n        return value\n", "path": "awscli/customizations/configure/get.py"}]}