profile.py 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env python3
  2. # vim: set fileencoding=utf-8
  3. """Define WiFi Profile."""
  4. from .const import *
  5. class Profile():
  6. def __init__(self):
  7. self.id = 0
  8. self.auth = AUTH_ALG_OPEN
  9. self.akm = [AKM_TYPE_NONE]
  10. self.cipher = CIPHER_TYPE_NONE
  11. self.ssid = None
  12. self.bssid = None
  13. self.key = None
  14. def process_akm(self):
  15. if len(self.akm) > 1:
  16. self.akm = self.akm[-1:]
  17. def __eq__(self, profile):
  18. if profile.ssid:
  19. if profile.ssid != self.ssid:
  20. return False
  21. if profile.bssid:
  22. if profile.bssid != self.bssid:
  23. return False
  24. if profile.auth:
  25. if profile.auth!= self.auth:
  26. return False
  27. if profile.cipher:
  28. if profile.cipher != self.cipher:
  29. return False
  30. if profile.akm:
  31. if set(profile.akm).isdisjoint(set(self.akm)):
  32. return False
  33. return True