Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import argparse
- import time
- import sys
- import os
- # Author MD Harrington facebook https://www.facebook.com/mark.harrington.142892 links to this there as well for you
- # code that prinst a text file to console with colous set on chars in slow motion type writer effect
- # usage :: python.py <yourfile.txt>
- # global colour settings
- # python version Python 2.7.14
- CBLACK = '\33[30m'
- CRED = '\33[31m'
- CGREEN = '\33[32m'
- CYELLOW = '\33[33m'
- CBLUE = '\33[34m'
- CVIOLET = '\33[35m'
- CBEIGE = '\33[36m'
- CWHITE = '\33[37m'
- CYAN = "\033[1;36m"
- CBLACKBG = '\33[40m'
- CREDBG = '\33[41m'
- CGREENBG = '\33[42m'
- CYELLOWBG = '\33[43m'
- CBLUEBG = '\33[44m'
- CVIOLETBG = '\33[45m'
- CBEIGEBG = '\33[46m'
- CWHITEBG = '\33[47m'
- CGREY = '\33[90m'
- CRED2 = '\33[91m'
- CGREEN2 = '\33[92m'
- CYELLOW2 = '\33[93m'
- CBLUE2 = '\33[94m'
- CVIOLET2 = '\33[95m'
- CBEIGE2 = '\33[96m'
- CWHITE2 = '\33[97m'
- CGREYBG = '\33[100m'
- CREDBG2 = '\33[101m'
- CGREENBG2 = '\33[102m'
- CYELLOWBG2 = '\33[103m'
- CBLUEBG2 = '\33[104m'
- CVIOLETBG2 = '\33[105m'
- CBEIGEBG2 = '\33[106m'
- CWHITEBG2 = '\33[107m'
- ENDC = '\033[0m'
- parser = argparse.ArgumentParser(description='Open file .')
- parser.add_argument('v1', type = str , help='imput your file to be opened')
- args=parser.parse_args();
- m_file = args.v1
- def f_clearscreen(time_delay):
- os.system('clear')
- time.sleep(time_delay)
- for x in range(3):
- print('')
- def f_openfile(fileopen):
- # make this global so that functions can see this
- global lines
- f = open(fileopen, "r")
- # use readlines to read all lines in the file
- # The variable "lines" is a list containing all lines in the file
- lines = f.readlines()
- # close the file after reading the lines.
- f.close()
- def slowPrint():
- for line in lines:
- for mychar in line:
- sys.stdout.write(CYAN + mychar)
- sys.stdout.flush()
- time.sleep(0.05)
- sys.stdout.write(ENDC)
- sys.stdout.flush()
- f_clearscreen(3.00)
- f_openfile(m_file)
- slowPrint()
- time.sleep(2)
- os.system('clear')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement