Skip to content

Capsize-Games/nullscream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NULLSCREAM


img.png

Upload Python Package


nullscream is a simple library that allows you to import noop functions and classes that you can use as drop in replacements for functions you wish to override.

This allows anything on the blacklist to be importable, but not executable.


Installation

pip install nullscream

Usage

Import the install_nullscream function the top of your main entry file (e.g. main.py), import nullscream before importing any other libraries.

import nullscream

nullscream_blacklist = ["requests"]

nullscream.activate(
    blacklist=nullscream_blacklist,
)

Now when you import requests, you will get a noop version of the requests library.

import requests

print(requests.__doc__)

# Output:
# This is a noop stand-in module.

print(requests.foobar())

# Output:
# MagicType instance

You can uninstall the noop module by calling uninstall_nullscream

import nullscream

nullscream.uninstall(blacklist=["requests"])

Now when you import requests, you will get the original requests library.

import requests

print(requests.__doc__)

# Output: Original requests library docstring

Testing

python -m unittest discover -s tests