Skip to content

Commit 2061100

Browse files
committed
add license header, improve comments
Signed-off-by: Kunz, Immanuel <immanuel.kunz@aisec.fraunhofer.de>
1 parent 56dd5c6 commit 2061100

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

src/univers/libversion.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Visit https://aboutcode.org and https://github.com/aboutcode-org/univers for support and download.
4+
15
import re
26

37
PRE_RELEASE_KEYWORDS = ["alpha", "beta", "rc", "pre"]
@@ -71,13 +75,17 @@ def compare_components(self, other):
7175
c1 = self.components[i]
7276
c2 = other.components[i]
7377

74-
# Compare metaorder
78+
"""
79+
Compare based on metaorder
80+
"""
7581
if c1[1] < c2[1]:
7682
return -1
7783
elif c1[1] > c2[1]:
7884
return 1
7985

80-
# Compare if components are empty
86+
"""
87+
Check based on empty components
88+
"""
8189
c1_is_empty = c1[0] == ""
8290
c2_is_empty = c2[0] == ""
8391

@@ -88,7 +96,9 @@ def compare_components(self, other):
8896
elif c2_is_empty:
8997
return 1
9098

91-
# Compare if components are alpha or numeric
99+
"""
100+
Compare based on alphabet or numeric
101+
"""
92102
c1_is_alpha = c1[0].isalpha()
93103
c2_is_alpha = c2[0].isalpha()
94104

@@ -102,7 +112,9 @@ def compare_components(self, other):
102112
elif c2_is_alpha:
103113
return 1
104114

105-
# Numeric comparison
115+
"""
116+
Compare based on numeric comparison
117+
"""
106118
c1_value = int(c1[0]) if c1[0] else 0
107119
c2_value = int(c2[0]) if c2[0] else 0
108120

@@ -111,7 +123,9 @@ def compare_components(self, other):
111123
elif c1_value > c2_value:
112124
return 1
113125

114-
# All components compared are equal, check for more components
126+
"""
127+
Components are equal; check for length of components
128+
"""
115129
if len(self.components) < len(other.components):
116130
return -1
117131
elif len(self.components) > len(other.components):

0 commit comments

Comments
 (0)