in python/moz/l10n/formats/xliff/parse_xcode.py [0:0]
def parse_xcode_pattern(src: str | None) -> Iterator[str | Expression]:
if not src:
return
pos = 0
for m in printf.finditer(src):
start = m.start()
if start > pos:
yield src[pos:start]
source = m[0]
format = source[-1]
if format == "%":
yield Expression("%", attributes={"source": source})
else:
name: str
func: str | None
# TODO post-py38: should be a match
if format in {"c", "C", "s", "S"}:
name = "str"
func = "string"
elif format in {"d", "D", "o", "O", "p", "u", "U", "x", "X"}:
name = "int"
func = "integer"
elif format in {"a", "A", "e", "E", "f", "g", "G"}:
name = "num"
func = "number"
else:
name = "arg"
func = None
if m[1]:
name += m[1][0]
yield Expression(
VariableRef(name),
func,
attributes={"source": source},
)
pos = m.end()
if pos < len(src):
yield src[pos:]