def test_lconf_emit_default_obj__ok6():
    """ Tests: test_lconf_emit_default_obj__ok6
   """
    print('::: TEST: test_lconf_emit_default_obj__ok6()')

    lconf_section__template_obj = Root([
        ('keyvalue_mapping',
         KVMap([
             ('#1',
              '# Comment-Line:  Key-Value-Mapping items: `Key :: Value Pairs`'
              ),
             ('mapping_key1', 'Some long sentence'),
         ])),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=True)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=True)
    eq_(section_lines[1], '. keyvalue_mapping', msg=None)
    eq_(section_lines[3], '   mapping_key1 :: Some long sentence', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok2():
    """ Tests: test_lconf_emit_default_obj__ok2
   """
    print('::: TEST: test_lconf_emit_default_obj__ok2()')

    lconf_section__template_obj = Root([
        ('first', 'Paul'),
        ('last', 'Smith'),
        ('sex', 'm'),
        ('age', '39', lconf_to_int),
        ('salary', '7000', lconf_to_float),
        ('interests', KVList(False, ['golf', 'reading', 'investments'])),
        ('registered', 'true'),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=False)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    eq_(section_lines[4], 'age :: 39', msg=None)
    eq_(section_lines[6], '- interests', msg=None)
    eq_(section_lines[7], '   golf', msg=None)
    eq_(section_lines[10], 'registered :: true', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok2():
   """ Tests: test_lconf_emit_default_obj__ok2
   """
   print('::: TEST: test_lconf_emit_default_obj__ok2()')

   lconf_section__template_obj = Root([
      ('first', 'Paul'),
      ('last', 'Smith'),
      ('sex', 'm'),
      ('age', '39', lconf_to_int),
      ('salary', '7000', lconf_to_float),
      ('interests', KVList(False, ['golf', 'reading', 'investments'])),
      ('registered', 'true'),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=False
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   eq_(section_lines[4], 'age :: 39', msg=None)
   eq_(section_lines[6], '- interests', msg=None)
   eq_(section_lines[7], '   golf', msg=None)
   eq_(section_lines[10], 'registered :: true', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok3():
   """ Tests: test_lconf_emit_default_obj__ok3
   """
   print('::: TEST: test_lconf_emit_default_obj__ok3()')

   lconf_section__template_obj = Root([
      ('first', 'Paul'),
      ('#1', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"'),
      ('last', 'Smith', None, 'NOT-DEFINED'),
      ('#2', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"'),
      ('sex', '', None, 'NOT-DEFINED'),
      ('age', '39', lconf_to_int),
      ('#3', '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "-1"'),
      ('salary', '', lconf_to_float, -1),
      ('interests', KVList(False, ['golf', 'reading', 'investments'])),
      ('registered', 'true'),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=False
   )
   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   eq_(section_lines[1], 'first :: Paul', msg=None)
   eq_(section_lines[2], 'last :: Smith', msg=None)
   eq_(section_lines[3], 'sex ::', msg=None)
   eq_(section_lines[4], 'age :: 39', msg=None)
   eq_(section_lines[5], 'salary ::', msg=None)
   eq_(section_lines[6], '- interests', msg=None)
   eq_(section_lines[7], '   golf', msg=None)
   eq_(section_lines[10], 'registered :: true', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok1():
   """ Tests: test_lconf_emit_default_obj__ok1
   """
   print('::: TEST: test_lconf_emit_default_obj__ok1()')

   lconf_section__template_obj = Root([
      ('first', ''),
      ('last', ''),
      ('sex', ''),
      ('age', ''),
      ('salary', ''),
      ('interests', KVList(False, [])),
      ('registered', ''),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=False
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   # empty multi line list: `Key-Value-List`
   eq_(section_lines[6], '- interests', msg=None)
   eq_(section_lines[8], '___END', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_NO,
      with_comments=True
   )
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_YES,
      with_comments=True
   )
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_NO,
      with_comments=False
   )
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_YES,
      with_comments=False
   )
def test_lconf_emit_default_obj__ok7():
    """ Tests: test_lconf_emit_default_obj__ok7
   """
    print('::: TEST: test_lconf_emit_default_obj__ok7()')

    # Main `Section-Template OBJ: type: Root
    lconf_section__template_obj = get_lconf_section__base_example_template_obj(
    )

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=True)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=True)
    eq_(section_lines[26], '   - mapping10_key4_list :: 555,9999', msg=None)
    eq_(section_lines[104],
        '            nested_mapping_key1 :: franz',
        msg=None)
    eq_(section_lines[114],
        '                  - block-item_key3_list |name|height|weight|',
        msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=True)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=True)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=False)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=False)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=False)
    lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok4():
    """ Tests: test_lconf_emit_default_obj__ok4
   """
    print('::: TEST: test_lconf_emit_default_obj__ok4()')

    lconf_section__template_obj = Root([
        ('interests', KVList(False, ['golf', 'reading', 'investments'])),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=False)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=True)
    eq_(section_lines[1], '- interests :: golf,reading,investments', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok4():
   """ Tests: test_lconf_emit_default_obj__ok4
   """
   print('::: TEST: test_lconf_emit_default_obj__ok4()')

   lconf_section__template_obj = Root([
      ('interests', KVList(False, ['golf', 'reading', 'investments'])),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_YES,
      with_comments=False
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=True)
   eq_(section_lines[1], '- interests :: golf,reading,investments', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok1():
    """ Tests: test_lconf_emit_default_obj__ok1
   """
    print('::: TEST: test_lconf_emit_default_obj__ok1()')

    lconf_section__template_obj = Root([
        ('first', ''),
        ('last', ''),
        ('sex', ''),
        ('age', ''),
        ('salary', ''),
        ('interests', KVList(False, [])),
        ('registered', ''),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=False)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    # empty multi line list: `Key-Value-List`
    eq_(section_lines[6], '- interests', msg=None)
    eq_(section_lines[8], '___END', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=True)
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=True)
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=True)
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=False)
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=False)
def test_lconf_emit_default_obj__ok3():
    """ Tests: test_lconf_emit_default_obj__ok3
   """
    print('::: TEST: test_lconf_emit_default_obj__ok3()')

    lconf_section__template_obj = Root([
        ('first', 'Paul'),
        ('#1',
         '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"'
         ),
        ('last', 'Smith', None, 'NOT-DEFINED'),
        ('#2',
         '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "NOT-DEFINED"'
         ),
        ('sex', '', None, 'NOT-DEFINED'),
        ('age', '39', lconf_to_int),
        ('#3',
         '# Comment-Line: `Key :: Value Pair` using an `Empty-KeyValuePair-ReplacementValue "-1"'
         ),
        ('salary', '', lconf_to_float, -1),
        ('interests', KVList(False, ['golf', 'reading', 'investments'])),
        ('registered', 'true'),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=False)
    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    eq_(section_lines[1], 'first :: Paul', msg=None)
    eq_(section_lines[2], 'last :: Smith', msg=None)
    eq_(section_lines[3], 'sex ::', msg=None)
    eq_(section_lines[4], 'age :: 39', msg=None)
    eq_(section_lines[5], 'salary ::', msg=None)
    eq_(section_lines[6], '- interests', msg=None)
    eq_(section_lines[7], '   golf', msg=None)
    eq_(section_lines[10], 'registered :: true', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok6():
   """ Tests: test_lconf_emit_default_obj__ok6
   """
   print('::: TEST: test_lconf_emit_default_obj__ok6()')

   lconf_section__template_obj = Root([
      ('keyvalue_mapping', KVMap([
         ('#1', '# Comment-Line:  Key-Value-Mapping items: `Key :: Value Pairs`'),
         ('mapping_key1', 'Some long sentence'),
      ])),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_NO,
      with_comments=True
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=True)
   eq_(section_lines[1], '. keyvalue_mapping', msg=None)
   eq_(section_lines[3], '   mapping_key1 :: Some long sentence', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
def main():
   # ---------------------------------- EXAMPLE 4 a ---------------------------------- #

   # EXAMPLE 4 a: ONLY VALIDATE
   lconf_validate_one_section_str(lconf_section__example_4a_lconf_section_raw_str)

   # EXAMPLE 4 a: ONLY PREPARE DEFAULT OBJ
   lconf_default_obj = lconf_prepare_default_obj(lconf_section__example_4a__template_obj, with_comments=False)
   print('\n\n============== EXAMPLE 4 a: ONLY PREPARE DEFAULT OBJ ==============\n')
   print(lconf_default_obj)

   # EXAMPLE 4 a: VALIDATE, PREPARE, PARSE:
   # validate a `LCONF-Section string` and prepare a default lconf obj from the template obj and parse the LCONF-Section
   print('\n\n============== EXAMPLE 4 a: VALIDATE, PREPARE, PARSE ==============\n')
   lconf_parse_obj = lconf_prepare_and_parse_section(
      lconf_section__example_4a_lconf_section_raw_str,
      lconf_section__example_4a__template_obj,
      with_comments=True,
      validate=True
   )
   print(lconf_parse_obj)

   # EXAMPLE 4 a: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4a_lconf_section_raw_str,
      'EXAMPLE 4 a',
      lconf_section__example_4a__template_obj,
      with_comments=True,
      validate=True
   )
   print(
      '\n\n============== EXAMPLE 4 a: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: also for files ==============\n')
   print(lconf_parse_obj)

   # EXAMPLE 4 a: ACCESS The Section-INFO
   print('\n\n============== EXAMPLE 4 a: ACCESS The Section-INFO ==============\n')
   print('  lconf_parse_obj.key_order: ', lconf_parse_obj.key_order)
   print('  lconf_parse_obj.section_name: ', lconf_parse_obj.section_name)
   print('  lconf_parse_obj.is_parsed: ', lconf_parse_obj.is_parsed)
   print('  lconf_parse_obj.has_comments: ', lconf_parse_obj.has_comments)

   # EXAMPLE 4 a: EMIT DEFAULT OBJ
   lconf_section_emitted_default_obj_str = lconf_emit_default_obj(
      lconf_section__example_4a__template_obj,
      'EMITTED EXAMPLE 4 a',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )
   print('\n\n============== EXAMPLE 4 a: EMIT DEFAULT OBJ ==============\n')
   print(lconf_section_emitted_default_obj_str)

   # EXAMPLE: EMIT PARSED LCONF OBJ
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4a_lconf_section_raw_str,
      'EXAMPLE 4 a',
      lconf_section__example_4a__template_obj,
      with_comments=True,
      validate=True
   )
   lconf_section_emitted_parsed_obj_str = lconf_emit(lconf_parse_obj, onelinelists=LCONF_DEFAULT)

   print('\n\n============== EXAMPLE 4 a: EMIT PARSED LCONF OBJ ==============\n')
   print(lconf_section_emitted_parsed_obj_str)

   # EXAMPLE 4 a: EMIT TO JSON
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4a_lconf_section_raw_str,
      'EXAMPLE 4 a',
      lconf_section__example_4a__template_obj,
      with_comments=False,
      validate=True
   )
   result_ordered_native_type = lconf_to_ordered_native_type(lconf_parse_obj)
   dump_json = json_dumps(result_ordered_native_type, indent=3)

   print('\n\n============== EXAMPLE 4 a: EMIT TO ORDERED JSON ==============\n')
   print(dump_json)

   # EXAMPLE: EMIT TO YAML
   if has_yaml:
      lconf_parse_obj = lconf_parse_section_extract_by_name(
         lconf_section__example_4a_lconf_section_raw_str,
         'EXAMPLE 4 a',
         lconf_section__example_4a__template_obj,
         with_comments=False,
         validate=True
      )
      result_native_type = lconf_to_native_type(lconf_parse_obj)
      dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True)

      print('\n\n============== EXAMPLE 4 a: EMIT TO YAML ==============\n')
      print(dump_yaml)


   # ---------------------------------- EXAMPLE 4 b ---------------------------------- #

   # EXAMPLE 4 b: ONLY VALIDATE
   lconf_validate_one_section_str(lconf_section__example_4b_lconf_section_raw_str)

   # EXAMPLE 4 b: ONLY PREPARE DEFAULT OBJ
   lconf_default_obj = lconf_prepare_default_obj(lconf_section__example_4b__template_obj, with_comments=False)
   print('\n\n============== EXAMPLE 4 b: ONLY PREPARE DEFAULT OBJ ==============\n')
   print(lconf_default_obj)

   # EXAMPLE 4 b: VALIDATE, PREPARE, PARSE:
   # validate a `LCONF-Section string` and prepare a default lconf obj from the template obj and parse the LCONF-Section
   print('\n\n============== EXAMPLE 4 b: VALIDATE, PREPARE, PARSE ==============\n')
   lconf_parse_obj = lconf_prepare_and_parse_section(
      lconf_section__example_4b_lconf_section_raw_str,
      lconf_section__example_4b__template_obj,
      with_comments=True,
      validate=True
   )
   print(lconf_parse_obj)

   # EXAMPLE 4 b: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4b_lconf_section_raw_str,
      'EXAMPLE 4 b',
      lconf_section__example_4b__template_obj,
      with_comments=True,
      validate=True
   )
   print(
      '\n\n============== EXAMPLE 4 b: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: also for files ==============\n')
   print(lconf_parse_obj)

   # EXAMPLE 4 b: ACCESS The Section-INFO
   print('\n\n============== EXAMPLE 4 b: ACCESS The Section-INFO ==============\n')
   print('  lconf_parse_obj.key_order: ', lconf_parse_obj.key_order)
   print('  lconf_parse_obj.section_name: ', lconf_parse_obj.section_name)
   print('  lconf_parse_obj.is_parsed: ', lconf_parse_obj.is_parsed)
   print('  lconf_parse_obj.has_comments: ', lconf_parse_obj.has_comments)

   # EXAMPLE 4 b: EMIT DEFAULT OBJ
   lconf_section_emitted_default_obj_str = lconf_emit_default_obj(
      lconf_section__example_4b__template_obj,
      'EMITTED EXAMPLE 4 b',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )
   print('\n\n============== EXAMPLE 4 b: EMIT DEFAULT OBJ ==============\n')
   print(lconf_section_emitted_default_obj_str)

   # EXAMPLE: EMIT PARSED LCONF OBJ
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4b_lconf_section_raw_str,
      'EXAMPLE 4 b',
      lconf_section__example_4b__template_obj,
      with_comments=True,
      validate=True
   )
   lconf_section_emitted_parsed_obj_str = lconf_emit(lconf_parse_obj, onelinelists=LCONF_DEFAULT)

   print('\n\n============== EXAMPLE 4 b: EMIT PARSED LCONF OBJ ==============\n')
   print(lconf_section_emitted_parsed_obj_str)

   # EXAMPLE 4 b: EMIT TO JSON
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__example_4b_lconf_section_raw_str,
      'EXAMPLE 4 b',
      lconf_section__example_4b__template_obj,
      with_comments=False,
      validate=True
   )
   result_ordered_native_type = lconf_to_ordered_native_type(lconf_parse_obj)
   dump_json = json_dumps(result_ordered_native_type, indent=3)

   print('\n\n============== EXAMPLE 4 b: EMIT TO ORDERED JSON ==============\n')
   print(dump_json)

   # EXAMPLE: EMIT TO YAML
   if has_yaml:
      lconf_parse_obj = lconf_parse_section_extract_by_name(
         lconf_section__example_4b_lconf_section_raw_str,
         'EXAMPLE 4 b',
         lconf_section__example_4b__template_obj,
         with_comments=False,
         validate=True
      )
      result_native_type = lconf_to_native_type(lconf_parse_obj)
      dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True)

      print('\n\n============== EXAMPLE 4 b: EMIT TO YAML ==============\n')
      print(dump_yaml)
def main():
    pass

    # EXAMPLE: ONLY VALIDATE
    lconf_validate_one_section_str(
        lconf_section__base_example_lconf_section_raw_str)

    # EXAMPLE: ONLY PREPARE DEFAULT OBJ
    lconf_default_obj = lconf_prepare_default_obj(
        lconf_section__base_example_template_obj, with_comments=False)
    print(
        '\n\n============== EXAMPLE: ONLY PREPARE DEFAULT OBJ ==============\n'
    )
    print(lconf_default_obj)

    # EXAMPLE: VALIDATE, PREPARE, PARSE:
    # validate a `LCONF-Section string` and prepare a default lconf obj from the template obj and parse the LCONF-Section
    print(
        '\n\n============== EXAMPLE: VALIDATE, PREPARE, PARSE ==============\n'
    )
    lconf_parse_obj = lconf_prepare_and_parse_section(
        lconf_section__base_example_lconf_section_raw_str,
        lconf_section__base_example_template_obj,
        with_comments=True,
        validate=True)
    print(lconf_parse_obj)

    # EXAMPLE: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__base_example_lconf_section_raw_str,
        'BaseEXAMPLE',
        lconf_section__base_example_template_obj,
        with_comments=True,
        validate=True)
    print(
        '\n\n============== EXAMPLE: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: also for files ==============\n'
    )
    print(lconf_parse_obj)

    # EXAMPLE: ACCESS The Section-INFO
    print(
        '\n\n============== EXAMPLE: ACCESS The Section-INFO ==============\n')
    print(('  lconf_parse_obj.key_order: ', lconf_parse_obj.key_order))
    print(('  lconf_parse_obj.key_empty_replacementvalue: ',
           lconf_parse_obj.key_empty_replacementvalue))
    print(('  lconf_parse_obj.section_name: ', lconf_parse_obj.section_name))
    print(('  lconf_parse_obj.is_parsed: ', lconf_parse_obj.is_parsed))
    print(('  lconf_parse_obj.has_comments: ', lconf_parse_obj.has_comments))

    # EXAMPLE: EMIT DEFAULT OBJ
    lconf_section_emitted_default_obj_str = lconf_emit_default_obj(
        lconf_section__base_example_template_obj,
        'EMITTED BaseEXAMPLE',
        onelinelists=LCONF_DEFAULT,
        with_comments=True)
    print('\n\n============== EXAMPLE: EMIT DEFAULT OBJ (==============\n')
    print(lconf_section_emitted_default_obj_str)

    # EXAMPLE: EMIT PARSED LCONF OBJ
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__base_example_lconf_section_raw_str,
        'BaseEXAMPLE',
        lconf_section__base_example_template_obj,
        with_comments=True,
        validate=True)
    lconf_section_emitted_parsed_obj_str = lconf_emit(
        lconf_parse_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=True)

    print(
        '\n\n============== EXAMPLE: EMIT PARSED LCONF OBJ (empty_key_value_pair=True) ==============\n'
    )
    print(lconf_section_emitted_parsed_obj_str)

    lconf_section_emitted_parsed_obj_str = lconf_emit(
        lconf_parse_obj,
        onelinelists=LCONF_DEFAULT,
        empty_key_value_pair=False)
    print(
        '\n\n============== EXAMPLE: EMIT PARSED LCONF OBJ (empty_key_value_pair=False) ==============\n'
    )
    print(lconf_section_emitted_parsed_obj_str)

    # EXAMPLE: EMIT TO JSON
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__base_example_lconf_section_raw_str,
        'BaseEXAMPLE',
        lconf_section__base_example_template_obj,
        with_comments=False,
        validate=True)
    result_ordered_native_type = lconf_to_ordered_native_type(lconf_parse_obj)
    # IMPORTANT: datetime.datetime(2014, 5, 8, 13, 39) is not JSON serializable
    result_ordered_native_type['key11value_mapping']['mapping11_key2_mapping'][
        'mapping11_key2_nested_mapping_key1'] = '2014-05-08 13:39:00'
    dump_json = json_dumps(result_ordered_native_type, indent=3)

    print('\n\n============== EXAMPLE: EMIT TO ORDERED JSON ==============\n')
    print(dump_json)

    # EXAMPLE: EMIT TO YAML
    if has_yaml:
        lconf_parse_obj = lconf_parse_section_extract_by_name(
            lconf_section__base_example_lconf_section_raw_str,
            'BaseEXAMPLE',
            lconf_section__base_example_template_obj,
            with_comments=False,
            validate=True)
        result_native_type = lconf_to_native_type(lconf_parse_obj)
        #  IMPORTANT: datetime.datetime(2014, 5, 8, 13, 39) is not JSON serializable
        result_native_type['key11value_mapping']['mapping11_key2_mapping'][
            'mapping11_key2_nested_mapping_key1'] = '2014-05-08 13:39:00'
        dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True)

        print('\n\n============== EXAMPLE: EMIT TO YAML ==============\n')
        print(dump_yaml)
Example #14
0
def main():
    # ---------------------------------- EXAMPLE 3 ---------------------------------- #

    # EXAMPLE 3: ONLY VALIDATE
    lconf_validate_one_section_str(
        lconf_section__example_3_lconf_section_raw_str)

    # EXAMPLE 3: ONLY PREPARE DEFAULT OBJ
    lconf_default_obj = lconf_prepare_default_obj(
        lconf_section__example_3__template_obj, with_comments=False)
    print(
        '\n\n============== EXAMPLE 3: ONLY PREPARE DEFAULT OBJ ==============\n'
    )
    print(lconf_default_obj)

    # EXAMPLE 3: VALIDATE, PREPARE, PARSE:
    # validate a `LCONF-Section string` and prepare a default lconf obj from the template obj and parse the LCONF-Section
    print(
        '\n\n============== EXAMPLE 3: VALIDATE, PREPARE, PARSE ==============\n'
    )
    lconf_parse_obj = lconf_prepare_and_parse_section(
        lconf_section__example_3_lconf_section_raw_str,
        lconf_section__example_3__template_obj,
        with_comments=True,
        validate=True)
    print(lconf_parse_obj)

    # EXAMPLE 3: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__example_3_lconf_section_raw_str,
        'EXAMPLE 3',
        lconf_section__example_3__template_obj,
        with_comments=True,
        validate=True)
    print(
        '\n\n============== EXAMPLE 3: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files ==============\n'
    )
    print(lconf_parse_obj)

    # EXAMPLE 3: ACCESS The Section-INFO
    print(
        '\n\n============== EXAMPLE 3: ACCESS The Section-INFO ==============\n'
    )
    print(('  lconf_parse_obj.key_order: ', lconf_parse_obj.key_order))
    print(('  lconf_parse_obj.section_name: ', lconf_parse_obj.section_name))
    print(('  lconf_parse_obj.is_parsed: ', lconf_parse_obj.is_parsed))
    print(('  lconf_parse_obj.has_comments: ', lconf_parse_obj.has_comments))

    # EXAMPLE 3: EMIT DEFAULT OBJ
    lconf_section_emitted_default_obj_str = lconf_emit_default_obj(
        lconf_section__example_3__template_obj,
        'EMITTED EXAMPLE 3',
        onelinelists=LCONF_DEFAULT,
        with_comments=True)
    print('\n\n============== EXAMPLE 3: EMIT DEFAULT OBJ ==============\n')
    print(lconf_section_emitted_default_obj_str)

    # EXAMPLE: EMIT PARSED LCONF OBJ
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__example_3_lconf_section_raw_str,
        'EXAMPLE 3',
        lconf_section__example_3__template_obj,
        with_comments=True,
        validate=True)
    lconf_section_emitted_parsed_obj_str = lconf_emit(
        lconf_parse_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=True)

    print(
        '\n\n============== EXAMPLE 3: EMIT PARSED LCONF OBJ ==============\n')
    print(lconf_section_emitted_parsed_obj_str)

    # EXAMPLE 3: EMIT TO JSON
    lconf_parse_obj = lconf_parse_section_extract_by_name(
        lconf_section__example_3_lconf_section_raw_str,
        'EXAMPLE 3',
        lconf_section__example_3__template_obj,
        with_comments=False,
        validate=True)
    result_ordered_native_type = lconf_to_ordered_native_type(lconf_parse_obj)
    dump_json = json_dumps(result_ordered_native_type, indent=3)

    print(
        '\n\n============== EXAMPLE 3: EMIT TO ORDERED JSON ==============\n')
    print(dump_json)

    # EXAMPLE: EMIT TO YAML
    if has_yaml:
        lconf_parse_obj = lconf_parse_section_extract_by_name(
            lconf_section__example_3_lconf_section_raw_str,
            'EXAMPLE 3',
            lconf_section__example_3__template_obj,
            with_comments=False,
            validate=True)
        result_native_type = lconf_to_native_type(lconf_parse_obj)
        dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True)

        print('\n\n============== EXAMPLE 3: EMIT TO YAML ==============\n')
        print(dump_yaml)
def main():
   pass

   # EXAMPLE: ONLY VALIDATE
   lconf_validate_one_section_str(lconf_section__base_example_lconf_section_raw_str)

   # EXAMPLE: ONLY PREPARE DEFAULT OBJ
   lconf_default_obj = lconf_prepare_default_obj(lconf_section__base_example_template_obj, with_comments=False)
   print('\n\n============== EXAMPLE: ONLY PREPARE DEFAULT OBJ ==============\n')
   print(lconf_default_obj)

   # EXAMPLE: VALIDATE, PREPARE, PARSE:
   # validate a `LCONF-Section string` and prepare a default lconf obj from the template obj and parse the LCONF-Section
   print('\n\n============== EXAMPLE: VALIDATE, PREPARE, PARSE ==============\n')
   lconf_parse_obj = lconf_prepare_and_parse_section(
      lconf_section__base_example_lconf_section_raw_str,
      lconf_section__base_example_template_obj,
      with_comments=True,
      validate=True
   )
   print(lconf_parse_obj)

   # EXAMPLE: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: this is also useful to extract from files
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__base_example_lconf_section_raw_str,
      'BaseEXAMPLE',
      lconf_section__base_example_template_obj,
      with_comments=True,
      validate=True
   )
   print(
      '\n\n============== EXAMPLE: EXTRACT KNOWN SECTION, VALIDATE, PREPARE, PARSE: also for files ==============\n')
   print(lconf_parse_obj)

   # EXAMPLE: ACCESS The Section-INFO
   print('\n\n============== EXAMPLE: ACCESS The Section-INFO ==============\n')
   print('  lconf_parse_obj.key_order: ', lconf_parse_obj.key_order)
   print('  lconf_parse_obj.key_empty_replacementvalue: ', lconf_parse_obj.key_empty_replacementvalue)
   print('  lconf_parse_obj.section_name: ', lconf_parse_obj.section_name)
   print('  lconf_parse_obj.is_parsed: ', lconf_parse_obj.is_parsed)
   print('  lconf_parse_obj.has_comments: ', lconf_parse_obj.has_comments)


   # EXAMPLE: EMIT DEFAULT OBJ
   lconf_section_emitted_default_obj_str = lconf_emit_default_obj(
      lconf_section__base_example_template_obj,
      'EMITTED BaseEXAMPLE',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )
   print('\n\n============== EXAMPLE: EMIT DEFAULT OBJ (==============\n')
   print(lconf_section_emitted_default_obj_str)

   # EXAMPLE: EMIT PARSED LCONF OBJ
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__base_example_lconf_section_raw_str,
      'BaseEXAMPLE',
      lconf_section__base_example_template_obj,
      with_comments=True,
      validate=True
   )
   lconf_section_emitted_parsed_obj_str = lconf_emit(lconf_parse_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=True)

   print('\n\n============== EXAMPLE: EMIT PARSED LCONF OBJ (empty_key_value_pair=True) ==============\n')
   print(lconf_section_emitted_parsed_obj_str)


   lconf_section_emitted_parsed_obj_str = lconf_emit(lconf_parse_obj, onelinelists=LCONF_DEFAULT, empty_key_value_pair=False)
   print('\n\n============== EXAMPLE: EMIT PARSED LCONF OBJ (empty_key_value_pair=False) ==============\n')
   print(lconf_section_emitted_parsed_obj_str)


   # EXAMPLE: EMIT TO JSON
   lconf_parse_obj = lconf_parse_section_extract_by_name(
      lconf_section__base_example_lconf_section_raw_str,
      'BaseEXAMPLE',
      lconf_section__base_example_template_obj,
      with_comments=False,
      validate=True
   )
   result_ordered_native_type = lconf_to_ordered_native_type(lconf_parse_obj)
   # IMPORTANT: datetime.datetime(2014, 5, 8, 13, 39) is not JSON serializable
   result_ordered_native_type['key11value_mapping']['mapping11_key2_mapping'][
      'mapping11_key2_nested_mapping_key1'] = '2014-05-08 13:39:00'
   dump_json = json_dumps(result_ordered_native_type, indent=3)

   print('\n\n============== EXAMPLE: EMIT TO ORDERED JSON ==============\n')
   print(dump_json)

   # EXAMPLE: EMIT TO YAML
   if has_yaml:
      lconf_parse_obj = lconf_parse_section_extract_by_name(
         lconf_section__base_example_lconf_section_raw_str,
         'BaseEXAMPLE',
         lconf_section__base_example_template_obj,
         with_comments=False,
         validate=True
      )
      result_native_type = lconf_to_native_type(lconf_parse_obj)
      #  IMPORTANT: datetime.datetime(2014, 5, 8, 13, 39) is not JSON serializable
      result_native_type['key11value_mapping']['mapping11_key2_mapping'][
         'mapping11_key2_nested_mapping_key1'] = '2014-05-08 13:39:00'
      dump_yaml = yaml_dump(result_native_type, indent=3, allow_unicode=True)

      print('\n\n============== EXAMPLE: EMIT TO YAML ==============\n')
      print(dump_yaml)
def test_lconf_emit_default_obj__ok0():
   """ Tests: test_lconf_emit_default_obj__ok0
   """
   print('::: TEST: test_lconf_emit_default_obj__ok0()')

   lconf_section__template_obj = Root([
      # Default Empty Line
      ('#1', ''),
      # Default Comment Line
      ('#2', '# Comment-Line: `Key :: Value Pair`'),
      ('first', ''),
      ('last', ''),
      ('sex', ''),
      ('age', ''),
      ('salary', ''),
      ('#3', '# Comment-Line: `Key-Value-List`'),
      ('interests', KVList(True, [])),
      ('#4', '# Comment-Line: `Key :: Value Pair`'),
      ('registered', ''),
   ])
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   # empty comment line
   eq_(section_lines[1], '', msg=None)
   eq_(section_lines[8], '# Comment-Line: `Key-Value-List`', msg=None)
   eq_(section_lines[9], '- interests ::', msg=None)
   eq_(section_lines[12], '___END', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_NO,
      with_comments=True
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_YES,
      with_comments=True
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=False
   )
   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   # empty multi line list: `Key :: Value-List`
   eq_(section_lines[6], '- interests ::', msg=None)
   eq_(section_lines[8], '___END', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
   #
   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_NO,
      with_comments=False
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   # empty multi line list: `Key :: Value-List`
   eq_(section_lines[6], '- interests', msg=None)
   eq_(section_lines[8], '___END', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Test Example1',
      onelinelists=LCONF_YES,
      with_comments=False
   )
   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)
   eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
   # empty multi line list: `Key :: Value-List`
   eq_(section_lines[6], '- interests ::', msg=None)
   eq_(section_lines[8], '___END', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok7():
   """ Tests: test_lconf_emit_default_obj__ok7
   """
   print('::: TEST: test_lconf_emit_default_obj__ok7()')

   # Main `Section-Template OBJ: type: Root
   lconf_section__template_obj = get_lconf_section__base_example_template_obj()

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=True
   )

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=True)
   eq_(section_lines[26], '   - mapping10_key4_list :: 555,9999', msg=None)
   eq_(section_lines[104], '            nested_mapping_key1 :: franz', msg=None)
   eq_(section_lines[114], '                  - block-item_key3_list |name|height|weight|', msg=None)

   lconf_validate_one_section_str(lconf_section_raw_str)

   section_lines, section_name = lconf_section_splitlines(lconf_section_raw_str, validate_first_line=False)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_NO,
      with_comments=True
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_YES,
      with_comments=True
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_DEFAULT,
      with_comments=False
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_NO,
      with_comments=False
   )
   lconf_validate_one_section_str(lconf_section_raw_str)

   lconf_section_raw_str = lconf_emit_default_obj(
      lconf_section__template_obj,
      'Example1',
      onelinelists=LCONF_YES,
      with_comments=False
   )
   lconf_validate_one_section_str(lconf_section_raw_str)
def test_lconf_emit_default_obj__ok0():
    """ Tests: test_lconf_emit_default_obj__ok0
   """
    print('::: TEST: test_lconf_emit_default_obj__ok0()')

    lconf_section__template_obj = Root([
        # Default Empty Line
        ('#1', ''),
        # Default Comment Line
        ('#2', '# Comment-Line: `Key :: Value Pair`'),
        ('first', ''),
        ('last', ''),
        ('sex', ''),
        ('age', ''),
        ('salary', ''),
        ('#3', '# Comment-Line: `Key-Value-List`'),
        ('interests', KVList(True, [])),
        ('#4', '# Comment-Line: `Key :: Value Pair`'),
        ('registered', ''),
    ])
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=True)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    # empty comment line
    eq_(section_lines[1], '', msg=None)
    eq_(section_lines[8], '# Comment-Line: `Key-Value-List`', msg=None)
    eq_(section_lines[9], '- interests ::', msg=None)
    eq_(section_lines[12], '___END', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=True)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=True)
    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_DEFAULT,
                                                   with_comments=False)
    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    # empty multi line list: `Key :: Value-List`
    eq_(section_lines[6], '- interests ::', msg=None)
    eq_(section_lines[8], '___END', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)
    #
    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_NO,
                                                   with_comments=False)

    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    # empty multi line list: `Key :: Value-List`
    eq_(section_lines[6], '- interests', msg=None)
    eq_(section_lines[8], '___END', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)

    lconf_section_raw_str = lconf_emit_default_obj(lconf_section__template_obj,
                                                   'Test Example1',
                                                   onelinelists=LCONF_YES,
                                                   with_comments=False)
    section_lines, section_name = lconf_section_splitlines(
        lconf_section_raw_str, validate_first_line=False)
    eq_(section_lines[0], '___SECTION :: Test Example1', msg=None)
    # empty multi line list: `Key :: Value-List`
    eq_(section_lines[6], '- interests ::', msg=None)
    eq_(section_lines[8], '___END', msg=None)

    lconf_validate_one_section_str(lconf_section_raw_str)