-
-
Save m-butterfield/13e48e7e508600ddef9d to your computer and use it in GitHub Desktop.
This file contains 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 python | |
""" | |
dumb | |
this is pretty dumb | |
Usage: | |
dumb <file_name> | |
Options: | |
-h --help Show this screen. | |
""" | |
import time | |
import os | |
import sys | |
from blessings import Terminal | |
from docopt import docopt | |
SLEEPTIME = 0.07 | |
def main(file_name): | |
lines = _get_lines(file_name) | |
term = Terminal() | |
while True: | |
for i in range(len(lines)): | |
with term.fullscreen(): | |
_print_data(i, lines) | |
time.sleep(SLEEPTIME) | |
def _print_data(index, lines): | |
screen = '' | |
for i, line in enumerate(lines): | |
if i == index - 1: | |
screen += " " | |
elif i == index: | |
screen += " " | |
elif i == index + 1: | |
screen += " " | |
screen += line | |
print screen | |
def _get_lines(file_name): | |
with open(file_name) as fp: | |
return fp.readlines() | |
if __name__ == '__main__': | |
args = docopt(__doc__) | |
file_name = args['<file_name>'] | |
if not os.path.exists(file_name): | |
print "Error: file: " + file_name + " does not exist" | |
sys.exit(1) | |
main(file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment