codekingpro/portable-devtools
114k
1# This is a stub package designed to roughly emulate the _yaml2# extension module, which previously existed as a standalone module3# and has been moved into the `yaml` package namespace.4# It does not perfectly mimic its old counterpart, but should get5# close enough for anyone who's relying on it even when they shouldn't.6import yaml7 8# in some circumstances, the yaml module we imoprted may be from a different version, so we need9# to tread carefully when poking at it here (it may not have the attributes we expect)10if not getattr(yaml, '__with_libyaml__', False):11 from sys import version_info12 13 exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError14 raise exc("No module named '_yaml'")15else:16 from yaml._yaml import *17 import warnings18 warnings.warn(19 'The _yaml extension module is now located at yaml._yaml'20 ' and its location is subject to change. To use the'21 ' LibYAML-based parser and emitter, import from `yaml`:'22 ' `from yaml import CLoader as Loader, CDumper as Dumper`.',23 DeprecationWarning24 )25 del warnings26 # Don't `del yaml` here because yaml is actually an existing27 # namespace member of _yaml.28 29__name__ = '_yaml'30# If the module is top-level (i.e. not a part of any specific package)31# then the attribute should be set to ''.32# https://docs.python.org/3.8/library/types.html33__package__ = ''34 