Guest User

Untitled

a guest
Jan 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. import re
  2. import os
  3.  
  4. def _unidiff_output(expected, actual):
  5. """
  6. Helper function. Returns a string containing the unified diff of two multiline strings.
  7. """
  8.  
  9. import difflib
  10. expected=expected.splitlines(1)
  11. actual=actual.splitlines(1)
  12.  
  13. diff=difflib.unified_diff(expected, actual)
  14.  
  15. return ''.join(diff)
  16.  
  17. def return_nix_libraries_list(nix_file_path):
  18. original_content = ""
  19.  
  20. with open(nix_file_path,'r') as nix_file:
  21. nix_file_content = nix_file.read()
  22. #print(nix_file_content)
  23. derivations_list = re.findall(re.compile('\s+pname = "(.*?)";\s+version = "(.*?)";\s+sha256 = "(.*?)";(\s+revision = "(.*?)";)*', re.MULTILINE), nix_file_content)
  24.  
  25. for derivation in derivations_list:
  26.  
  27. pname = derivation[0]
  28. version = derivation[1]
  29. sha256 = derivation[2]
  30. revision = derivation[4]
  31.  
  32. original_content += pname + ', ' + version + ', ' + sha256 + ', ' + revision + os.linesep
  33. #print(pname + ', ' + version + ', ' + sha256 + ', ' + revision)
  34.  
  35. return original_content
  36.  
  37. # _unidiff_output(return_nix_libraries_list('path_to_default.nix'), return_nix_libraries_list('path_to_default.nix'))
Add Comment
Please, Sign In to add comment