<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 About
ruamel.yaml is a YAML 1.2 loader/dumper package for Python. It is a derivative of Kirill Simonov’s PyYAML 3.11
ruamel.yaml supports YAML 1.2 and has round-trip loaders and dumpers that preserves, among others
Step2:  Examples
http
Step4:  Anchors and References
API Study
Based on the example (abridged version)
Step7:  Full example
Step9:  Inserting Keys and Comments
<ASSISTANT_TASK:>
Python Code:
import ruamel.yaml
ruamel.yaml
ruamel
dir(ruamel)
Explanation: About
ruamel.yaml is a YAML 1.2 loader/dumper package for Python. It is a derivative of Kirill Simonov’s PyYAML 3.11
ruamel.yaml supports YAML 1.2 and has round-trip loaders and dumpers that preserves, among others:
comments
block style and key ordering are kept, so you can diff the round-tripped source
flow style sequences ( ‘a: b, c, d’) (based on request and test by Anthony Sottile)
anchors names that are hand-crafted (i.e. not of the formidNNN)
merges in dictionaries are preserved
You can read more at http://yaml.readthedocs.io/en/latest/overview.html
Importing
End of explanation
inp = \
# example
name:
    # details
    family: Goda   # Very uncommon
    given: Satish  # One of the siblings (Comman name)
print(inp)
help(ruamel.yaml.load)
code = ruamel.yaml.load(inp, Loader=ruamel.yaml.RoundTripLoader)
code
code['name']['given']
code['name']['family']
Explanation: Examples
http://yaml.readthedocs.io/en/latest/example.html
End of explanation
import ruamel.yaml
inp = \
- &CENTER {x: 1, y: 2}
- &LEFT {x: 0, y: 2}
- &BIG {r: 10}
- &SMALL {r: 1}
code = ruamel.yaml.load(inp, Loader=ruamel.yaml.RoundTripLoader)
code
type(code)
dir(code)
code.anchor
code.anchor.value
code.keys()
for item in code:
    print(item)
for item in code:
    print(item.anchor.value, item.keys())
Explanation: Anchors and References
API Study
Based on the example (abridged version)
End of explanation
import ruamel.yaml
inp = \
- &CENTER {x: 1, y: 2}
- &LEFT {x: 0, y: 2}
- &BIG {r: 10}
- &SMALL {r: 1}
# All the following maps are equal:
# Explicit keys
- x: 1
  y: 2
  r: 10
  label: center/big
# Merge one map
- <<: *CENTER
  r: 10
  label: center/big
# Merge multiple maps
- <<: [*CENTER, *BIG]
  label: center/big
  
# Override
- <<: [*BIG, *LEFT, *SMALL]
  x: 1
  label: center/big
data = ruamel.yaml.load(inp, Loader=ruamel.yaml.RoundTripLoader)
data
# Modifying the merge order of the aliases
inp = \
- &CENTER {x: 1, y: 2}
- &LEFT {x: 0, y: 2}
- &BIG {r: 10}
- &SMALL {r: 1}
# All the following maps are equal:
# Explicit keys
- x: 1
  y: 2
  r: 10
  label: center/big
# Merge one map
- <<: *CENTER
  r: 10
  label: center/big
# Merge multiple maps
- <<: [*CENTER, *BIG]
  label: center/big
  
# Override
- <<: [*SMALL, *BIG, *LEFT]
  x: 1
  label: center/small
data = ruamel.yaml.load(inp, Loader=ruamel.yaml.RoundTripLoader)
data
assert data[7]['y'] == 2
Explanation: Full example
End of explanation
yaml_str = \
first_name: Art
occupation: Architect  # This is an occupation comment
about: Art Vandelay is a fictional character that George invents...
data = ruamel.yaml.round_trip_load(yaml_str)
data
data.insert(1, 'last name', 'Vandelay', comment='new key')
print(ruamel.yaml.round_trip_dump(data))
Explanation: Inserting Keys and Comments
End of explanation
<END_TASK>