aboutsummaryrefslogtreecommitdiff
path: root/pyfunkwhale/utils.py
blob: eb6da037e5af2f46f7e6fdf7e4182d33108c2791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json


def read_file(filename):
    """
    Simple wrapper for read a file content

    Parameters
    ----------
    filename : str
        The filename where read the datas
    """
    with open(filename, 'r') as file:
        data = file.read()

    return data


def write_file(filename, datas):
    """
    Simple wrapper for write data in file

    Parameters
    ----------
    filename : str
        The filename where write the datas
    datas : str
        The datas to write in the filename
    """
    with open(filename, 'w') as file:
        file.write(json.dumps(datas))

    return datas