source: sasview/build_tools/rpm/create_rpm_spec.py @ 5980b1a

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 5980b1a was f6f0c7b, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #3 improve finding algo for config

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