From 18e123258780f6aba3ce4667bb66dcd954392a7f Mon Sep 17 00:00:00 2001 From: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> Date: Sat, 3 Jul 2021 12:55:18 -0600 Subject: [PATCH] Allow list of domains and fix path issue. (#51) --- log_change.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/log_change.py b/log_change.py index 2f70bea619..219db4e306 100644 --- a/log_change.py +++ b/log_change.py @@ -174,9 +174,15 @@ def isdate(string): def isdomain(string): ''' Returns a bool after checking whether the input string meets the - requirements for a date string: YYYYMMDDHH. ''' - - return string.lower() in [d.lower() for d in DOMAINS] + requirements for a domain, or list of domains ''' + + string_list = [i.strip("[]\"', ") for i in string.split(',')] + domains = [d.lower() for d in DOMAINS] + for s in string_list: + if s.lower() not in domains: + print(f'{s} is not a valid domain') + return False + return True def load_externals(ext_path="Externals.cfg"): @@ -230,7 +236,7 @@ def logit(logfile, tmpfile): # Create a logfile backup just in case. Make it a hidden file. # Won't remove this one in the script in case something goes # wrong. - path, fname = os.path.abspath(logfile), os.path.basename(logfile) + path, fname = os.path.dirname(logfile), os.path.basename(logfile) shutil.copy(logfile, os.path.join(path, f".{fname}._bk")) # Write the contents of the logfile to the tempfile for reverse