My build of nnn with minor changes
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

43 rindas
1.3 KiB

  1. #!/usr/bin/env python3
  2. # #############################################################################
  3. # natool: a wrapper script to patool to list, extract and create archives
  4. #
  5. # usage: natool [-l] [-x] [archive] [file/dir]
  6. #
  7. # Examples:
  8. # - list archive : natool -l archive.7z
  9. # - extract archive: natool -x archive.7z
  10. # - create archive : natool archive.7z archive_dir
  11. #
  12. # Brief:
  13. # natool is written to integrate patool (instead of the default atool) with nnn
  14. # Two copies of this file should be dropped somewhere in $PATH - atool, apack
  15. #
  16. # Author: Arun Prakash Jana
  17. # Email: engineerarun@gmail.com
  18. # Homepage: https://github.com/jarun/nnn
  19. # Copyright © 2019 Arun Prakash Jana
  20. # #############################################################################
  21. import sys
  22. from subprocess import Popen, PIPE, DEVNULL
  23. if len(sys.argv) < 3:
  24. print('usage: natool [-l] [-x] [archive] [file/dir]')
  25. sys.exit(0)
  26. if sys.argv[1] == '-x':
  27. cmd = ['patool', '--non-interactive', 'extract']
  28. elif sys.argv[1] == '-l':
  29. cmd = ['patool', '--non-interactive', 'list']
  30. else:
  31. cmd = ['patool', '--non-interactive', 'create', sys.argv[1]]
  32. cmd.extend(sys.argv[2:])
  33. pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
  34. out, err = pipe.communicate()
  35. print(out.decode())
  36. print(err.decode())