예제 #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
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
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
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
def SaveYAML(d, file_name, except_cnv=lambda y:y):
  OpenW(file_name).write(yamldump(ToStdType(d,except_cnv), Dumper=YDumper))