Skip to content

Instantly share code, notes, and snippets.

@m-butterfield
Last active September 16, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-butterfield/13e48e7e508600ddef9d to your computer and use it in GitHub Desktop.
Save m-butterfield/13e48e7e508600ddef9d to your computer and use it in GitHub Desktop.
#!/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