replace logging.info with logging.debug for unimportant loggings, change the functions inside type checking class into classmethods

This commit is contained in:
Huy Pham 2020-02-03 07:30:25 -08:00
parent 6c89ba1abb
commit 5dd379a2ee
4 changed files with 35 additions and 14 deletions

View file

@ -31,7 +31,8 @@ class InputValidation:
self.rgb = self.master.register(self.check_rbg)
self.hex = self.master.register(self.check_hex)
def ip_focus_out(self, event: tk.Event):
@classmethod
def ip_focus_out(cls, event: tk.Event):
value = event.widget.get()
try:
IPNetwork(value)
@ -39,12 +40,14 @@ class InputValidation:
event.widget.delete(0, tk.END)
event.widget.insert(tk.END, "invalid")
def focus_out(self, event: tk.Event, default: str):
@classmethod
def focus_out(cls, event: tk.Event, default: str):
value = event.widget.get()
if value == "":
event.widget.insert(tk.END, default)
def check_positive_int(self, s: str) -> bool:
@classmethod
def check_positive_int(cls, s: str) -> bool:
if len(s) == 0:
return True
try:
@ -55,7 +58,8 @@ class InputValidation:
except ValueError:
return False
def check_positive_float(self, s: str) -> bool:
@classmethod
def check_positive_float(cls, s: str) -> bool:
if len(s) == 0:
return True
try:
@ -66,7 +70,8 @@ class InputValidation:
except ValueError:
return False
def check_node_name(self, s: str) -> bool:
@classmethod
def check_node_name(cls, s: str) -> bool:
if len(s) < 0:
return False
if len(s) == 0:
@ -76,7 +81,8 @@ class InputValidation:
return False
return True
def check_canvas_int(self, s: str) -> bool:
@classmethod
def check_canvas_int(cls, s: str) -> bool:
if len(s) == 0:
return True
try:
@ -87,7 +93,8 @@ class InputValidation:
except ValueError:
return False
def check_canvas_float(self, s: str) -> bool:
@classmethod
def check_canvas_float(cls, s: str) -> bool:
if not s:
return True
try:
@ -98,7 +105,8 @@ class InputValidation:
except ValueError:
return False
def check_ip4(self, s: str) -> bool:
@classmethod
def check_ip4(cls, s: str) -> bool:
if not s:
return True
pat = re.compile("^([0-9]+[.])*[0-9]*$")
@ -117,7 +125,8 @@ class InputValidation:
else:
return False
def check_rbg(self, s: str) -> bool:
@classmethod
def check_rbg(cls, s: str) -> bool:
if not s:
return True
if s.startswith("0") and len(s) >= 2:
@ -131,7 +140,8 @@ class InputValidation:
except ValueError:
return False
def check_hex(self, s: str) -> bool:
@classmethod
def check_hex(cls, s: str) -> bool:
if not s:
return True
pat = re.compile("^([#]([0-9]|[a-f])+)$|^[#]$")