commotion_client.utils.validate.Networking Class Reference
Inheritance diagram for commotion_client.utils.validate.Networking:

Public Member Functions

def __init__
 
def ipaddr
 

Public Attributes

 log
 
 translate
 

Member Function Documentation

def commotion_client.utils.validate.Networking.ipaddr (   self,
  ip_addr,
  addr_type = None 
)
Checks if a string is a validly formatted IPv4 or IPv6 address.

@param ip str A ip address to be checked
@param addr_type int The appropriate version number: 4 for IPv4, 6 for IPv6.

References commotion_client.GUI.menu_bar.MenuBar.translate, commotion_client.extensions.config_editor.main.ViewPort.translate, commotion_client.GUI.main_window.MainWindow.translate, commotion_client.GUI.toolbar_builder.ToolBar.translate, commotion_client.utils.validate.ClientConfig.translate, commotion_client.GUI.extension_toolbar.ExtensionToolBar.translate, commotion_client.GUI.toolbar.ToolBar.translate, commotion_client.utils.extension_manager.ExtensionManager.translate, commotion_client.GUI.extension_toolbar.MenuItem.translate, commotion_client.commotion_client.CommotionClientApplication.translate, commotion_client.utils.validate.Networking.translate, and commotion_client.utils.extension_manager.ConfigManager.translate.

324  def ipaddr(self, ip_addr, addr_type=None):
325  """
326  Checks if a string is a validly formatted IPv4 or IPv6 address.
327 
328  @param ip str A ip address to be checked
329  @param addr_type int The appropriate version number: 4 for IPv4, 6 for IPv6.
330  """
331  try:
332  addr = ipaddress.ip_address(str(ip_addr))
333  except ValueError:
334  self.log.warning(self.translate("logs", "The value {0} is not an validly formed IP-address.").format(ip_addr))
335  return False
336  if addr_type:
337  if addr.version == addr_type:
338  return True
339  else:
340  self.log.warning(self.translate("logs", "The value {0} is not an validly formed IPv{1}-address.").format(ip_addr, addr_type))
341  return False
342  else:
343  return True
translate
Definition: validate.py:321
def ipaddr
Definition: validate.py:323

The documentation for this class was generated from the following file:
  • commotion_client/utils/validate.py