Importing `yaml` may fail (if the user doesn't have PyYAML installed),
but don't die until we need to use it. This way users without the old
YAML formats on disk can run BE without installing PyYAML.
import sys
import types
-import yaml
+try:
+ import yaml
+except ImportError as e:
+ yaml = None
+ _yaml_import_error = e
import libbe
import libbe.bug
>>> generate_yaml_mapfile({'q':u'hello'})
'q: hello\\n\\n'
"""
+ if yaml is None:
+ raise _yaml_import_error
keys = map.keys()
keys.sort()
for key in keys:
>>> dict['q']
u'Fran\\xe7ais'
"""
+ if yaml is None:
+ raise _yaml_import_error
c = yaml.safe_load(contents)
if type(c) == types.StringType:
raise mapfile.InvalidMapfileContents(