All pastes #983496 Raw Edit

Copy-num.py

public python v1 · immutable
#983496 ·published 2008-04-13 12:03 UTC
rendered paste body
#! /usr/bin/env python 	import time 	import os 	import sys 	print "hello in program copy-numbers 0.0.3" 	time.sleep(2) 	print "This program copies numbers from file 'xD' to file 'lmao.txt'" 	time.sleep(2) 	print "you have to make 'xD' and inside should be printed: [num] [text] [text] newline etc" 	time.sleep(2) 	prompt = "Please type 'go' to continue or 'exit' to exit. " 	while True: 	    command = raw_input(prompt) 	    if command == "go": 	        break 	    elif command == "exit": 	        sys.exit(0) 	outfile = open('lmao.txt', 'w') 	print "Copying" 	for line in file('xD'): outfile.write(line.split()[0] + os.linesep) 	class progressbarClass: 	    def __init__(self, finalcount, progresschar=None): 	        self.finalcount=finalcount 	        self.blockcount=0 	        # 	        # See if caller passed me a character to use on the 	        # progress bar (like "*").  If not use the block 	        # character that makes it look like a real progress 	        # bar. 	        # 	        if not progresschar: self.block=chr(178) 	        else:                self.block=progresschar 	        # 	        # Get pointer to sys.stdout so I can use the write/flush 	        # methods to display the progress bar. 	        # 	        self.f=sys.stdout 	        # 	        # If the final count is zero, don't start the progress gauge 	        # 	        if not self.finalcount : return 	        self.f.write('\n---------------- % Progress --------------------\n') 	        self.f.write('  10   20   30   40   50   60   70   80   90   100\n') 	        return 	 	    def progress(self, count): 	        # 	        # Make sure I don't try to go off the end (e.g. >100%) 	        # 	        count=min(count, self.finalcount) 	        # 	        # If finalcount is zero, I'm done 	        # 	        if self.finalcount: 	            percentcomplete=int(round(100*count/self.finalcount)) 	            if percentcomplete < 1: percentcomplete=1 	        else: 	            percentcomplete=100 	 	        #print "percentcomplete=",percentcomplete 	        blockcount=int(percentcomplete/2) 	        #print "blockcount=",blockcount 	        if blockcount > self.blockcount: 	            for i in range(self.blockcount,blockcount): 	                self.f.write(self.block) 	                self.f.flush() 	 	        if percentcomplete == 100: self.f.write("\n") 	        self.blockcount=blockcount 	        return 	 	if __name__ == "__main__": 	    from time import sleep 	    pb=progressbarClass(8,"*") 	    count=0 	    while count<9: 	        count+=1 	        pb.progress(count) 	        sleep(0.2) 	 	 	time.sleep(2) 	while not raw_input("Done! Please type 'exit' to exit. ") == "exit": pass 	sys.exit()