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
from functools import wraps | |
import sys | |
def with_argv(fn): | |
"""Decorator that wraps your 'main' function, giving it some automatic behaviour. | |
The resulting function should not be passed any args. | |
Command line arguments are interpreted as follows: | |
The first argument is the program name, it is dropped (you can still access it with sys.argv[0]). | |
If an argument has form '--key=value', main's kwargs are updated |
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
""" | |
A python library of constants and utility functions for using ANSI terminal escapes. | |
Example usage: | |
>>> import escapes as e | |
>>> print e.FORECOLOUR(e.RED) + "this is red" + e.UNFORMAT | |
""" | |
ESC = "\033" # escape character for terminal | |
CSI = ESC + "[" # Control Sequence Initiator |
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
""" | |
A gevent-based script that copies input to output, but interrupts every second to paint the current time at the top of the screen. | |
May change the time format with an optional argument. | |
Time format is as per the date(1) command, as well as the following escapes: | |
\e -> ESC character | |
\t -> Tab | |
\\ -> Literal \ | |
For example, you could color your time output bold blue with the argument '\e[1;34m%X\e[m' |
NewerOlder