Skip to content

Commit

Permalink
remove hidden paths from analysis, as they might be temporary files
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Aug 28, 2022
1 parent b02ba9f commit f499b74
Show file tree
Hide file tree
Showing 5 changed files with 11,927 additions and 16,330 deletions.
23 changes: 19 additions & 4 deletions examples/os_diffs/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,20 @@ def uniques(self):
Apaths = [x for x in Apaths if x not in Bpaths]
if not Apaths:
break
uniques[A] = Apaths
uniques[A] = sorted(Apaths)
return uniques

def filter_hidden(self, paths):
"""
Filter out hidden paths that might be temporary.
"""
finals = []
for path in paths:
if any(x.startswith(".") for x in path.split(os.sep)):
continue
finals.append(path)
return finals

def diff(self):
"""
Run the diff
Expand All @@ -117,8 +128,12 @@ def diff(self):
return df

def read_fs(self, jsonA):
"""
Read filesystem entries and filter out hidden paths
"""
A = read_json(jsonA)
return set(list(A.values())[0]["fs"])
paths = set(list(A.values())[0]["fs"])
return self.filter_hidden(paths)

def calculate_diff(self, jsonA, jsonB):
"""
Expand All @@ -128,8 +143,8 @@ def calculate_diff(self, jsonA, jsonB):
-------------------------
union of items in A and B
"""
A = self.read_fs(jsonA)
B = self.read_fs(jsonB)
A = set(self.read_fs(jsonA))
B = set(self.read_fs(jsonB))

return len(A.intersection(B)) / len(A.union(B))

Expand Down

0 comments on commit f499b74

Please sign in to comment.