• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pyaml.dump函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyaml.dump函数的典型用法代码示例。如果您正苦于以下问题:Python dump函数的具体用法?Python dump怎么用?Python dump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: writeConfig

 def writeConfig(self): 
   log.info("Writing config...")
   trigs = {}
   for i in self.triggers:
     trigs[i.trigger] = i.text
   log.info("Saving : {}".format(trigs))
   settings = {
               "bot": {
                 "name": self.botname,
                 "version": self.bot_version,
                 "msg_prefix": self.bot_prefix,
                 "cmd_prefix": self.cmd_prefix,
                 "debug_logging": False 
               },
               "modules": {
                 "path": self.path,
                 "load": self.init_modules
               },
               "triggers": trigs,
               "admins": self.admins,
               "ai":{"model_directory":"models"}
             }
   log.info(pyaml.dump(settings))
   with open("discord-config.conf", "w") as f:
     f.write(pyaml.dump(settings))
   log.info("Written") 
开发者ID:FloatingGhost,项目名称:Python-Utilities,代码行数:26,代码来源:discord.py


示例2: do_list

    def do_list(self):
        """
        Usage: list
        """
        archives = self.cache._for_adf('archives')

        if len(archives):
            for n, archive in enumerate(archives.iteritems()):
                archive = archive[1]
                status = "LOCAL"
                cert = ""
                if 'signature' in archive:
                    status = "COMPLETE"
                    cert = archive['signature'].aid
                elif 'links' in archive and archive['links'].upload:
                    status = "UPLOADED"
                    if self.verbose:
                        cert = archive['links'].upload
                title = archive['archive'].title
                size = archive_size(archive['archive'])
                print "{:03d} {:>6} {:>20} {:>10} {:>10}".format(
                    n+1, size, title, status, cert)
                if self.debug > 2:
                    for doc in archive.itervalues():
                        pyaml.dump(doc, sys.stdout)
                    print
        else:
            print "No available archives."
开发者ID:V-Lamp,项目名称:longaccess-client,代码行数:28,代码来源:command.py


示例3: write_settings_file

 def write_settings_file(self, eps_values):
     eps_values['min_samples'] = self.min_samples
     eps_values['only_core_samples'] = self.only_core_samples
     settingspath = self.pm.blotchfile.parent / 'clustering_settings.yaml'
     settingspath.parent.mkdir(exist_ok=True, parents=True)
     logger.info("Writing settings file at %s", str(settingspath))
     with open(settingspath, 'w') as fp:
         pyaml.dump(eps_values, fp)
开发者ID:michaelaye,项目名称:planet4,代码行数:8,代码来源:dbscan.py


示例4: test_str_style_pick

	def test_str_style_pick(self):
		a = pyaml.dump(data_str_multiline)
		b = pyaml.dump(data_str_multiline, string_val_style='|')
		self.assertEqual(a, b)
		b = pyaml.dump(data_str_multiline, string_val_style='plain')
		self.assertNotEqual(a, b)
		self.assertTrue(pyaml.dump('waka waka', string_val_style='|').startswith('|-\n'))
		self.assertEqual(pyaml.dump(dict(a=1), string_val_style='|'), 'a: 1\n')
开发者ID:AtomicConductor,项目名称:conductor_client,代码行数:8,代码来源:dump.py


示例5: type_diff

def type_diff(a, b):
    s = StringIO.StringIO()
    pyaml.dump(a, s, safe = True)
    a = s.getvalue().splitlines()
    s = StringIO.StringIO()
    pyaml.dump(b, s, safe = True)
    b = s.getvalue().splitlines()
    return '\n'.join(difflib.Differ().compare(a, b))
开发者ID:Elethom,项目名称:UTI-Types,代码行数:8,代码来源:import_types.py


示例6: test_str_style_pick

 def test_str_style_pick(self):
     a = pyaml.dump(data_str_multiline)
     b = pyaml.dump(data_str_multiline, string_val_style="|")
     self.assertEqual(a, b)
     b = pyaml.dump(data_str_multiline, string_val_style="plain")
     self.assertNotEqual(a, b)
     self.assertTrue(pyaml.dump("waka waka", string_val_style="|").startswith("|-\n"))
     self.assertEqual(pyaml.dump(dict(a=1), string_val_style="|"), "a: 1\n")
开发者ID:mk-fg,项目名称:pretty-yaml,代码行数:8,代码来源:dump.py


示例7: test_colons_in_strings

	def test_colons_in_strings(self):
		val1 = {'foo': ['bar:', 'baz', 'bar:bazzo', 'a: b'], 'foo:': 'yak:'}
		val1_str = pyaml.dump(val1)
		val2 = yaml.safe_load(val1_str)
		val2_str = pyaml.dump(val2)
		val3 = yaml.safe_load(val2_str)
		self.assertEqual(val1, val2)
		self.assertEqual(val1_str, val2_str)
		self.assertEqual(val2, val3)
开发者ID:AtomicConductor,项目名称:conductor_client,代码行数:9,代码来源:dump.py


示例8: test_colons_in_strings

 def test_colons_in_strings(self):
     val1 = {"foo": ["bar:", "baz", "bar:bazzo", "a: b"], "foo:": "yak:"}
     val1_str = pyaml.dump(val1)
     val2 = yaml.safe_load(val1_str)
     val2_str = pyaml.dump(val2)
     val3 = yaml.safe_load(val2_str)
     self.assertEqual(val1, val2)
     self.assertEqual(val1_str, val2_str)
     self.assertEqual(val2, val3)
开发者ID:mk-fg,项目名称:pretty-yaml,代码行数:9,代码来源:dump.py


示例9: test_empty_strings

 def test_empty_strings(self):
     val1 = {"key": ["", "stuff", "", "more"], "": "value", "k3": ""}
     val1_str = pyaml.dump(val1)
     val2 = yaml.safe_load(val1_str)
     val2_str = pyaml.dump(val2)
     val3 = yaml.safe_load(val2_str)
     self.assertEqual(val1, val2)
     self.assertEqual(val1_str, val2_str)
     self.assertEqual(val2, val3)
开发者ID:mk-fg,项目名称:pretty-yaml,代码行数:9,代码来源:dump.py


示例10: dump

    def dump(self, data, path):
        """dump data to file
        """

        with open(path, "w") as f:

            if isinstance(data, MergeableDict):
                pyaml.dump(data.convert_to(data), f)
            else:
                pyaml.dump(data, f)
开发者ID:robotice,项目名称:robotice,代码行数:10,代码来源:base.py


示例11: dump

    def dump(self, content, filepath, indent=4):
        """
        Dump settings content to filepath.

        Args:
            content (str): Settings content.
            filepath (str): Settings file location.
        """
        with open(filepath, 'w') as fp:
            pyaml.dump(content, dst=fp, indent=indent)
开发者ID:sveetch,项目名称:boussole,代码行数:10,代码来源:yaml_backend.py


示例12: main

def main(argv=None):
	import argparse
	parser = argparse.ArgumentParser(
		description='Process and dump prettified YAML to stdout.')
	parser.add_argument('path', nargs='?', metavar='path',
		help='Path to YAML to read (default: use stdin).')
	opts = parser.parse_args(argv or sys.argv[1:])

	src = open(opts.path) if opts.path else sys.stdin
	try: data = yaml.load(src)
	finally: src.close()

	pyaml.dump(data, sys.stdout)
开发者ID:chrigl,项目名称:pretty-yaml,代码行数:13,代码来源:__main__.py


示例13: do_list

    def do_list(self):
        """
        Usage: list
        """
        archives = list(self.cache._for_adf('archives').iteritems())

        if len(archives):
            ui.print_archives_header()
            bydate = sorted(archives,
                            key=compose(creation, operator.itemgetter(1)))
            for n, docs in enumerate(bydate):
                fname = docs[0]
                archive = docs[1]
                status = self.cache.archive_status(fname, archive)
                cert = ""
                if status == ArchiveStatus.Completed:
                    status = "COMPLETE"
                    cert = archive['signature'].aid
                elif status == ArchiveStatus.InProgress:
                    status = "IN PROGRESS"
                    if self.verbose:
                        cert = archive['links'].upload
                elif status == ArchiveStatus.Failed:
                    status = "FAILED"
                    if self.verbose:
                        cert = archive['links'].upload
                elif status == ArchiveStatus.Local:
                    status = "LOCAL"
                elif status == ArchiveStatus.Paused:
                    status = "PAUSED"
                else:
                    status = "UNKNOWN"
                title = archive['archive'].title
                size = archive_size(archive['archive'])

                ui.print_archives_line(archive={
                    'num': n+1,
                    'size': size,
                    'title': title,
                    'status': status,
                    'cert': cert,
                    'created': archive['archive'].meta.created,
                    'capsule': archive_capsule(archive) or '-'
                })
                if self.debug > 2:
                    for doc in archive.itervalues():
                        pyaml.dump(doc, sys.stdout)
                    print
            print
        else:
            print "No available archives."
开发者ID:longaccess,项目名称:longaccess-client,代码行数:51,代码来源:command.py


示例14: test_multiple_docs

	def test_multiple_docs(self):
		docs = [yaml.safe_load(large_yaml), dict(a=1, b=2, c=3)]
		docs_str = pyaml.dump_all(docs, vspacing=[3, 2])
		self.assertTrue(docs_str.startswith('---'))
		self.assertIn('---\n\n\n\na: 1\n\n\n\nb: 2\n\n\n\nc: 3\n', docs_str)
		docs_str2 = pyaml.dump(docs, vspacing=[3, 2], multiple_docs=True)
		self.assertEqual(docs_str, docs_str2)
		docs_str2 = pyaml.dump(docs, vspacing=[3, 2])
		self.assertNotEqual(docs_str, docs_str2)
		docs_str2 = pyaml.dump_all(docs, explicit_start=False)
		self.assertFalse(docs_str2.startswith('---'))
		self.assertNotEqual(docs_str, docs_str2)
		docs_str = pyaml.dump(docs, multiple_docs=True, explicit_start=False)
		self.assertEqual(docs_str, docs_str2)
开发者ID:mk-fg,项目名称:pretty-yaml,代码行数:14,代码来源:dump.py


示例15: test_print

	def test_print(self):
		self.assertIs(pyaml.print, pyaml.pprint)
		self.assertIs(pyaml.print, pyaml.p)
		buff = io.BytesIO()
		b = pyaml.dump(data_str_multiline, dst=bytes)
		pyaml.print(data_str_multiline, file=buff)
		self.assertEqual(b, buff.getvalue())
开发者ID:AtomicConductor,项目名称:conductor_client,代码行数:7,代码来源:dump.py


示例16: write

def write():  # pragma: no cover
    global _cache
    yfn = yaml_file_name()
    touch(yfn)
    with open(yfn, "w") as outfile:
        outfile.write(dump(_cache, vspacing=[1, 0]))
    return None
开发者ID:smithfarm,项目名称:ceph-auto-aws,代码行数:7,代码来源:myyaml.py


示例17: test_pyyaml_params

	def test_pyyaml_params(self):
		d = {'foo': 'lorem ipsum ' * 30} # 300+ chars
		for w in 40, 80, 200:
			lines = pyaml.dump(d, width=w, indent=10).splitlines()
			for n, line in enumerate(lines, 1):
				self.assertLess(len(line), w*1.2)
				if n != len(lines): self.assertGreater(len(line), w*0.8)
开发者ID:AtomicConductor,项目名称:conductor_client,代码行数:7,代码来源:dump.py


示例18: to_yaml

 def to_yaml(self):
     """overwrite default DeclarativeBase.to_yaml method because we need to convert MutableDicts first
     """
     node_dict = self.to_dict()
     node_dict["attrs"] = dict(node_dict["attrs"])
     node_dict["system_attrs"] = dict(node_dict["system_attrs"])
     return pyaml.dump(node_dict)
开发者ID:mediatum,项目名称:mediatum,代码行数:7,代码来源:node.py


示例19: writeConfig

  def writeConfig(self):
    """Save the config, all currently loaded modules will be saved to init_modules"""
    self.log.info("Writing config...")

    #Add all of our triggers to a nice little dictionary,
    #So we can write it to a file
    trigs = {}
    for i in self.triggers:
      trigs[i.trigger] = i.send_text

    settings = {
        "bot" : {
          "name": self.bot_name,
          "version": self.bot_version,
          "msg_prefix": self.msg_prefix,
          "cmd_prefix": self.command_prefix,
          "debug_logging": False
        },
        "modules" : {
          "path": self.module_path,
          "load": self.loadedModules
        },
        "triggers": trigs,
        "ai": {
          "model_directory": "models"
        },
        "admins": self.admins
      } 

    self.log.info(settings)
    
    #Write the config in YAML format 
    with open("command-proc.conf", "w") as f:
      f.write(pyaml.dump(settings))
    self.log.info("Written")
开发者ID:FloatingGhost,项目名称:Python-Utilities,代码行数:35,代码来源:commandprocessor.py


示例20: write

 def write(self):
     d = self._serialize()
     s = pyaml.dump(d)
     p = os.path.dirname(self.filename)
     if not os.path.exists(p):
         os.makedirs(p)
     with open(self.filename, 'w') as f:
         f.write(s)
     self._reset_changes()
开发者ID:nocarryr,项目名称:s3-logparser,代码行数:9,代码来源:config.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python anaconda_log.log_method_call函数代码示例发布时间:2022-05-25
下一篇:
Python mrc.write函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap