]> git.saurik.com Git - wxWidgets.git/blob - wxPython/samples/ide/activegrid/util/fileutils.py
Add a comment about covariant returns
[wxWidgets.git] / wxPython / samples / ide / activegrid / util / fileutils.py
1 #----------------------------------------------------------------------------
2 # Name: fileutils.py
3 # Purpose: Active grid miscellaneous utilities
4 #
5 # Author: Jeff Norton
6 #
7 # Created: 12/10/04
8 # CVS-ID: $Id$
9 # Copyright: (c) 2004-2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
12
13 import os
14
15 def createFile(filename, mode='w'):
16 f = None
17 try:
18 f = file(filename, mode)
19 except:
20 os.makedirs(filename[:filename.rindex(os.sep)])
21 f = file(filename, mode)
22 return f
23
24 def compareFiles(file1, file2):
25 file1.seek(0)
26 file2.seek(0)
27 while True:
28 line1 = file1.readline()
29 line2 = file2.readline()
30 if (len(line1) == 0):
31 if (len(line2) == 0):
32 return 0
33 else:
34 return -1
35 elif (len(line2) == 0):
36 return -1
37 elif (line1 != line2):
38 return -1
39