source: sasview/build_tools/rpm/create_rpm_spec.py @ 5548954

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 5548954 was 3fa4bbd, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #3 Fix revision numbering

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import sys
2sys.path.append("..")
3import get_version
4
5revision = get_version.__revision__
6if len(sys.argv)>1:
7    try:
8        revision = int(sys.argv[1].strip())
9    except:
10        print "Could not process bad revision number: %s" % str(sys.argv)
11
12def replaceToken(line, key, value): #pylint: disable-msg=R0201
13    """ Replace a token in the template file
14        @param line: line of text to inspect
15        @param key: token to look for
16        @param value: string value to replace the token with
17        @return: new string value
18    """
19    lenkey = len(key)
20    newline = line
21   
22    while newline.count(key)>0:
23        index = newline.index(key)
24        newline = newline[:index]+value+newline[index+lenkey:]
25   
26    return newline
27
28
29input=open("sansview.spec.template",'r')
30output=open("sansview.spec",'w')
31
32buf = input.read()
33lines = buf.split('\n')
34for l in lines:
35    new_line = replaceToken(l, "[VERSION]", get_version.__version__)
36    new_line = replaceToken(new_line, "[REVISION]", str(revision))
37    output.write(new_line+'\n')
38   
39input.close()
40output.close()
41   
42
43
Note: See TracBrowser for help on using the repository browser.