Revision 59f82e3f
b/lib/utils.py | ||
---|---|---|
724 | 724 |
key_fields = key.split() |
725 | 725 |
|
726 | 726 |
fd, tmpname = tempfile.mkstemp(dir=os.path.dirname(file_name)) |
727 |
out = os.fdopen(fd, 'w') |
|
728 | 727 |
try: |
729 |
f = open(file_name, 'r')
|
|
728 |
out = os.fdopen(fd, 'w')
|
|
730 | 729 |
try: |
731 |
for line in f: |
|
732 |
# Ignore whitespace changes while comparing lines |
|
733 |
if line.split() != key_fields: |
|
734 |
out.write(line) |
|
735 |
|
|
736 |
out.flush() |
|
737 |
os.rename(tmpname, file_name) |
|
730 |
f = open(file_name, 'r') |
|
731 |
try: |
|
732 |
for line in f: |
|
733 |
# Ignore whitespace changes while comparing lines |
|
734 |
if line.split() != key_fields: |
|
735 |
out.write(line) |
|
736 |
|
|
737 |
out.flush() |
|
738 |
os.rename(tmpname, file_name) |
|
739 |
finally: |
|
740 |
f.close() |
|
738 | 741 |
finally: |
739 |
f.close() |
|
740 |
finally: |
|
741 |
out.close() |
|
742 |
out.close() |
|
743 |
except: |
|
744 |
RemoveFile(tmpname) |
|
745 |
raise |
|
742 | 746 |
|
743 | 747 |
|
744 | 748 |
def CreateBackup(file_name): |
Also available in: Unified diff