equal
deleted
inserted
replaced
|
1 # Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # All rights reserved. |
|
3 # This component and the accompanying materials are made available |
|
4 # under the terms of "Eclipse Public License v1.0" |
|
5 # which accompanies this distribution, and is available |
|
6 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 # |
|
8 # Initial Contributors: |
|
9 # Nokia Corporation - initial contribution. |
|
10 # |
|
11 # Contributors: |
|
12 # |
|
13 # Description: |
|
14 # |
|
15 |
|
16 import re |
|
17 |
|
18 def doTimeStampCompareAndWrite(aFile, aNewFileContents): |
|
19 oldFileSub = '' |
|
20 try: |
|
21 oldFile = open(aFile, 'r') |
|
22 oldFileContents = oldFile.read() |
|
23 if len(oldFileContents) > 0: |
|
24 oldFileSub = re.sub(r'\n[\W\w]*\(time stamp\)', '', oldFileContents) |
|
25 except IOError: |
|
26 pass |
|
27 |
|
28 newFileSub = re.sub(r'\n[\W\w]*\(time stamp\)', '', aNewFileContents) |
|
29 |
|
30 #compare sub-ed files |
|
31 if oldFileSub == '' or re.search(re.escape(oldFileSub), newFileSub) == None: |
|
32 file(aFile, 'w+').write(aNewFileContents) |
|
33 return True |
|
34 return False |