Skip to content

Conversation

@joguSD
Copy link
Contributor

@joguSD joguSD commented Aug 26, 2016

This pull requests adds a basic framework for coercing parameters into the correct type. Input taken from prompts will always be strings and for some basic types it is easy enough to cast them implicitly rather than having to define explicitly what type it is in the wizard specification or have a custom interaction.

@joguSD joguSD force-pushed the coerce-params branch 3 times, most recently from 10c2d4c to af191c2 Compare August 29, 2016 17:59
else:
from HTMLParser import HTMLParser
text_type = unicode
long_type = long

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would six help with some of these? Could help to notice that you have a text_type as well which six has. Furthermore, we really do not worry about longs in botocore so you can just get away with six.integer_types: https://github.com/boto/botocore/blob/develop/botocore/validate.py#L235-L237

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The six.integer_types is (int, long) in python 2 and just int in python 3. This makes it not possible to use the value as a constructor to coerce the parameter. That being said after doing some research it seems that calling int on a large enough number will end up returning a long anyways and this may not be needed.

Copy link
Contributor Author

@joguSD joguSD Aug 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it might be okay to map the types 'long' and 'int' to just use int in both python 2 and 3.
This is the behavior in python 2:

int('99999999999999999999') => 99999999999999999999L

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool

@kyleknap
Copy link

Approach looks fine. I just had a few questions. Parameter translation based off model traversal has a fair amount of edge cases and there is a bunch of places in botocore where we do it so I would make sure you take a look at those. The places we do it notably is: serializers, response parsers, and documentation.

@JordonPhillips
Copy link
Contributor

It really is a shame that we can't use the CLI, but this is a fairly well known problem as Kyle mentioned. Looks good for the most part, just a few small comments.

@JordonPhillips
Copy link
Contributor


                       _____|\
                  _.--| SSt |:
                 <____|.----||
                        .---''---,
                         ;..__..'    _...
                       ,'/  ;|/..--''    \
                     ,'_/.-/':            :
                _..-'''/  /  |  \    \   _|/|
               \      /-./_ \;   \    \,;'   \
               ,\    / \:  `:\    \   //    `:`.
             ,'  \  /-._;   | :    : ::    ,.   .
           ,'     ::   /`-._| |    | || ' :  `.`.)
        _,'       |;._:: |  | |    | `|   :    `'
      ,'   `.     /   |`-:_ ; |    |  |  : \
      `--.   )   /|-._:    :          |   \ \
         /  /   :_|   ;`-._;   __..--';    : :
        /  (    ;|;-./_  _/.-:'o |   /     ' |
       /  , \._/_/_./--''/_|:|___|_,'        |
      :  /   `'-'--'----'---------'          |
      | :     O ._O   O_. O ._O   O_.      ; ;
      : `.      //    //    //    //     ,' /
    ~~~`.______//____//____//____//_______,'~
              //    //~   //    //
       ~~   _//   _//   _// ~ _//     ~
     ~     / /   / /   / /   / /  ~      ~~
          ~~~   ~~~   ~~~   ~~~

@kyleknap
Copy link

Looks good. I am not sure about a better name than coerce but 🚢 if you can't think of a better name either.

@joguSD joguSD merged commit 5c85f99 into awslabs:wizard-feature Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants