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 cf81aaa was
5a13f0d,
checked in by Mathieu Doucet <doucetm@…>, 13 years ago
|
Re #3 getting ready for rpm
|
-
Property mode set to
100644
|
File size:
903 bytes
|
Rev | Line | |
---|
[5a13f0d] | 1 | import sys |
---|
| 2 | sys.path.append("..") |
---|
| 3 | import get_version |
---|
| 4 | |
---|
| 5 | def replaceToken(line, key, value): #pylint: disable-msg=R0201 |
---|
| 6 | """ Replace a token in the template file |
---|
| 7 | @param line: line of text to inspect |
---|
| 8 | @param key: token to look for |
---|
| 9 | @param value: string value to replace the token with |
---|
| 10 | @return: new string value |
---|
| 11 | """ |
---|
| 12 | lenkey = len(key) |
---|
| 13 | newline = line |
---|
| 14 | |
---|
| 15 | while newline.count(key)>0: |
---|
| 16 | index = newline.index(key) |
---|
| 17 | newline = newline[:index]+value+newline[index+lenkey:] |
---|
| 18 | |
---|
| 19 | return newline |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | input=open("sansview.spec.template",'r') |
---|
| 23 | output=open("sansview.spec",'w') |
---|
| 24 | |
---|
| 25 | buf = input.read() |
---|
| 26 | lines = buf.split('\n') |
---|
| 27 | for l in lines: |
---|
| 28 | new_line = replaceToken(l, "[VERSION]", get_version.__version__) |
---|
| 29 | new_line = replaceToken(new_line, "[REVISION]", get_version.__revision__) |
---|
| 30 | output.write(new_line+'\n') |
---|
| 31 | |
---|
| 32 | input.close() |
---|
| 33 | output.close() |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
Note: See
TracBrowser
for help on using the repository browser.