ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since 6f44bfb was
6f44bfb,
checked in by Mathieu Doucet <doucetm@…>, 12 years ago
|
Re #3 Refactoring version handling
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | __revision__ = filter(str.isdigit, "$Revision$") |
---|
2 | __version__ = "0.0.0" |
---|
3 | |
---|
4 | def get_svn_revision(path=None): |
---|
5 | rev = None |
---|
6 | if path is None: |
---|
7 | path = os.path.dirname(__file__) |
---|
8 | entries_path = '%s/.svn/entries' % path |
---|
9 | |
---|
10 | if os.path.exists(entries_path): |
---|
11 | entries = open(entries_path, 'r').read() |
---|
12 | # Versions >= 7 of the entries file are flat text. The first line is |
---|
13 | # the version number. The next set of digits after 'dir' is the revision. |
---|
14 | if re.match('(\d+)', entries): |
---|
15 | rev_match = re.search('\d+\s+dir\s+(\d+)', entries) |
---|
16 | if rev_match: |
---|
17 | rev = rev_match.groups()[0] |
---|
18 | # Older XML versions of the file specify revision as an attribute of |
---|
19 | # the first entries node. |
---|
20 | else: |
---|
21 | from xml.dom import minidom |
---|
22 | dom = minidom.parse(entries_path) |
---|
23 | rev = dom.getElementsByTagName('entry')[0].getAttribute('revision') |
---|
24 | |
---|
25 | if rev: |
---|
26 | return u'%s' % rev |
---|
27 | return None |
---|
28 | |
---|
29 | # Get actual revision number if possible |
---|
30 | try: |
---|
31 | rev = get_svn_revision() |
---|
32 | if rev is not None: |
---|
33 | __revision__ = rev |
---|
34 | except: |
---|
35 | print "Could not extract revision number" |
---|
36 | |
---|
37 | # Get the version number from the sansview module |
---|
38 | # Check to see if we are dealing with a release |
---|
39 | try: |
---|
40 | import sans.sansview |
---|
41 | __version__ = sans.sansview.__version__ |
---|
42 | |
---|
43 | if sans.sansview.__is_release__: |
---|
44 | __revision__ = None |
---|
45 | except: |
---|
46 | print "Could not load sansview module" |
---|
47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.