当前位置: 首页>>代码示例>>Python>>正文


Python yaml.__version__方法代码示例

本文整理汇总了Python中yaml.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python yaml.__version__方法的具体用法?Python yaml.__version__怎么用?Python yaml.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yaml的用法示例。


在下文中一共展示了yaml.__version__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_yaml

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def read_yaml(filepath: str, default_value: Optional[Any] = None, strict: bool = False) -> Dict:
    """Read a YAML file in.  If no file is found and default value is set, return that instead.  Otherwise error

    :param filepath: str, A file to load
    :param default_value: If the file doesn't exist, return return this. Defaults to an empty dict.
    :param strict: bool, If true raise an error on file not found.

    :return: dict, The read yaml object
    """
    if not os.path.exists(filepath):
        if strict:
            raise IOError("No file {} found".format(filepath))
        return default_value if default_value is not None else {}
    with open(filepath) as f:
        import yaml
        from distutils.version import LooseVersion

        if LooseVersion(yaml.__version__) >= LooseVersion("5.1"):
            return yaml.load(f, Loader=yaml.FullLoader)
        return yaml.load(f) 
开发者ID:dpressel,项目名称:mead-baseline,代码行数:22,代码来源:utils.py

示例2: yaml_load

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def yaml_load(f: typing.Union[str, typing.IO[str]]) -> typing.Any:
    """Wrapper over yaml.load using the C loader if possible."""
    start = datetime.datetime.now()

    # WORKAROUND for https://github.com/yaml/pyyaml/pull/181
    with log.ignore_py_warnings(
            category=DeprecationWarning,
            message=r"Using or importing the ABCs from 'collections' instead "
            r"of from 'collections\.abc' is deprecated.*"):
        data = yaml.load(f, Loader=YamlLoader)

    end = datetime.datetime.now()

    delta = (end - start).total_seconds()
    deadline = 10 if 'CI' in os.environ else 2
    if delta > deadline:  # pragma: no cover
        log.misc.warning(
            "YAML load took unusually long, please report this at "
            "https://github.com/qutebrowser/qutebrowser/issues/2777\n"
            "duration: {}s\n"
            "PyYAML version: {}\n"
            "C extension: {}\n"
            "Stack:\n\n"
            "{}".format(
                delta, yaml.__version__, YAML_C_EXT,
                ''.join(traceback.format_stack())))

    return data 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:30,代码来源:utils.py

示例3: default_params

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def default_params():
    '''Return default configuration
    '''
    default_params_yaml = open("config.yaml", "r")
    if(yaml.__version__[0]>=5):
        params = yaml.safe_load(default_params_yaml)
    else:
        params = yaml.load(default_params_yaml)

    params['image_format'] = get_img_format(params['base_dir'])
    return params 
开发者ID:mfxox,项目名称:ILCC,代码行数:13,代码来源:config.py

示例4: test_datetimes

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def test_datetimes(self):
        self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["."]), "")
        if yaml.__version__ < '5.3':
            self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["-y", "."]), "- '2016-12-20T22:07:36'\n")
        else:
            self.assertEqual(self.run_yq("- 2016-12-20T22:07:36Z\n", ["-y", "."]), "- '2016-12-20T22:07:36+00:00'\n")

        self.assertEqual(self.run_yq("2016-12-20", ["."]), "")
        self.assertEqual(self.run_yq("2016-12-20", ["-y", "."]), "'2016-12-20'\n") 
开发者ID:kislyuk,项目名称:yq,代码行数:11,代码来源:test.py

示例5: get_version

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def get_version(pkg):
    s = ".".join(pkg.__version__.split(".")[:2])
    return float(s) 
开发者ID:dpressel,项目名称:mead-baseline,代码行数:5,代码来源:utils.py

示例6: get_platform_info

# 需要导入模块: import yaml [as 别名]
# 或者: from yaml import __version__ [as 别名]
def get_platform_info():
    from gi.repository import GObject
    from gi.repository import Gtk
    import yaml

    functions = [
        platform.machine,
        platform.platform,
        platform.processor,
        platform.python_version,
        platform.release,
        platform.system,
    ]
    names_values = [(func.__name__, func()) for func in functions]

    names_values.extend(
        [
            (
                "GTK",
                (
                    Gtk.get_major_version(),
                    Gtk.get_minor_version(),
                    Gtk.get_micro_version(),
                ),
            ),
            ("Glib", GObject.glib_version),
            ("PyGObject", GObject.pygobject_version),
            ("YAML", yaml.__version__),
        ]
    )

    vals = ["{}: {}".format(name, val) for name, val in names_values]
    return "System info: " + ", ".join(vals) 
开发者ID:jendrikseipp,项目名称:rednotebook,代码行数:35,代码来源:filesystem.py


注:本文中的yaml.__version__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。