Advertisement
siverpro

logs

Jul 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. def append_log(line: dict, file: string):
  2.     logfile = open(file, 'a+')
  3.     print>>logfile, line
  4.     logfile.close()
  5.     return
  6.  
  7.  
  8. def compare_line(line: dict, file: string):
  9.     file = open(file, 'r+')
  10.     contents = logfile.readlines()
  11.     logfile.close()
  12.  
  13.     # Check log files for duplicates
  14.     for row in contents:
  15.         test = cmp(line, row)
  16.         if test == 0:
  17.             # return None if a match is found
  18.             return None
  19.  
  20.     # No duplicate found
  21.     return True
  22.  
  23. # Check if the log file contains the transaction
  24. # by compare_line(dict, logfile). If it returns true,
  25. # add the line to log file append_log(dict, logfile)
  26. # and then push line to Fiken. If false, skip the line.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement