What is the best way to parse this YAML template in Python?

Viewed 20

We're switching from an old app with a specific task that is no longer being maintained, and developing a custom solution.

Essentially, I need to iterate through these pairs of URLs and tokens. They're in sets of 2, meaning that each:

  - url: http://192.168.0.8:PORT
  token: XXXXXXXXXXXXXXXXXXXX

pair is the authentication for one instance of a different application it needs to access.

The end goal is to loop through each pair, in a for loop, and run a specific command per pair.

I've tried getting this to give in with Confuse and also PyYAML and so far, its been smashing my head in.

Full Template:

targets:
  application:
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
 
    - url: http://192.168.0.8:PORT
      token: XXXXXXXXXXXXXXXXXXXX
0 Answers
Related