Jun-30-2021, 04:32 PM
(This post was last modified: Jun-30-2021, 05:09 PM by JeffTech.
Edit Reason: Added code tags
)
Hi! New guy here! (I'm sure that your FAVORITE thing to read right off the top)
Anyway, I've been working on this script (my first in Python) and debugging it and I am down to my last error (I believe because of the position and error I am getting) and I know what the error means but I am unable to sus out what to do about it or what the actual cause is.
I had some indentation issues with my script when debugging, so it may stem from solving those. But basically, it is looking for some kind of "close" to the code that this is missing.
I'm sure this is stupid simple, but I am both. Thank you for looking in advance...
Anyway, I've been working on this script (my first in Python) and debugging it and I am down to my last error (I believe because of the position and error I am getting) and I know what the error means but I am unable to sus out what to do about it or what the actual cause is.
I had some indentation issues with my script when debugging, so it may stem from solving those. But basically, it is looking for some kind of "close" to the code that this is missing.
I'm sure this is stupid simple, but I am both. Thank you for looking in advance...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#Passing Vars import yaml # Get vpc data from yaml with open (r "somepath\file.yaml" , 'r' ) as file : testdata = yaml.safe_load( file ) vpcs = testdata[ 'vpcs' ] new_vpc_list = [] is_dmz = False tags = vpc[ 'Tags' ] for tag in tags: if tag[ 'Value' ] = = 'DMZ' : is_dmz = True if is_dmz: new_vpc_list.append(vpc) # Get template from yaml with open (r "someotherpath\otherfile.yml" ) as file : template = yaml.safe_load( file ) template_copy = template.copy() # Edit the template data template_copy[ 'Parameters' ][ 'EnvType' ][ 'VPC' ] = new_vpc_list[ 0 ][ 'VpcId' ] # Write the template data to a new file. with open (r "someotherpath\otherfile.yml" ) as file : file .write(yaml.dump(template_copy, file ) |