summaryrefslogtreecommitdiff
path: root/example/app2/plugins/randomstr.py
diff options
context:
space:
mode:
Diffstat (limited to 'example/app2/plugins/randomstr.py')
-rw-r--r--example/app2/plugins/randomstr.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/example/app2/plugins/randomstr.py b/example/app2/plugins/randomstr.py
new file mode 100644
index 0000000..ed4c159
--- /dev/null
+++ b/example/app2/plugins/randomstr.py
@@ -0,0 +1,14 @@
+import random
+import string
+
+
+def make_random(s):
+ chars = list(s)
+ for idx, char in enumerate(chars):
+ if char not in string.punctuation and not char.isspace():
+ chars[idx] = random.choice(string.ascii_letters)
+ return ''.join(chars)
+
+
+def setup(app):
+ app.register_formatter('random', make_random)