A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| #!/usr/bin/env python | |
| __author__ = "github.com/ruxi" | |
| __license__ = "MIT" | |
| import requests | |
| import tqdm # progress bar | |
| import os.path | |
| def download_file(url, filename=False, verbose = False): | |
| """ | |
| Download file with progressbar | |
| # Rename all *.fasta to *.sra | |
| for f in *.fasta; do | |
| mv -- "$f" "${f%.fasta}.sra" | |
| done |
| #!/usr/bin/env python | |
| from __future__ import print_function | |
| __author__ = 'github.com/ruxi' | |
| __license__= 'MIT' | |
| import sys | |
| import os.path | |
| import subprocess | |
| def runbash(cmd, cwd=".", shell=True, logname="runbash.log", ioprint=True): | |
| """ | |
| cmd: bash command to run. example: 'ls -l' |
| from contextlib import contextmanager | |
| import sys, os | |
| @contextmanager | |
| def suppress_stdout(): | |
| with open(os.devnull, "w") as devnull: | |
| old_stdout = sys.stdout | |
| sys.stdout = devnull | |
| try: | |
| yield |
| from contextlib import contextmanager | |
| import sys, os | |
| @contextmanager | |
| def suppress_stdout(): | |
| """ | |
| source: https://gist.github.com/djsmith42/3956189 | |
| usage: | |
| print "You can see this" | |
| with suppress_stdout(): |
| 0x0E62556027f7371DA69001b7331039A42D0EB63C |