Skip to content

Commit

Permalink
sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasheinrich committed Mar 27, 2018
1 parent 1e23062 commit e2793fd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packtivity/statecontexts/posixfs_context.py
Expand Up @@ -18,15 +18,16 @@ def __init__(self,readwrite = None, readonly = None, dependencies = None, identi
except AssertionError:
raise TypeError('readwrite and readonly must be None or a list {} {}'.format(type(readonly)))
self._identifier = identifier
self.readwrite = list(map(os.path.realpath,readwrite) if readwrite else [])

readonlies = list(map(os.path.realpath,readonly) if readonly else [])
for d in dependencies or []:
if d.readwrite:
readonlies += d.readwrite # if dep has readwrite add those
else:
readonlies += d.readonly # else add the readonlies
self.readonly = readonlies

self.readwrite = sorted(list(map(os.path.realpath,readwrite) if readwrite else []))
self.readonly = sorted(list(map(os.path.realpath,readonlies)))
self.datamodel = None

def __repr__(self):
Expand Down Expand Up @@ -66,7 +67,7 @@ def state_hash(self):
return: SHA1 hash
'''
#hash the upstream / input state
dep_checksums = [checksumdir.dirhash(d) for d in self.readonly if os.path.isdir(d)]
dep_checksums = [checksumdir.dirhash(d) for d in self.readonly if os.path.isdir(d)]

#hash out writing state
state_checksums = [checksumdir.dirhash(d) for d in self.readwrite if os.path.isdir(d)]
Expand Down Expand Up @@ -102,7 +103,7 @@ def json(self):
@classmethod
def fromJSON(cls,jsondata):
return cls(
readwrite = jsondata['readwrite'],
readonly = jsondata['readonly'],
identifier = jsondata['identifier'],
readwrite = sorted(jsondata['readwrite']),
readonly = sorted(jsondata['readonly']),
)

0 comments on commit e2793fd

Please sign in to comment.