Script: replace only the first _ with ~

This commit is contained in:
Lukáš Lalinský
2007-05-31 12:37:10 +02:00
parent adc19f7320
commit 1f17645b8e
2 changed files with 11 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
Version 0.9.0alpha11 - 2007-05-28
Version 0.9.0alpha11 - 2007-05-27
* New Features:
* Added "Edit" button to the tag editor.
* Bug Fixes:

View File

@@ -307,7 +307,8 @@ def func_num(parser, text, length):
def func_unset(parser, name):
"""Unsets the variable ``name``."""
name = name.replace("_", "~")
if name.startswith("_"):
name = "~" + name[1:]
try:
del parser.context[name]
except KeyError:
@@ -316,19 +317,23 @@ def func_unset(parser, name):
def func_set(parser, name, value):
"""Sets the variable ``name`` to ``value``."""
name = name.replace("_", "~")
if name.startswith("_"):
name = "~" + name[1:]
parser.context[name] = value
return ""
def func_get(parser, name):
"""Returns the variable ``name`` (equivalent to ``%name%``)."""
name = name.replace("_", "~")
if name.startswith("_"):
name = "~" + name[1:]
return parser.context.get(name, u"")
def func_copy(parser, new, old):
"""Copies content of variable ``old`` to variable ``new``."""
new = new.replace("_", "~")
old = old.replace("_", "~")
if new.startswith("_"):
new = "~" + new[1:]
if old.startswith("_"):
old = "~" + old[1:]
parser.context[new] = parser.context.getall(old)[:]
return ""