Skip to content

Commit

Permalink
recent changes in Python code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Dieckmann committed Apr 26, 2020
1 parent bf9d6bc commit 846d2c5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
14 changes: 14 additions & 0 deletions nodes/1.x/python/Helpers.FindSyncEventOverlaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data = [(x.Start, x.End, x) for x in IN[0]]
# sort by end first, then by start
data.sort(key=lambda x: x[1])
data.sort(key=lambda x: x[0])
l = len(data)
overlaps = []
for i in xrange(l):
for j in xrange(i+1, l):
x = data[i]
y = data[j]
# identify overlaps
if (y[0]<=x[1]): overlaps.append([x[2], y[2]])

OUT = overlaps
11 changes: 11 additions & 0 deletions nodes/1.x/python/SyncEvent.WasAborted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import clr

def process_input(func, input):
if isinstance(input, list): return [func(x) for x in input]
else: return func(input)

def SyncEventWasAborted(syncevent):
if syncevent.__repr__() == 'SyncEvent': return syncevent.WasAborted
else: return None

OUT = process_input(SyncEventWasAborted,IN[0])
2 changes: 2 additions & 0 deletions nodes/1.x/python/WorksharingLog.ByPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def GetSyncEvents(self):
for event in self.Events:
if event.Text == ">STC": events.append(SyncEvent(event.DateTime))
elif event.Text == ">STC:RL:Read": events[-1].ReloadLatestCount += 1
elif event.Text == ".STC:RL:LockRoot RW gaveUp": events[-1].WasAborted = True
elif event.Text == "<STC" and len(events) > 0:
events[-1].End = event.DateTime
events[-1].Duration = event.DateTime - events[-1].Start
Expand All @@ -94,6 +95,7 @@ def __init__(self, start):
self.End = None
self.Duration = None
self.ReloadLatestCount = 0
self.WasAborted = False
def __repr__(self):
return "SyncEvent"

Expand Down
14 changes: 14 additions & 0 deletions nodes/2.x/python/Helpers.FindSyncEventOverlaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data = [(x.Start, x.End, x) for x in IN[0]]
# sort by end first, then by start
data.sort(key=lambda x: x[1])
data.sort(key=lambda x: x[0])
l = len(data)
overlaps = []
for i in xrange(l):
for j in xrange(i+1, l):
x = data[i]
y = data[j]
# identify overlaps
if (y[0]<=x[1]): overlaps.append([x[2], y[2]])

OUT = overlaps
11 changes: 11 additions & 0 deletions nodes/2.x/python/SyncEvent.WasAborted.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import clr

def process_input(func, input):
if isinstance(input, list): return [func(x) for x in input]
else: return func(input)

def SyncEventWasAborted(syncevent):
if syncevent.__repr__() == 'SyncEvent': return syncevent.WasAborted
else: return None

OUT = process_input(SyncEventWasAborted,IN[0])
2 changes: 2 additions & 0 deletions nodes/2.x/python/WorksharingLog.ByPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def GetSyncEvents(self):
for event in self.Events:
if event.Text == ">STC": events.append(SyncEvent(event.DateTime))
elif event.Text == ">STC:RL:Read": events[-1].ReloadLatestCount += 1
elif event.Text == ".STC:RL:LockRoot RW gaveUp": events[-1].WasAborted = True
elif event.Text == "<STC" and len(events) > 0:
events[-1].End = event.DateTime
events[-1].Duration = event.DateTime - events[-1].Start
Expand All @@ -99,6 +100,7 @@ def __init__(self, start):
self.End = None
self.Duration = None
self.ReloadLatestCount = 0
self.WasAborted = False
def __repr__(self):
return "SyncEvent"

Expand Down

0 comments on commit 846d2c5

Please sign in to comment.