From 2087ca6922558d3dc11d68e41d4e6298a90247c8 Mon Sep 17 00:00:00 2001 From: LukasK13 Date: Mon, 18 May 2020 10:56:38 +0200 Subject: [PATCH] check_path() added --- esbo_etc/classes/Entry.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/esbo_etc/classes/Entry.py b/esbo_etc/classes/Entry.py index 9f8eb00..c331252 100644 --- a/esbo_etc/classes/Entry.py +++ b/esbo_etc/classes/Entry.py @@ -134,6 +134,25 @@ class Entry(object): if not os.path.isfile(getattr(self, name)): return "File '" + getattr(self, name) + "' does not exist." + def check_path(self, name) -> Union[None, str]: + """ + Check a parameter to be a valid path to a file. + + Parameters + ---------- + name : str + The name of the parameter to be checked. + + Returns + ------- + mes : Union[None, str] + The error message of the check. This will be None if the check was successful. + """ + if not hasattr(self, name): + return "Parameter '" + name + "' not found." + if not os.path.isdir(getattr(self, name)): + return "Path '" + getattr(self, name) + "' does not exist." + def check_float(self, name) -> Union[None, str]: """ Check a parameter to be a floating point value