Advertisement
QuantumWarpCode

Python Log File Creation Classes V2

Nov 9th, 2014
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time, datetime
  2.  
  3. class string(object):
  4.    
  5.     def removePhrase(self, string, charArray):
  6.        
  7.         string = str(string)
  8.        
  9.         for i in range (0, len(charArray)):
  10.             string = string.replace(charArray[i], "")
  11.        
  12.         return string
  13.    
  14.     def removePhraseSpace(self, string, charArray):
  15.        
  16.         string = str(string)
  17.        
  18.         for i in range (0, len(charArray)):
  19.             string = string.replace(charArray[i], " " * len(charArray[i]))
  20.        
  21.         return string
  22.    
  23.     def cleanPhrase(self, string, charArray):
  24.        
  25.         string = str(string)
  26.        
  27.         for i in range (0, len(charArray)):
  28.             string = string.replace(charArray[i], "*" * len(charArray[i]))
  29.        
  30.         return string
  31.  
  32. class log(object):
  33.    
  34.     def fileOpen(self, file):
  35.        
  36.         self.file = open(file,"a")
  37.    
  38.     def addLine(self, line):
  39.        
  40.         self.file.write(str(line) + "\n")
  41.    
  42.     def addLineDT(self, line):
  43.        
  44.         time = datetime.datetime.now()
  45.         print(time)
  46.         self.addLine(str(time) + str(line))
  47.    
  48.     def addLinePrint(self, line):
  49.        
  50.         self.file.write(str(line) + "\n")
  51.         print(line)
  52.    
  53.     def fileClose(self):
  54.        
  55.         self.file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement