Guest User

Untitled

a guest
Apr 27th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. In []: run txt2pdf.py Results/*.txt
  2. Out []: Writing 'ResultsA_2018_04_27_13_55.txt' with 80 characters per line and
  3. 60 lines per page...
  4. PDF document: 1 pages
  5.  
  6. In [] : run txt2pdf.py Results/*.txt
  7. Out []: usage: txt2pdf.py [-h] [--font FONT] [--font-size FONT_SIZE]
  8. [--extra-vertical-space EXTRA_VERTICAL_SPACE]
  9. [--kerning KERNING] [--media MEDIA]
  10. [--minimum-page-length MINIMUM_PAGE_LENGTH] [--landscape]
  11. [--margin-left MARGIN_LEFT] [--margin-right MARGIN_RIGHT]
  12. [--margin-top MARGIN_TOP] [--margin-bottom MARGIN_BOTTOM]
  13. [--output OUTPUT] [--author AUTHOR] [--title TITLE]
  14. [--quiet] [--subject SUBJECT] [--keywords KEYWORDS]
  15. [--break-on-blanks] [--encoding ENCODING] [--page-numbers]
  16. [--line-numbers]
  17. filename
  18. txt2pdf.py: error: unrecognized arguments: ResultsA_2018_04_27_13_57.txt
  19. An exception has occurred, use %tb to see the full traceback.
  20. SystemExit: 2
  21.  
  22. ./txt2pdf.py Results/first_file.txt
  23.  
  24. ./txt2pdf.py Results/first_file.txt Results/second_file.txt
  25.  
  26. import sh
  27. from glob import glob
  28. import os
  29.  
  30. # commenting line by line
  31. def get_last_txt(path):
  32. return sorted( # sort
  33. glob(path + '/*.txt'), # all files in the folder
  34. key=lambda f: os.stat(f).st_mtime # by modified time
  35. )[-1] # return the last one
  36.  
  37. sh.python('txt2pdf.py', get_last_txt("Results"))
Add Comment
Please, Sign In to add comment