DRYer
This commit is contained in:
parent
55aa9e11db
commit
17f3d2d581
@ -224,12 +224,12 @@ def parse_option_spec(spec: Optional[str] = None) -> Tuple[OptionSpecSeq, Option
|
|||||||
|
|
||||||
def prettify(text: str) -> str:
|
def prettify(text: str) -> str:
|
||||||
|
|
||||||
|
def identity(x: str) -> str:
|
||||||
|
return x
|
||||||
|
|
||||||
def sub(m: Match) -> str:
|
def sub(m: Match) -> str:
|
||||||
role, text = m.group(1, 2)
|
role, text = m.group(1, 2)
|
||||||
try:
|
return role_map.get(role, identity)(text)
|
||||||
return str(role_map[role](text))
|
|
||||||
except KeyError:
|
|
||||||
return str(text)
|
|
||||||
|
|
||||||
text = re.sub(r':([a-z]+):`([^`]+)`', sub, text)
|
text = re.sub(r':([a-z]+):`([^`]+)`', sub, text)
|
||||||
return text
|
return text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user