+
+
+def shuffle_columns(
+ txt: Iterable[str],
+ specs: Iterable[Iterable[int]],
+ delim=''
+) -> Iterable[str]:
+ out = []
+ for spec in specs:
+ chunk = ''
+ for n in spec:
+ chunk = chunk + delim + txt[n]
+ chunk = chunk.strip(delim)
+ out.append(chunk)
+ return out
+
+
+def shuffle_columns_into_dict(
+ txt: Iterable[str],
+ specs: Iterable[Tuple[str, Iterable[int]]],
+ delim=''
+) -> Dict[str, str]:
+ out = {}
+ for spec in specs:
+ chunk = ''
+ for n in spec[1]:
+ chunk = chunk + delim + txt[n]
+ chunk = chunk.strip(delim)
+ out[spec[0]] = chunk
+ return out
+
+
+def interpolate_using_dict(txt: str, values: Dict[str, str]) -> str:
+ return sprintf(txt.format(**values), end='')