Created
September 28, 2016 15:40
-
-
Save paultopia/81eb0e1364da0ea397de2a485475a2a9 to your computer and use it in GitHub Desktop.
I'm super lazy and want to be able to type, e.g., "gowder pdf test" and have it convert a markdown file to pdf without having to type flags etc. ditto "gowder dropbox test.txt"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import sys | |
| import os | |
| mode = sys.argv[1] | |
| command = sys.argv[2] | |
| def markdown_to_pdf(root_filename): | |
| md_filename = root_filename+".md" | |
| pdf_filename = root_filename+".pdf" | |
| print("converting {0} to {1}".format(md_filename, pdf_filename)) | |
| return "pandoc -o {0} {1}".format(pdf_filename, md_filename) | |
| def upload_to_dropbox(filename): | |
| path = "cli_uploads/{0}".format(filename) | |
| print("uploading to {0}".format(path)) | |
| return "dbxcli put {0} {1}".format(filename, path) | |
| if mode == "pdf": | |
| os.system(markdown_to_pdf(command)) | |
| if mode == "dropbox": | |
| os.system(upload_to_dropbox(command)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment