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 4793734 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
|
Rev | Line | |
---|
[5a13f0d] | 1 | import sys |
---|
| 2 | sys.path.append("..") |
---|
| 3 | import get_version |
---|
| 4 | |
---|
[d6a2e26] | 5 | revision = get_version.__revision__ |
---|
| 6 | if len(sys.argv)>1: |
---|
| 7 | try: |
---|
| 8 | revision = int(sys.argv[1].strip()) |
---|
| 9 | except: |
---|
[b0a63cb] | 10 | print "Could not process bad revision number: %s" % str(sys.argv) |
---|
[d6a2e26] | 11 | |
---|
[5a13f0d] | 12 | def 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 | |
---|
| 29 | input=open("sansview.spec.template",'r') |
---|
| 30 | output=open("sansview.spec",'w') |
---|
| 31 | |
---|
| 32 | buf = input.read() |
---|
| 33 | lines = buf.split('\n') |
---|
| 34 | for l in lines: |
---|
| 35 | new_line = replaceToken(l, "[VERSION]", get_version.__version__) |
---|
[3fa4bbd] | 36 | new_line = replaceToken(new_line, "[REVISION]", str(revision)) |
---|
[5a13f0d] | 37 | output.write(new_line+'\n') |
---|
| 38 | |
---|
| 39 | input.close() |
---|
| 40 | output.close() |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | |
---|
Note: See
TracBrowser
for help on using the repository browser.