summaryrefslogtreecommitdiff
path: root/webapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py
diff options
context:
space:
mode:
Diffstat (limited to 'webapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py')
-rwxr-xr-xwebapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py96
1 files changed, 0 insertions, 96 deletions
diff --git a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py b/webapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py
deleted file mode 100755
index 089b33b966..0000000000
--- a/webapps/qooxdoo-0.6.3-sdk/frontend/framework/tool/modules/filetool.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env python
-
-import os, codecs, cPickle, sys
-import textutil
-
-def save(filePath, content="", encoding="utf_8"):
- # Normalize
- filePath = normalize(filePath)
-
- # Create directory
- directory(os.path.dirname(filePath))
-
- # Writing file
- try:
- outputFile = codecs.open(filePath, encoding=encoding, mode="w", errors="replace")
- outputFile.write(content)
- except IOError, (errno, strerror):
- print " * I/O error(%s): %s" % (errno, strerror)
- sys.exit(1)
- except UnicodeDecodeError:
- print " * Could not decode result to %s" % encoding
- sys.exit(1)
- except:
- print " * Unexpected error:", sys.exc_info()[0]
- sys.exit(1)
-
- outputFile.flush()
- outputFile.close()
-
-
-def directory(dirname):
- # Normalize
- dirname = normalize(dirname)
-
- # Check/Create directory
- if dirname != "" and not os.path.exists(dirname):
- os.makedirs(dirname)
-
-
-def normalize(filename):
- return os.path.normcase(os.path.normpath(filename))
-
-
-def read(filePath, encoding="utf_8"):
- try:
- ref = codecs.open(filePath, encoding=encoding, mode="r")
- content = ref.read()
- ref.close()
-
- return textutil.any2Unix(unicode(content))
-
- except IOError, (errno, strerror):
- print " * I/O error(%s): %s" % (errno, strerror)
- sys.exit(1)
-
- except ValueError:
- print " * Invalid Encoding. Required encoding %s in %s" % (encoding, filePath)
- sys.exit(1)
-
- except:
- print " * Unexpected error:", sys.exc_info()[0]
- sys.exit(1)
-
-
-def storeCache(cachePath, data):
- try:
- cPickle.dump(data, open(cachePath, 'w'), 2)
-
- except EOFError or PickleError or PicklingError:
- print " * Could not store cache to %s" % cachePath
- sys.exit(1)
-
-
-def readCache(cachePath):
- try:
- return cPickle.load(open(cachePath))
-
- except EOFError or PickleError or UnpicklingError:
- print " * Could not read cache from %s" % cachePath
- sys.exit(1)
-
-
-def checkCache(filePath, cachePath, internalModTime):
- fileModTime = os.stat(filePath).st_mtime
-
- try:
- cacheModTime = os.stat(cachePath).st_mtime
- except OSError:
- cacheModTime = 0
-
- if internalModTime > cacheModTime:
- # print "Invalid cache: %s" % filePath
- # print "%s > %s" % (internalModTime, cacheModTime)
- return True
-
- return fileModTime > cacheModTime