aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Timber <dxdt@dev.snart.me>2022-06-02 12:45:14 +0800
committerDavid Timber <dxdt@dev.snart.me>2022-06-02 12:45:14 +0800
commitec43c0e7dc02199fb4c77b89e57791279f4a2622 (patch)
tree7345c5dd55b9f1c2088bb34d15b3f1d821caeee6
parent31e7acb5c965067463f33fa59fc463086a298350 (diff)
Reformat python scripts to PEP 257 docstr
-rw-r--r--src/prne_txtrec.py30
-rwxr-xr-xsrc/proone-txtrec-del.py2
-rwxr-xr-xsrc/proone-txtrec-set.py2
3 files changed, 19 insertions, 15 deletions
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({
diff --git a/src/proone-txtrec-del.py b/src/proone-txtrec-del.py
index 8fadce3..8c02de2 100755
--- a/src/proone-txtrec-del.py
+++ b/src/proone-txtrec-del.py
@@ -59,8 +59,8 @@ HOOK_ERRORS = {
},
}
-# AWS hook main function
def main_aws (zone_id: str, head_rec: str):
+ """AWS hook main function"""
try:
import boto3
except ModuleNotFoundError as e:
diff --git a/src/proone-txtrec-set.py b/src/proone-txtrec-set.py
index cdba79a..4e009ad 100755
--- a/src/proone-txtrec-set.py
+++ b/src/proone-txtrec-set.py
@@ -42,8 +42,8 @@ HOOK_ERRORS = {
}
}
-# AWS hook main function
def main_aws (zone_id: str, head_rec: str, suffix: str, ttl: int):
+ """AWS hook main function"""
if ttl is None:
ttl = 3600