From ec43c0e7dc02199fb4c77b89e57791279f4a2622 Mon Sep 17 00:00:00 2001 From: David Timber Date: Thu, 2 Jun 2022 12:45:14 +0800 Subject: Reformat python scripts to PEP 257 docstr --- src/prne_txtrec.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/prne_txtrec.py') diff --git a/src/prne_txtrec.py b/src/prne_txtrec.py index a432f67..6951805 100644 --- a/src/prne_txtrec.py +++ b/src/prne_txtrec.py @@ -23,32 +23,36 @@ from typing import Iterable # AWS hook - The max number of objects in a request AWS_MAX_ITEMS = 1000 -## Handle error according to the error definition -# @param o the error definition -# @param e the exception (optional) -# @param m the error message header, perror() param equiv (optional) -# @note The function will call \c exit() if the error definition dictates to do -# so -def handle_err (o, e, m): +def handle_err (o: dict, e, m: str): + """Handle error according to the error definition + + The function will call exit() if the error definition dictates to do so + + Parameters: + o: the error definition + e: the exception (optional) + m: the error message header, perror() param equiv (optional) + """ if e: - sys.stderr.write(e + "\n\n") + sys.stderr.write(str(e) + "\n\n") if m: l = m + ": " + o["msg"] + "\n" else: l = o["msg"] + "\n" - sys.stderr.write(l) - if "ec" in o: - exit(o["ec"]) -## Append a dot(".") to the string if it does not end with the dot + ec = o.get("ec", None) + if ec is not None: + exit(ec) + def termdot (str: str): + """Append a dot(".") to the string if it does not end with the dot""" if not str.endswith("."): return str + "." return str -# Change all RRs specified in the iterable def change_all (client, zone_id: str, action: str, it: Iterable): + """Change all RRs specified in the iterable""" c_arr = [] for rr in it: c_arr.append({ -- cgit