SHARE
TWEET

Untitled

a guest Jul 21st, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2.  
  3. import os
  4. from subprocess import Popen, PIPE
  5.  
  6. proc = Popen(
  7.     ["xsel", "-o", "-b"], stdout=PIPE
  8. )
  9. linesep = bytes(os.linesep, encoding="UTF-8")
  10. stdout, _ = proc.communicate()
  11. lines = stdout.split(linesep)
  12.  
  13. blen = 0
  14. out = []
  15.  
  16. if lines:
  17.     for line in lines:
  18.         blen = max(blen, len(line))
  19.  
  20.     for line in lines:
  21.         flen = blen - len(line)
  22.         out.append(line + (b" " * flen))
  23.  
  24.     proc = Popen(
  25.         ["xsel", "-i", "-b"], stdin=PIPE
  26.     )
  27.     proc.communicate(linesep.join(out))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top