aboutsummaryrefslogtreecommitdiff
path: root/pomop/version.py
diff options
context:
space:
mode:
Diffstat (limited to 'pomop/version.py')
-rw-r--r--pomop/version.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/pomop/version.py b/pomop/version.py
new file mode 100644
index 0000000..b621557
--- /dev/null
+++ b/pomop/version.py
@@ -0,0 +1,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)