Last active
September 25, 2015 20:43
-
-
Save zsoldosp/da7132ecadfd880aa2c2 to your computer and use it in GitHub Desktop.
avoiding duplication in yaml files. Heard about from @beerops https://twitter.com/beerops/status/647499854499987456 then googled and found https://gist.github.com/bowsersenior/979804
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: &DEFAULT | |
URL: stooges.com | |
throw_pies?: true | |
stooges: &stooge_list | |
larry: first_stooge | |
moe: second_stooge | |
curly: third_stooge | |
development: | |
<<: *DEFAULT | |
URL: stooges.local | |
stooges: | |
shemp: fourth_stooge | |
test: | |
<<: *DEFAULT | |
URL: test.stooges.qa | |
stooges: | |
<<: *stooge_list | |
shemp: fourth_stooge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pprint | |
import yaml # https://pypi.python.org/pypi/PyYAML | |
file_path = os.path.join(os.path.dirname(__file__), 'data.yml') | |
with open(file_path, 'r') as f: | |
yaml_data = f.read() | |
parsed_data = yaml.load(yaml_data) | |
pprint.pprint(parsed_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment