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


Python cbook.file_requires_unicode方法代码示例

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


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

示例1: print_svg

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import file_requires_unicode [as 别名]
def print_svg(self, filename, *args, **kwargs):
        with cbook.open_file_cm(filename, "w", encoding="utf-8") as fh:

            filename = getattr(fh, 'name', '')
            if not isinstance(filename, str):
                filename = ''

            if cbook.file_requires_unicode(fh):
                detach = False
            else:
                fh = io.TextIOWrapper(fh, 'utf-8')
                detach = True

            result = self._print_svg(filename, fh, **kwargs)

            # Detach underlying stream from wrapper so that it remains open in
            # the caller.
            if detach:
                fh.detach()

        return result 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:23,代码来源:backend_svg.py

示例2: print_pgf

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import file_requires_unicode [as 别名]
def print_pgf(self, fname_or_fh, *args, **kwargs):
        """
        Output pgf commands for drawing the figure so it can be included and
        rendered in latex documents.
        """
        if kwargs.get("dryrun", False):
            self._print_pgf_to_fh(None, *args, **kwargs)
            return
        with cbook.open_file_cm(fname_or_fh, "w", encoding="utf-8") as file:
            if not cbook.file_requires_unicode(file):
                file = codecs.getwriter("utf-8")(file)
            self._print_pgf_to_fh(file, *args, **kwargs) 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:14,代码来源:backend_pgf.py

示例3: print_svg

# 需要导入模块: from matplotlib import cbook [as 别名]
# 或者: from matplotlib.cbook import file_requires_unicode [as 别名]
def print_svg(self, filename, *args, **kwargs):
        with cbook.open_file_cm(filename, "w", encoding="utf-8") as fh:

            filename = getattr(fh, 'name', '')
            if not isinstance(filename, six.string_types):
                filename = ''

            if cbook.file_requires_unicode(fh):
                detach = False
            else:
                if six.PY3:
                    fh = io.TextIOWrapper(fh, 'utf-8')
                else:
                    fh = codecs.getwriter('utf-8')(fh)
                detach = True

            result = self._print_svg(filename, fh, **kwargs)

            # Detach underlying stream from wrapper so that it remains open in
            # the caller.
            if detach:
                if six.PY3:
                    fh.detach()
                else:
                    fh.reset()
                    fh.stream = io.BytesIO()

        return result 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:30,代码来源:backend_svg.py


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