コード例 #1
0
def write_yaml(path, dictionary):
    """ Writes a dictionary to a file in .yaml format.

    Parameters
    ----------
    path: :obj:`str`
        Location to where the .yaml should be written.
    dictionary: :obj:`dict`
        Dictionary that should be stored in the file."""
    with open(path) as f:
        yamldump(dictionary, f)
コード例 #2
0
def Main():
    database = []
    fp = open('/tmp/data1.yaml', 'w')
    for i in range(10):
        data = {}
        data['a'] = [i, i * i, i * i * i]
        data['b'] = [str(i), str(i * i)]

        database.append(data)
        fp.write(yamldump([data], Dumper=Dumper))
        fp.flush()
    fp.close()

    open('/tmp/data2.yaml', 'w').write(yamldump(database, Dumper=Dumper))
コード例 #3
0
    def dump(self, ordoc):
        """Return a string yaml formated native Open Rocket Doc
        """

        # We want some control over what is printed
        # (not a naive dump of everything in every object)
        # So we build a dictionary first

        doc = {}

        # rocket top level
        if type(ordoc) is rdoc.Rocket:
            doc['rocket'] = {'name': ordoc.name}
            if ordoc.description:
                doc['rocket']['description'] = ordoc.description
            if ordoc.manufacturer:
                doc['rocket']['manufacturer'] = ordoc.manufacturer
            doc['rocket']['aerodynamics'] = ordoc.aero_properties

            doc['rocket']['stages'] = []
            for stage in ordoc.stages:
                s = {'name': stage.name}
                s['components'] = []
                for component in stage.components:
                    s['components'].append(self._component_dict(component))
                doc['rocket']['stages'].append(s)

        return yamldump(doc, default_flow_style=False)
コード例 #4
0
ファイル: io.py プロジェクト: sjforeman/draco
    def setup(self):
        """Save module versions."""

        fname = "{}_config.yml".format(self.root)
        f = open(fname, "w")
        f.write(yamldump(self.pipeline_config))
        f.close()
        self.done = True
コード例 #5
0
ファイル: fsestimate.py プロジェクト: farseerfc/dotfiles
def output_fs_estimate(data):
    fs = [
        Stats(),
        Fat32(),
        ExFat(),
        UnixFS(),
        Ext2FS(),
        F2FS(),
        FFS(),
        Ext4FS()
    ]
    for i in data:
        for f in fs:
            f.fallocate(i)
    pdict = OrderedDict()
    for f in fs:
        pdict[f'{f}'] = f.to_dict()
    #pprint(pdict, indent=4, width=os.get_terminal_size().columns)
    print(yamldump(pdict, width=os.get_terminal_size().columns))
コード例 #6
0
ファイル: base_util.py プロジェクト: akihikoy/lfd_trick
def SaveYAML(d, file_name, except_cnv=lambda y:y):
  OpenW(file_name).write(yamldump(ToStdType(d,except_cnv), Dumper=YDumper))
コード例 #7
0
ファイル: util.py プロジェクト: yashimar/ay_py
def SaveYAML(d, file_name, except_cnv=lambda y:y, interactive=True):
  OpenW(file_name,interactive=interactive).write(yamldump(ToStdType(d,except_cnv), Dumper=YDumper))
コード例 #8
0
ファイル: dnn_cls1.py プロジェクト: elevenjiang1/ay_test
def SaveYAML(d, file_name, except_cnv=lambda y: y):
    file(file_name,
         'w').write(yamldump(ToStdType(d, except_cnv), Dumper=Dumper))
コード例 #9
0
def write_back_yaml(data, filename):
    with open(filename, 'w') as output_yaml:
        yamldump(data, output_yaml)
コード例 #10
0
ファイル: util.py プロジェクト: akihikoy/ay_py
def GetSHA1HashOfDict(d):
    d_yaml = yamldump(d, Dumper=YDumper)
    return hashlib.sha1(d_yaml).hexdigest()
コード例 #11
0
ファイル: base_util.py プロジェクト: davidqiu1993/catapult
def SaveYAML(d, file_name, except_cnv=lambda y:y):
  OpenW(file_name).write(yamldump(ToStdType(d,except_cnv), Dumper=YDumper))