aws-cloudformation-templates icon indicating copy to clipboard operation
aws-cloudformation-templates copied to clipboard

Upper function is not there

Open bogdanpopey opened this issue 6 years ago • 1 comments

I believe the code is missing functions of upper, title and swapcase python functions. Please have a look and correct this.

Regards, bogdan

bogdanpopey avatar Apr 30 '19 08:04 bogdanpopey

These functions are covered by this piece of code:

no_param_string_funcs = ["Upper", "Lower", "Capitalize", "Title", "SwapCase"]
if operation in no_param_string_funcs:
    response["fragment"] = getattr(input, operation.lower())()

This takes the function name, makes it lower case, then uses the built-in Python method to run the method of the same name.

Let's step through it with "Upper":

if operation in no_param_string_funcs:

is "Upper" in the list of functions? Yes

Then let's break this line down:

response["fragment"] = getattr(input, operation.lower())()
  • operation.lower(): change "Upper" to "upper"
response["fragment"] = getattr(input, "upper")()
response["fragment"] = input.upper()
  • Call upper() on input and set the response to that.

mitchellrj avatar May 02 '19 08:05 mitchellrj