]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/util/fileutils.py
Added the ActiveGrid IDE as a sample application
[wxWidgets.git] / wxPython / samples / ide / activegrid / util / fileutils.py
diff --git a/wxPython/samples/ide/activegrid/util/fileutils.py b/wxPython/samples/ide/activegrid/util/fileutils.py
new file mode 100644 (file)
index 0000000..7d334c7
--- /dev/null
@@ -0,0 +1,39 @@
+#----------------------------------------------------------------------------
+# Name:         fileutils.py
+# Purpose:      Active grid miscellaneous utilities
+#
+# Author:       Jeff Norton
+#
+# Created:      12/10/04
+# CVS-ID:       $Id$
+# Copyright:    (c) 2004-2005 ActiveGrid, Inc.
+# License:      wxWindows License
+#----------------------------------------------------------------------------
+
+import os
+
+def createFile(filename, mode='w'):
+    f = None
+    try:
+        f = file(filename, mode)
+    except:
+        os.makedirs(filename[:filename.rindex(os.sep)])
+        f = file(filename, mode)
+    return f
+
+def compareFiles(file1, file2):
+    file1.seek(0)
+    file2.seek(0)
+    while True:
+        line1 = file1.readline()
+        line2 = file2.readline()
+        if (len(line1) == 0):
+            if (len(line2) == 0):
+                return 0
+            else:
+                return -1
+        elif (len(line2) == 0):
+            return -1
+        elif (line1 != line2):
+            return -1
+