From 3b25a2659675e30d6308c764f79d80bddae881ba Mon Sep 17 00:00:00 2001 From: Stephanie Merritt Date: Tue, 14 May 2024 12:43:34 +0000 Subject: [PATCH] docstrings --- src/adler/utilities/AdlerCLIArguments.py | 2 +- src/adler/utilities/adler_logging.py | 26 +++++++++++++++++++ src/adler/utilities/readin_utilities.py | 16 ++++++++++++ .../adler/utilities/test_readin_utilities.py | 1 + 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/adler/utilities/AdlerCLIArguments.py b/src/adler/utilities/AdlerCLIArguments.py index 4b741ff..80e0481 100644 --- a/src/adler/utilities/AdlerCLIArguments.py +++ b/src/adler/utilities/AdlerCLIArguments.py @@ -8,7 +8,7 @@ class AdlerCLIArguments: """ Class for storing abd validating Adler command-line arguments. - Attributes: + Attributes ----------- args : argparse.Namespace object argparse.Namespace object created by calling parse_args(). diff --git a/src/adler/utilities/adler_logging.py b/src/adler/utilities/adler_logging.py index d885c79..e138032 100644 --- a/src/adler/utilities/adler_logging.py +++ b/src/adler/utilities/adler_logging.py @@ -10,6 +10,32 @@ def setup_adler_logging( log_file_info="adler.log", log_file_error="adler.err", ): + """Sets up two logs for Adler: info, which logs everything, and error, which logs warnings and errors. + + Parameters + ----------- + log_location : string + Filepath to directory in which to save logs. + + log_format : string, optional + Format for log filename. + Default = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s " + + log_name : string, optional + Name of log. Default = "" + + log_file_info : string, optional + Name with which to save info log. Default = "adler.log" + + log_file_error : string, optional + Name with which to save error log. Default = "adler.err" + + Returns + ---------- + log : logging object + Log object. + """ + log = logging.getLogger(log_name) log_formatter = logging.Formatter(log_format) diff --git a/src/adler/utilities/readin_utilities.py b/src/adler/utilities/readin_utilities.py index b41b4e1..ed5b6d8 100644 --- a/src/adler/utilities/readin_utilities.py +++ b/src/adler/utilities/readin_utilities.py @@ -4,6 +4,22 @@ def read_in_SSObjectID_file(readin_path): + """Reads in a list of SSOIDs from a text file and performs basic validation. + + Parameters + ----------- + + readin_path : str + String containing filepath to text file. + + + Returns + ----------- + ssoid_list : list + A list of SSOIDs. + + """ + with open(readin_path) as f: ssoid_list = f.read().splitlines() diff --git a/tests/adler/utilities/test_readin_utilities.py b/tests/adler/utilities/test_readin_utilities.py index 14ac3cc..a47311d 100644 --- a/tests/adler/utilities/test_readin_utilities.py +++ b/tests/adler/utilities/test_readin_utilities.py @@ -4,6 +4,7 @@ def test_read_in_SSObjectID_file(): + from adler.utilities.readin_utilities import read_in_SSObjectID_file good_ssoids = read_in_SSObjectID_file(get_test_data_filepath("test_SSOIDs.txt"))