| Trees | Indices | Help |
|
|---|
|
|
1 #############################################################################
2 # #
3 # The BMRB library. #
4 # #
5 # Copyright (C) 2008-2013 Edward d'Auvergne #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 #############################################################################
21
22 # Module docstring.
23 """The NMR-STAR version singleton object.
24
25 This file is part of the U{BMRB library<https://sourceforge.net/projects/bmrblib>}.
26 """
27
28 # Python module imports.
29 from re import search
30
31
33 """A singleton for storing the NMR-STAR version information."""
34
35 # Class variable for storing the class instance.
36 instance = None
37
39 """Replacement function for implementing the singleton design pattern."""
40
41 # First initialisation.
42 if self.instance is None:
43 self.instance = object.__new__(self, *args, **kargs)
44
45 # Already initialised, so return the instance.
46 return self.instance
47
48
50 """Set the version number and extract the major, minor and revision numbers.
51
52 @param version: The NMR-STAR version number.
53 @type version: str
54 """
55
56 # Store the number.
57 self.version = version
58
59 # Determine the major, minor, and revision numbers.
60 self.parse_version()
61
62
64 """Convert the version number string into the major, minor, and revision numbers."""
65
66 # Initialise.
67 self.major = None
68 self.minor = None
69 self.revision = None
70 self.sub_revision = None
71
72 # Split up the number.
73 nums = self.version.split('.')
74
75 # Catch development versions.
76 if search('^Dev', self.version) or search('^dev', self.version):
77 # Assume a version 2.1 file.
78 self.major = 2
79 self.minor = 1
80
81 # Quit.
82 return
83
84 # A production tag is in the version string.
85 if nums[0] == 'production':
86 nums.pop(0)
87
88 # The major and minor numbers.
89 self.major = int(nums[0])
90 self.minor = int(nums[1])
91
92 # The revision number.
93 if len(nums) > 2:
94 self.revision = int(nums[2])
95
96 # The sub-revision number.
97 if len(nums) > 3:
98 self.sub_revision = int(nums[3])
99
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Tue Nov 26 19:05:27 2013 | http://epydoc.sourceforge.net |