Outputs a limited file tree rooted at the current directory which highlights the position of the argument within the tree. Originally intended for FZF like so:
fzf --preview 'ptf.py {}'
Screenshot:
#!/usr/bin/env python | |
import os | |
import sys | |
import subprocess | |
from fnmatch import fnmatch | |
from multiprocessing import Process, Queue | |
from Queue import Empty as QEmpty |
class MethodSplitView(object): | |
""" | |
A flexible class for splitting handling of different HTTP methods being | |
dispatched to the same view into seperate class methods. Subclasses may | |
define a separate class method for each HTTP method the view handles (e.g. | |
GET(self, request, ...), POST(self, request, ...) which will be called with | |
the usual view signature when that sort of reqeust is made. | |
Subclasses may also define a `pre_method_check` method which, if it returns | |
a HttpResponse, will be used to response to the request instead of |
import urllib2 | |
import time | |
from collections import defaultdict | |
def run_mr(mapf, reducef, data): | |
intr = defaultdict(list) | |
final = [] | |
def emitIntr(key, value): | |
intr[key].append(value) |
{ | |
"_META": { | |
"year": 2001, | |
"source": "https://files.taxfoundation.org/20210217114725/State-Individual-Income-Tax-Rates-and-Brackets-for-2021.pdf", | |
"updates_and_fixes": "https://gist.github.com/Lanny/cfb412dba213b59c7c74d7b940e77e3f", | |
"description": "Extraction of taxfoundation.org's info on 2021 US state income taxes into JSON for automatic processing. Tax brackets are expressed as 2-tuples of incomeat the bottom of the bracket, and tax rate within that bracket (as apercentage)." | |
}, | |
"DATA": { | |
"AL": { | |
"BRACKETS": { |
def get_pallet(scheme = 'dark', intensity = 'hard'): | |
if scheme not in ('dark', 'light'): | |
raise RuntimeError('Schme must be one of "dark", "light".') | |
if intensity not in ('hard', 'medium', 'soft'): | |
raise RuntimeError('Intensity must be one of "hard", "medium", "soft".') | |
pallet = None | |
if scheme == 'dark': | |
pallet = { | |
'fg': '#d3c6aa', |