Esempio n. 1
0
def read_text(file):
    file = check_path(file)
    with open(file, 'rt') as f:
        lines = f.readlines()
    return lines
Esempio n. 2
0
 def test_to_string(self, make_path, new_type):
     path_old = make_path
     path_new = check_path(path_old, new_type)
     assert (isinstance(path_new, new_type))
Esempio n. 3
0
def write_json(file, dictionary):
    file = check_path(file, str)
    with open(file, 'wt') as f:
        json.dump(dictionary, f)
Esempio n. 4
0
def read_json(file):
    file = check_path(file, str)
    with open(file, 'rt') as f:
        json_dict = json.load(f)
    return json_dict
Esempio n. 5
0
def write_yaml(file, dictionary):
    file = check_path(file, str)
    with open(file, 'wt') as f:
        yaml.safe_dump(dictionary, f)
Esempio n. 6
0
def read_yaml(file):
    file = check_path(file, str)
    with open(file, 'rt') as f:
        yaml_dict = yaml.safe_load(f)
    return yaml_dict
Esempio n. 7
0
def write_text(file, lines, mode='wt'):
    file = check_path(file, str)
    with open(file, mode) as f:
        f.writelines(lines)