1919import datetime
2020import json
2121
22+ import pdb
23+
2224# for ordered dicts!
2325from collections import OrderedDict , Counter
2426
@@ -208,7 +210,7 @@ def to_yaml(
208210
209211 >>> config.to_yaml('global_variables', destination='../')
210212 """
211-
213+ logger . info ( "To YAML" )
212214 if not destination and not template :
213215 raise ValueError (
214216 "Both destination and template are None."
@@ -233,6 +235,8 @@ def to_yaml(
233235 mystream = re .sub (r"\s+~" , "~" , mystream )
234236 mystream = re .sub (r"~\s+" , "~" , mystream )
235237
238+ # pdb.set_trace()
239+
236240 cfg1 = self ._get_dest_form (mystream )
237241 cfg2 = self ._get_tmpl_form (mystream )
238242
@@ -622,7 +626,9 @@ def _get_required_form(stream, template=False, ipl=False):
622626 def _get_tmpl_form (stream ):
623627 """Get template form (<...> if present, not numbers)."""
624628
625- pattern = "-*[a-zA-Z0-9.]+~"
629+ pattern = "\\ -*[\\ -a-zA-Z0-9.]+~"
630+
631+ # pdb.set_trace()
626632
627633 if isinstance (stream , list ):
628634 logger .info ("STREAM is a list object" )
@@ -646,7 +652,8 @@ def _get_tmpl_form(stream):
646652 def _get_dest_form (stream ):
647653 """Get destination form (numbers, not <...>)"""
648654
649- pattern = "~<.+?>"
655+ logger .info ("TRY DEST %s" , stream )
656+ pattern = "~.*<.+?>"
650657
651658 if isinstance (stream , list ):
652659 logger .info ("STREAM is a list object" )
@@ -662,4 +669,5 @@ def _get_dest_form(stream):
662669 else :
663670 raise ValueError ("Input for templateconversion neither string " "or list" )
664671
672+ logger .info ("DEST %s" , result )
665673 return result
0 commit comments