Changeset e0c830a in sasview


Ignore:
Timestamp:
Dec 16, 2011 6:56:10 AM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7680760
Parents:
5548954
Message:

Re #3 Refactoring version handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • build_tools/get_version.py

    ree1e4b20 re0c830a  
    66except: 
    77    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 TracChangeset for help on using the changeset viewer.