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


Python pyaml.dump函数代码示例

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


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


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