From 20eccebd454e365073d834d5c7c89ef88c1a803a Mon Sep 17 00:00:00 2001 From: Cutipus Date: Tue, 15 May 2018 19:47:24 +0300 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ classcreation.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .gitignore create mode 100644 classcreation.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..372c13e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__/ + diff --git a/classcreation.py b/classcreation.py new file mode 100644 index 0000000..244978b --- /dev/null +++ b/classcreation.py @@ -0,0 +1,18 @@ +import builtins + +_original = builtins.__build_class__ + +naughty_list = 'test', 'a', 'b', 'c', 'lewd', 'pony', 'ponies' + +def profanity_filter(func, name, *args, **kwargs): + if any(bad_word in name.lower() for bad_word in naughty_list): + raise RuntimeError('Disgusting! Thats how you name your classes?!') + return _original(func, name, *args, **kwargs) + +def disallow_profanity(): + builtins.__build_class__ = profanity_filter + +def allow_profanity(): + builtins.__build_class__ = _original + +disallow_profanity()