From 941f65f89e542af37eaa6c8195bc0eda57999da3 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Fri, 20 Jul 2018 07:03:54 +0200 Subject: Add vyos.util.read_file() function. Really, how many times can we write the same thing. --- python/vyos/util.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'python/vyos/util.py') diff --git a/python/vyos/util.py b/python/vyos/util.py index 531cd8182..3d9925a60 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -16,6 +16,11 @@ import re import psutil +def read_file(path): + """ Read a file to string """ + with open(path, 'r') as f: + data = f.read().strip() + return data def colon_separated_to_dict(data_string, uniquekeys=False): """ Converts a string containing newline-separated entries -- cgit v1.2.3