diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-07-20 07:03:54 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-07-20 07:03:54 +0200 |
commit | 941f65f89e542af37eaa6c8195bc0eda57999da3 (patch) | |
tree | dd210f6f4823c57835a49ac3ce9fc99e72fb510c /python/vyos | |
parent | 2a7f374f8a3ddf4a31ab88087912f19889c75a94 (diff) | |
download | vyos-1x-941f65f89e542af37eaa6c8195bc0eda57999da3.tar.gz vyos-1x-941f65f89e542af37eaa6c8195bc0eda57999da3.zip |
Add vyos.util.read_file() function.
Really, how many times can we write the same thing.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/util.py | 5 |
1 files changed, 5 insertions, 0 deletions
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 |