Scyther.py: Added Caching to Scyther's Python interface.

Cached data is stored in:

Cache/XX/YYYYY.out (stdout)
Cache/XX/YYYYY.err (stderr)

Where XX^YYYYY is the sha256 hexdigest of the concatenation of the input spdl and
the arguments.
This commit is contained in:
Cas Cremers
2010-11-09 12:05:18 +01:00
parent cbb66ea794
commit e42aa1215e
3 changed files with 109 additions and 1 deletions

View File

@@ -64,6 +64,40 @@ def sorted(li):
return result
# ensurePath: does what os.makedirs should do.
def ensurePath(pt):
"""
Make sure the path exists: if not, create the directories one by one
By example:
Call with "dog/cat/bone" ensures that afterwards, this subdirectory structure (dog/cat/bone) exists, with 'bone' a directory.
It ensures this by doing the procedure for "dog", then "dog/cat", etc...
"""
ptn = os.path.normpath(pt)
# First we see what needs to exist overall
todo = [ptn]
tail = "x"
while len(tail) > 0:
(head,tail) = os.path.split(ptn)
if len(head) > 0:
todo.append(head)
ptn = head
else:
break
# Reverse list: path prefixes first
todo.reverse()
# Create bottom-up
for pt in todo:
if not os.path.isdir(pt):
# Note that os.path.exists(pt) may still hold. In this case the next command will cause an error.
os.mkdir(pt)
# path
def mypath(file):
""" Construct a file path relative to the scyther-gui main directory