Skip to content

Commit f0610d7

Browse files
committed
Implicitly treat .shed.yml contents as unicode.
Eliminates ugly type hints in .shed.yml files created by shed_init - closing #243.
1 parent aad1eed commit f0610d7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

planemo/shed/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@
121121
]
122122

123123

124+
def construct_yaml_str(self, node):
125+
# Override the default string handling function
126+
# to always return unicode objects
127+
return self.construct_scalar(node)
128+
129+
yaml.Loader.add_constructor(u'tag:yaml.org,2002:str', construct_yaml_str)
130+
yaml.SafeLoader.add_constructor(u'tag:yaml.org,2002:str', construct_yaml_str)
131+
132+
124133
def shed_init(ctx, path, **kwds):
125134
if not os.path.exists(path):
126135
os.makedirs(path)
@@ -690,7 +699,7 @@ def _create_shed_config(ctx, path, **kwds):
690699
del config[k]
691700

692701
with open(path, "w") as f:
693-
yaml.dump(config, f)
702+
yaml.safe_dump(config, f)
694703

695704

696705
def _parse_repos_from_workflow(path):

0 commit comments

Comments
 (0)