Red Cricket Red Cricket - 9 months ago 121
YAML Question

ValueError: unsupported format character '{' (0x7b) at index

I have this block of python code ...

79 print "debug top is [" + top + "]"
80 print "debug package is [" + package + "]"
81 print "debug version is [" + version + "]"
82 print "debug password is [" + password + "]"
83 print "debug app_image_url is [" + app_image_url + "]"
84 print "debug apptitle is [" + apptitle + "]"
85 # get_filenames_from_zip_file (app_zip_url)
86 # sys.exit(0)
87 print """---
88 top: '%s'
89 package: '%s'
90 version: %s
91 password: '%s'
92 make_audiobook::package_name: "%%{hiera('package')}"
93 make_audiobook::version: "%%{hiera('version')}"
94 make_audiobook::mp3filesdir: "%%{hiera('top')}/%%{::appname}/%%{::appname}/res/raw"
95 make_audiobook::app_image::app_image_url: '%s'
96 make_audiobook::app_image::resource_path: "%%{hiera('top')}/%%{::appname}/%%{::appname}"
97 make_audiobook::app_image::appdir: "%{hiera('top')}/%{::appname}"
98 make_audiobook::app_image::appname: "%{::appname}"
99 make_audiobook::app_javacode::appname: "%%{::appname}"
100 make_audiobook::app_javacode::password: "%%{hiera('password')}"
101 make_audiobook::app_javacode::apptitle: "%s"
102 make_audiobook::app_javacode::package: "%%{hiera('package')}"
103 make_audiobook::app_javacode::path_to_code: "%%{hiera('top')}/%%{::appname}/%%{::appname}/src/com/%%{hiera('package')}/%%{::appname}"
104 make_audiobook::app_javacode::path_to_androidmanifest: "%%{hiera('top')}/%%{::appname}/%%{::appname}"
105 make_audiobook::app_javacode::version: "%%{hiera('version')}"
106 make_audiobook::app_javacode::tracks: """ % (top, package, version, password, app_image_url, apptitle)


When I run my script I get this error in the output:

debug top is [/home/get_links/TEMPLATE_FILES]
debug package is [redcricket]
debug version is [1]
debug password is [XXXXXX]
debug app_image_url is [https://ia801509.us.archive.org/7/items/song_of_the_wave_1703_librivox/songwave_1703.jpg]
debug apptitle is [Song of the Wave, and Other Poems]
Traceback (most recent call last):
File "./make_hiera_data_from_librivox_api.py", line 137, in <module>
main(sys.argv[1:])
File "./make_hiera_data_from_librivox_api.py", line 106, in main
make_audiobook::app_javacode::tracks: """ % (top, package, version, password, app_image_url, apptitle)
ValueError: unsupported format character '{' (0x7b) at index 415


I cannot see anything wrong in that block of code. Maybe a second pair eyes would be helpful?

Thanks!

Answer Source

All the instances of %{ need to be replaced with %%{

For instance this

 %{::appname}

should be

 %%{::appname}