Example #1
0
 def test_saveload_json(self):
     filename = "tmp_json_file"
     obj_init =[u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
     tools.savejson(filename, obj_init)
     obj_read = tools.loadjson(filename)
     self.assertEqual(obj_read, obj_init)
     os.remove(filename)
Example #2
0
    def test_save(self):
        # Fill a ParamObj with a random dictionary
        name = 'm' + str(uuid.uuid4().get_hex()[0:6])
        param = tools.ParameterObj(name)

        keys = ['k' + str(uuid.uuid4().get_hex()[0:6]) for i in range(1, 10)]
        values = ['v' + str(uuid.uuid4().get_hex()[0:6]) for i in range(1, 10)]
        dic = dict(zip(keys, values))

        param.update(dic)

        # Save the object dictionary to file
        file_name = 'f' + str(uuid.uuid4().get_hex()[0:6])
        param.save(file_name)

        # Read back the file
        from seisflows.tools.code import loadjson
        read_dic = loadjson(file_name)

        self.assertEqual(dic, read_dic)
        os.remove(file_name)
Example #3
0
 def reload(self, path):
     fullfile = join(path, 'SeisflowsPaths.json')
     mydict = loadjson(fullfile)
     self.update(mydict)