summaryrefslogtreecommitdiff
path: root/argparse_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-07-08 22:25:12 -0700
committerScott Gasch <[email protected]>2021-07-08 22:25:12 -0700
commit11eeb8574b7b4620ac6fd440cb251f8aa2458f5b (patch)
tree97f8e64eddd4528b01af58df269427814b889929 /argparse_utils.py
parente516059c716537259c601c022cc3bad44025385e (diff)
Reduce import scopes, remove cycles.
Diffstat (limited to 'argparse_utils.py')
-rw-r--r--argparse_utils.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/argparse_utils.py b/argparse_utils.py
index 80046de..02db0f0 100644
--- a/argparse_utils.py
+++ b/argparse_utils.py
@@ -5,8 +5,6 @@ import datetime
import logging
import os
-import string_utils
-
logger = logging.getLogger(__name__)
@@ -58,11 +56,13 @@ class ActionNoYes(argparse.Action):
def valid_bool(v):
if isinstance(v, bool):
return v
- return string_utils.to_bool(v)
+ from string_utils import to_bool
+ return to_bool(v)
def valid_ip(ip: str) -> str:
- s = string_utils.extract_ip_v4(ip.strip())
+ from string_utils import extract_ip_v4
+ s = extract_ip_v4(ip.strip())
if s is not None:
return s
msg = f"{ip} is an invalid IP address"
@@ -71,7 +71,8 @@ def valid_ip(ip: str) -> str:
def valid_mac(mac: str) -> str:
- s = string_utils.extract_mac_address(mac)
+ from string_utils import extract_mac_address
+ s = extract_mac_address(mac)
if s is not None:
return s
msg = f"{mac} is an invalid MAC address"
@@ -99,7 +100,8 @@ def valid_filename(filename: str) -> str:
def valid_date(txt: str) -> datetime.date:
- date = string_utils.to_date(txt)
+ from string_utils import to_date
+ date = to_date(txt)
if date is not None:
return date
msg = f'Cannot parse argument as a date: {txt}'
@@ -108,7 +110,8 @@ def valid_date(txt: str) -> datetime.date:
def valid_datetime(txt: str) -> datetime.datetime:
- dt = string_utils.to_datetime(txt)
+ from string_utils import to_datetime
+ dt = to_datetime(txt)
if dt is not None:
return dt
msg = f'Cannot parse argument as datetime: {txt}'