Mercurial > gnulib
changeset 38835:a49716228960
gnulib-tool.py: Fix subend function.
Make subend('a','b','Laura') return 'Laurb' instead of 'bL'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 09 Sep 2017 12:01:28 +0200 |
parents | 5457601180bd |
children | 42df2563bf2b |
files | pygnulib/constants.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pygnulib/constants.py Sat Sep 09 10:25:09 2017 +0200 +++ b/pygnulib/constants.py Sat Sep 09 12:01:28 2017 +0200 @@ -397,6 +397,10 @@ def substart(orig, repl, data): + '''Replaces the start portion of a string. + + Returns data with orig replaced by repl, but only at the beginning of data. + Like data.replace(orig,repl), except only at the beginning of data.''' result = data if data.startswith(orig): result = repl + data[len(orig):] @@ -404,9 +408,13 @@ def subend(orig, repl, data): + '''Replaces the end portion of a string. + + Returns data with orig replaced by repl, but only at the end of data. + Like data.replace(orig,repl), except only at the end of data.''' result = data if data.endswith(orig): - result = repl + data[:len(repl)] + result = data[:-len(orig)] + repl return(result)