Skip to content

Commit 1a35cc6

Browse files
committed
Update textgen.py
1 parent afa9217 commit 1a35cc6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

util/textgen.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ def generate_string(self, template=None):
2222
else:
2323
text = random.choice(self.templates)
2424

25-
# replace static variables in the template with provided values
25+
# replace static tags in the template with provided values
26+
27+
# eg: if the template contains the tag {age} and you provide the variable age when creating the textgen,
28+
# instances of {age} will be replaced with the variable provided before the random stage
2629
if self.variables:
2730
for key, value in self.variables.items():
2831
text = text.replace("{%s}" % key, value)
2932

3033
# get a list of all text parts we need
3134
required_parts = TEMPLATE_RE.findall(text)
35+
36+
# TODO: replace the simple logic here with a system that can allow multiple instances of the
37+
# same tag to be handled
38+
39+
# eg: if there are two instances of the tag {example} in the template, each one should be
40+
# replaced with a random part instead of both getting the same part
3241

3342
for required_part in required_parts:
3443
ppart = self.parts[required_part]

0 commit comments

Comments
 (0)