summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-07-20 07:03:54 +0200
committerDaniil Baturin <daniil@baturin.org>2018-07-20 07:03:54 +0200
commit941f65f89e542af37eaa6c8195bc0eda57999da3 (patch)
treedd210f6f4823c57835a49ac3ce9fc99e72fb510c /python/vyos/util.py
parent2a7f374f8a3ddf4a31ab88087912f19889c75a94 (diff)
downloadvyos-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/util.py')
-rw-r--r--python/vyos/util.py5
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