-
Notifications
You must be signed in to change notification settings - Fork 0
/
Release.py
52 lines (37 loc) · 1.57 KB
/
Release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
This class represents a release.
The release has a version and some clients
'''
from Except import NoDependencyChange
class Release:
def __init__(self, version, client_timestamp, client_previous_timestamp):
self.version = version
self.client_timestamp = client_timestamp
self.client_previous_timestamp = client_previous_timestamp
self.dependencies = []
def addDependency(self, dependency):
self.dependencies.append(dependency)
# insertionSort: http://interactivepython.org/courselib/static/pythonds/SortSearch/TheInsertionSort.html
def sort(self):
for index in range(1, len(self.dependencies)):
currentvalue = self.dependencies[index]
position = index
# compare '[email protected]' to '[email protected]'
while position > 0 and self.dependencies[position-1].__str__() > currentvalue.__str__():
self.dependencies[position] = self.dependencies[position-1]
position = position-1
self.dependencies[position] = currentvalue
# return one client at time
def getDependency(self):
return self.dependencies
def __str__(self):
return self.version
# if any dependency is changed to 'upgrade' or add, then need to install and test
def verifyDependencyChange(self, onlyVersion):
# force install and test even if hasnt change
if onlyVersion:
return
for dependency in self.dependencies:
if dependency.changed():
return
raise NoDependencyChange()