Guest User

Untitled

a guest
Apr 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. massive=[['cn=Андрей', 'ou=Masters', 'o=lab2', '0b1dwe8065eff78ad92771ef78cc076c'],['cn=Barma', 'ou=Masters', 'o=lab2', '0b1dc48065eff78ad92771ef78cdfgdf']]
  2.  
  3. list1=[['CN=Андрей', 'OU=Masters', 'O=lab2', '0b1dwe8065eff78ad92771ef78cc076c'],['CN=Barmad', 'OU=Masters', 'O=lab2', 'fb1dc48065eff78ad92771ef78cdfgdf']]
  4.  
  5. #!/usr/bin/python
  6. # -*- coding: utf-8 -*-
  7.  
  8.  
  9. def change (massive,list1):
  10. to_del=[]
  11. to_add=[]
  12. for num in list1:
  13. if num not in massive:
  14. to_del.append(num)
  15. for num in massive:
  16. if num not in list1:
  17. to_add.append(num)
  18. return to_add,to_del
  19.  
  20. to_add,to_del=change(massive,list1)
  21. print to_add
  22. print 'n'
  23. print to_del
  24.  
  25. [['cn=xd0x90xd0xbdxd0xb4xd1x80xd0xb5xd0xb9', 'ou=Masters', 'o=lab2', '0b1dwe8065eff78ad92771ef78cc076c'], ['cn=Barma', 'ou=Masters', 'o=lab2', '0b1dc48065eff78ad92771ef78cdfgdf']]
  26.  
  27. [['CN=xd0x90xd0xbdxd0xb4xd1x80xd0xb5xd0xb9', 'OU=Masters', 'O=lab2', '0b1dwe8065eff78ad92771ef78cc076c'], ['CN=Barmad', 'OU=Masters', 'O=lab2', 'fb1dc48065eff78ad92771ef78cdfgdf']]
  28.  
  29. def change(items_1, items_2):
  30. # Для приведения элементов в нижний регистр
  31. items_1 = [list(map(str.lower, sub_list)) for sub_list in items_1]
  32. items_2 = [list(map(str.lower, sub_list)) for sub_list in items_2]
  33.  
  34. to_del = [num for num in items_1 if num not in items_2]
  35. to_add = [num for num in items_2 if num not in items_1]
  36.  
  37. return to_add, to_del
  38.  
  39.  
  40. items_1 = [['cn=Андрей', 'ou=Masters', 'o=lab2', '0b1dwe8065eff78ad92771ef78cc076c'], ['cn=Barma', 'ou=Masters', 'o=lab2', '0b1dc48065eff78ad92771ef78cdfgdf']]
  41. items_2 = [['CN=Андрей', 'OU=Masters', 'O=lab2', '0b1dwe8065eff78ad92771ef78cc076c'], ['CN=Barmad', 'OU=Masters', 'O=lab2', 'fb1dc48065eff78ad92771ef78cdfgdf']]
  42.  
  43. to_add, to_del = change(items_1, items_2)
  44. print 'to_add: %s' % (to_add,)
  45. print 'to_del: %s' % (to_del,)
  46.  
  47. to_add: [['cn=barmad', 'ou=masters', 'o=lab2', 'fb1dc48065eff78ad92771ef78cdfgdf']]
  48. to_del: [['cn=barma', 'ou=masters', 'o=lab2', '0b1dc48065eff78ad92771ef78cdfgdf']]
Add Comment
Please, Sign In to add comment