source: sasview/build_tools/get_version.py @ e0c830a

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 e0c830a was e0c830a, checked in by Mathieu Doucet <doucetm@…>, 12 years ago

Re #3 Refactoring version handling

  • Property mode set to 100644
File size: 1.3 KB
Line 
1__revision__ = filter(str.isdigit, "$Revision$")
2__version__ = "0.0.0"
3try:
4    import sans.sansview
5    __version__ = sans.sansview.__version__
6except:
7    print "Could not load sansview module"
8   
9def get_svn_revision(path=None):
10    rev = None
11    if path is None:
12        path = os.path.dirname(__file__)
13    entries_path = '%s/.svn/entries' % path
14
15    if os.path.exists(entries_path):
16        entries = open(entries_path, 'r').read()
17        # Versions >= 7 of the entries file are flat text.  The first line is
18        # the version number. The next set of digits after 'dir' is the revision.
19        if re.match('(\d+)', entries):
20            rev_match = re.search('\d+\s+dir\s+(\d+)', entries)
21            if rev_match:
22                rev = rev_match.groups()[0]
23        # Older XML versions of the file specify revision as an attribute of
24        # the first entries node.
25        else:
26            from xml.dom import minidom
27            dom = minidom.parse(entries_path)
28            rev = dom.getElementsByTagName('entry')[0].getAttribute('revision')
29
30    if rev:
31        return u'%s' % rev
32    return None
33
34# Get actual revision number if possible
35try:
36    rev = get_svn_revision()
37    if rev is not None:
38        __revision__ = rev
39except:
40    print "Could not extract revision number"
41
42   
Note: See TracBrowser for help on using the repository browser.