My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

46 lignes
1.4 KiB

  1. #!/usr/bin/env python3
  2. # #############################################################################
  3. # natool: a wrapper script to patool to list, extract and create archives
  4. #
  5. # usage: natool [-a] [-l] [-x] [archive] [file/dir]
  6. #
  7. # Examples:
  8. # - create archive : natool -a archive.7z archive_dir
  9. # - list archive : natool -l archive.7z
  10. # - extract archive: natool -x archive.7z
  11. #
  12. # Brief:
  13. # natool is written to integrate patool (instead of the default atool) with nnn
  14. # A copies of this file should be dropped somewhere in $PATH as atool
  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 [-a] [-l] [-x] [archive] [file/dir]')
  25. sys.exit(0)
  26. if sys.argv[1] == '-a':
  27. cmd = ['patool', '--non-interactive', 'create', sys.argv[2]]
  28. cmd.extend(sys.argv[3:])
  29. elif sys.argv[1] == '-l':
  30. cmd = ['patool', '--non-interactive', 'list']
  31. cmd.extend(sys.argv[2:])
  32. elif sys.argv[1] == '-x':
  33. cmd = ['patool', '--non-interactive', 'extract']
  34. cmd.extend(sys.argv[2:])
  35. else:
  36. sys.exit(0)
  37. pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
  38. out, err = pipe.communicate()
  39. print(out.decode())
  40. print(err.decode())