blob: b621557d9a6a622b6ecedd52088ca32e6c97f43c (
plain)
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
53
54
|
# vim: set fileencoding=utf-8 :
#
# (C) 2013 Guido Günther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Some Pom parsing handling
class Version(object):
def __init__(self, text):
self._version = text.strip()
def is_subst(self):
"""
Wheter a version is subject to variable substitution
>>> Version('1.0').is_subst()
False
>>> Version('${version}').is_subst()
True
"""
return self._version.startswith('${') and self._version.endswith('}')
def is_snapshot(self):
"""
Wheter a version is a snapthot version
>>> Version('1.0').is_snapshot()
False
>>> Version('1.0-SNAPSHOT').is_snapshot()
True
"""
return self._version.endswith('-SNAPSHOT')
def __str__(self):
return self._version
def __eq__(self, arg):
# Make sure we can compare versions in string context
if isinstance(arg, (str, unicode)):
return self._version.__eq__(arg)
else:
return super(Version, self).__eq__(arg)
|