1818
1919
2020def load (hsdfile : Union [TextIO , str ], lower_tag_names : bool = False ,
21- include_hsd_attribs : bool = False , flatten_data : bool = False ) -> dict :
21+ include_hsd_attribs : bool = False , flatten_data : bool = False ,
22+ include_file : bool = True ) -> dict :
2223 """Loads a file with HSD-formatted data into a Python dictionary
2324
2425 Args:
@@ -36,6 +37,7 @@ def load(hsdfile: Union[TextIO, str], lower_tag_names: bool = False,
3637 flatten_data: Whether multiline data in the HSD input should be
3738 flattened into a single list. Othewise a list of lists is created,
3839 with one list for every line (default).
40+ include_file: Whether files via "<<<"/"<<+" should be included or not
3941
4042 Returns:
4143 Dictionary representing the HSD data.
@@ -45,7 +47,7 @@ def load(hsdfile: Union[TextIO, str], lower_tag_names: bool = False,
4547 """
4648 dictbuilder = HsdDictBuilder (lower_tag_names = lower_tag_names , flatten_data = flatten_data ,
4749 include_hsd_attribs = include_hsd_attribs )
48- parser = HsdParser (eventhandler = dictbuilder )
50+ parser = HsdParser (eventhandler = dictbuilder , include_file = include_file )
4951 if isinstance (hsdfile , str ):
5052 with open (hsdfile , "r" ) as hsddescr :
5153 parser .parse (hsddescr )
@@ -56,8 +58,8 @@ def load(hsdfile: Union[TextIO, str], lower_tag_names: bool = False,
5658
5759def load_string (
5860 hsdstr : str , lower_tag_names : bool = False ,
59- include_hsd_attribs : bool = False , flatten_data : bool = False
60- ) -> dict :
61+ include_hsd_attribs : bool = False , flatten_data : bool = False ,
62+ include_file : bool = True ) -> dict :
6163 """Loads a string with HSD-formatted data into a Python dictionary.
6264
6365 Args:
@@ -75,6 +77,7 @@ def load_string(
7577 flatten_data: Whether multiline data in the HSD input should be
7678 flattened into a single list. Othewise a list of lists is created,
7779 with one list for every line (default).
80+ include_file: Whether files via "<<<"/"<<+" should be included or not
7881
7982 Returns:
8083 Dictionary representing the HSD data.
@@ -130,7 +133,8 @@ def load_string(
130133
131134 """
132135 fobj = io .StringIO (hsdstr )
133- return load (fobj , lower_tag_names , include_hsd_attribs , flatten_data )
136+ return load (fobj , lower_tag_names , include_hsd_attribs , flatten_data ,
137+ include_file )
134138
135139
136140def dump (data : dict , hsdfile : Union [TextIO , str ],
0 commit comments