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