コード例 #1
0
def test_example_2_1():
    yaml = YAML()
    yaml.round_trip("""
    - Mark McGwire
    - Sammy Sosa
    - Ken Griffey
    """)
コード例 #2
0
def test_example_2_5():
    yaml = YAML()
    yaml.flow_sequence_element_align = True
    yaml.round_trip("""
    - [name        , hr, avg  ]
    - [Mark McGwire, 65, 0.278]
    - [Sammy Sosa  , 63, 0.288]
    """)
コード例 #3
0
def test_example_2_2():
    yaml = YAML()
    yaml.mapping_value_align = True
    yaml.round_trip("""
    hr:  65    # Home runs
    avg: 0.278 # Batting average
    rbi: 147   # Runs Batted In
    """)
コード例 #4
0
 def test_sequence2(self):
     yaml = YAML()
     yaml.mapping_value_align = True
     yaml.round_trip(
         """
     - !Sequence [a, b: 1, c: {d: 3}]
     """
     )
コード例 #5
0
def test_example_2_13():
    yaml = YAML()
    yaml.round_trip(r"""
    # ASCII Art
    --- |
      \//||\/||
      // ||  ||__
    """)
コード例 #6
0
def test_example_2_19():
    yaml = YAML()
    yaml.round_trip("""
    canonical: 12345
    decimal: +12345
    octal: 0o14
    hexadecimal: 0xC
    """)
コード例 #7
0
def test_example_2_20():
    yaml = YAML()
    yaml.round_trip("""
    canonical: 1.23015e+3
    exponential: 12.3015e+02
    fixed: 1230.15
    negative infinity: -.inf
    not a number: .NaN
    """)
コード例 #8
0
 def test_sequence(self):
     yaml = YAML()
     yaml.brace_single_entry_mapping_in_flow_sequence = True
     yaml.mapping_value_align = True
     yaml.round_trip(
         """
     - !Sequence [a, {b: 1}, {c: {d: 3}}]
     """
     )
コード例 #9
0
ファイル: test_indentation.py プロジェクト: commx/ruamel-yaml
 def test_02(self):
     yaml = YAML()
     yaml.indent(mapping=5, sequence=6, offset=3)
     inp = """
     a:
          b:
             -  1
             -  [1, 2]
     """
     yaml.round_trip(inp)
コード例 #10
0
ファイル: test_indentation.py プロジェクト: commx/ruamel-yaml
 def test_01(self):
     yaml = YAML()
     yaml.indent(sequence=6)
     yaml.indent(offset=3)
     inp = """
     a:
        -  1
        -  {b: 3}
     """
     yaml.round_trip(inp)
コード例 #11
0
ファイル: test_literal.py プロジェクト: ware/ruamel-yaml
 def test_root_literal_doc_indent_document_end(self):
     yaml = YAML()
     yaml.explicit_start = True
     inp = """
     --- |-
       some more
       ...
       text
     """
     yaml.round_trip(inp)
コード例 #12
0
def test_example_2_18():
    yaml = YAML()
    yaml.round_trip("""
    plain:
      This unquoted scalar
      spans many lines.

    quoted: "So does this
      quoted scalar.\n"
    """)
コード例 #13
0
def test_example_2_14():
    yaml = YAML()
    yaml.explicit_start = True
    yaml.indent(root_scalar=2)  # needs to be added
    yaml.round_trip("""
    --- >
      Mark McGwire's
      year was crippled
      by a knee injury.
    """)
コード例 #14
0
ファイル: test_literal.py プロジェクト: ware/ruamel-yaml
 def test_root_literal_doc_indent_directives_end(self):
     yaml = YAML()
     yaml.explicit_start = True
     inp = """
     --- |-
       %YAML 1.3
       ---
       this: is a test
     """
     yaml.round_trip(inp)
コード例 #15
0
def test_example_2_6():
    yaml = YAML()
    # yaml.flow_mapping_final_comma = False
    yaml.flow_mapping_one_element_per_line = True
    yaml.round_trip("""
    Mark McGwire: {hr: 65, avg: 0.278}
    Sammy Sosa: {
        hr: 63,
        avg: 0.288
      }
    """)
コード例 #16
0
def test_example_2_16():
    yaml = YAML()
    yaml.round_trip("""
    name: Mark McGwire
    accomplishment: >
      Mark set a major league
      home run record in 1998.
    stats: |
      65 Home Runs
      0.278 Batting Average
    """)
コード例 #17
0
ファイル: test_literal.py プロジェクト: ware/ruamel-yaml
 def test_root_literal_doc_indent_marker(self):
     yaml = YAML()
     yaml.explicit_start = True
     inp = """
     --- |2
        some more
       text
     """
     d = yaml.load(inp)
     print(type(d), repr(d))
     yaml.round_trip(inp)
コード例 #18
0
ファイル: test_indentation.py プロジェクト: commx/ruamel-yaml
 def test_00(self):
     # old style
     yaml = YAML()
     yaml.indent = 6
     yaml.block_seq_indent = 3
     inp = """
     a:
        -  1
        -  [1, 2]
     """
     yaml.round_trip(inp)
コード例 #19
0
ファイル: test_indentation.py プロジェクト: commx/ruamel-yaml
 def test_04(self):
     yaml = YAML()
     yaml.indent(mapping=5, sequence=6)
     inp = """
     a:
          b:
          -     1
          -     [1, 2]
          -     {d: 3.14}
     """
     yaml.round_trip(inp)
コード例 #20
0
def test_example_2_15():
    yaml = YAML()
    yaml.round_trip("""
    >
     Sammy Sosa completed another
     fine season with great stats.

       63 Home Runs
       0.288 Batting Average

     What a year!
    """)
コード例 #21
0
def test_example_2_3():
    yaml = YAML()
    yaml.indent(sequence=4, offset=2)
    yaml.round_trip("""
    american:
      - Boston Red Sox
      - Detroit Tigers
      - New York Yankees
    national:
      - New York Mets
      - Chicago Cubs
      - Atlanta Braves
    """)
コード例 #22
0
def test_example_2_17():
    yaml = YAML()
    yaml.allow_unicode = False
    yaml.preserve_quotes = True
    yaml.round_trip(r"""
    unicode: "Sosa did fine.\u263A"
    control: "\b1998\t1999\t2000\n"
    hex esc: "\x0d\x0a is \r\n"

    single: '"Howdy!" he cried.'
    quoted: ' # Not a ''comment''.'
    tie-fighter: '|\-*-/|'
    """)
コード例 #23
0
def test_example_2_11():
    yaml = YAML()
    yaml.round_trip("""
    ? - Detroit Tigers
      - Chicago cubs
    :
      - 2001-07-23

    ? [ New York Yankees,
        Atlanta Braves ]
    : [ 2001-07-02, 2001-08-12,
        2001-08-14 ]
    """)
コード例 #24
0
def test_example_2_12():
    yaml = YAML()
    yaml.explicit_start = True
    yaml.round_trip("""
    ---
    # Products purchased
    - item    : Super Hoop
      quantity: 1
    - item    : Basketball
      quantity: 4
    - item    : Big Shoes
      quantity: 1
    """)
コード例 #25
0
def test_example_2_4():
    yaml = YAML()
    yaml.mapping_value_align = True
    yaml.round_trip("""
    -
      name: Mark McGwire
      hr:   65
      avg:  0.278
    -
      name: Sammy Sosa
      hr:   63
      avg:  0.288
    """)
コード例 #26
0
def test_example_2_9():
    yaml = YAML()
    yaml.explicit_start = True
    yaml.indent(sequence=4, offset=2)
    yaml.round_trip("""
    ---
    hr: # 1998 hr ranking
      - Mark McGwire
      - Sammy Sosa
    rbi:
      # 1998 rbi ranking
      - Sammy Sosa
      - Ken Griffey
    """)
コード例 #27
0
def test_example_2_10():
    yaml = YAML()
    yaml.explicit_start = True
    yaml.indent(sequence=4, offset=2)
    yaml.round_trip("""
    ---
    hr:
      - Mark McGwire
      # Following node labeled SS
      - &SS Sammy Sosa
    rbi:
      - *SS # Subsequent occurrence
      - Ken Griffey
    """)
コード例 #28
0
ファイル: test_indentation.py プロジェクト: commx/ruamel-yaml
 def test_issue_51(self):
     yaml = YAML()
     # yaml.map_indent = 2 # the default
     yaml.indent(sequence=4, offset=2)
     yaml.preserve_quotes = True
     yaml.round_trip("""
     role::startup::author::rsyslog_inputs:
       imfile:
         - ruleset: 'AEM-slinglog'
           File: '/opt/aem/author/crx-quickstart/logs/error.log'
           startmsg.regex: '^[-+T.:[:digit:]]*'
           tag: 'error'
         - ruleset: 'AEM-slinglog'
           File: '/opt/aem/author/crx-quickstart/logs/stdout.log'
           startmsg.regex: '^[-+T.:[:digit:]]*'
           tag: 'stdout'
     """)
コード例 #29
0
 def test_issue_249(self):
     yaml = YAML()
     inp = dedent(
         """\
     # comment
     -
       - 1
       - 2
       - 3
     """
     )
     exp = dedent(
         """\
     # comment
     - - 1
       - 2
       - 3
     """
     )
     yaml.round_trip(inp, outp=exp)  # NOQA
コード例 #30
0
def Xtest_example_2_X():
    yaml = YAML()
    yaml.round_trip("""
    """)