Skip to main content

A General Purpose Utility package for Python 3

Project description

Beetroot, a general purpose library full of random python functions that I thought were useful. Has file manipulation, random, tts and more! Have fun using it!

Also, to make JSON dumping and reading faster, do pip install ujson or pip install simplejson

If you find a problem, feel free to report it here.

To install the bare minimum from pip, use pip install beetroot, to install all dependencies for all classes, use pip install beetroot[all]

Upgrading python-beetroot uses the command pip install --upgrade beetroot

Warnings/Known Issues:

  • beetroot.file.bdump() might not work too well, use with caution.

  • beetroot.file.delete() doesn’t throw errors when trying to delete non-existent files, wtf.

  • beetroot.crash() doesn’t even do anything, damn my horrible python skills

  • Yay I fixed the previous crash() bug but the damn thing broke OMFG I DIDN’T EVEN TOUCH ANYTHING WHAT WHY AAAAAAAAAAAA

  • fixed it, still uses the old system

Different extras installation thingies:

  • beetroot[all]

  • beetroot[tts]

  • beetroot[img]

  • beetroot[yt]

  • beetroot[text]

  • beetroot[ram]

  • beetroot[keyboard]

  • beetroot[cython]

  • beetroot[speed]

Functions and uses:

Bad Obfuscation Stuff:

  • beetroot.obf.obfuscate(string) ; Minorly obfuscates objects, this is definitely not secure, don’t rely on this being irreversible or secure. If you want to obfuscate Python 3 code, use beetroot.cython()

  • beetroot.obf.unobfuscate(string) ; Deobfuscates objects made by beetroot.strobfuscate()

Random stuff:

  • beetroot.random.randint(start, end) ; generates random number but using SystemRandom

  • beetroot.random.srandint(seed, start, end) ; generates seeded pseudorandom number

Stopwatch stuff:

  • beetroot.stopwatch.start() ; Starts global stopwatch

  • beetroot.stopwatch.stop() ; Stops global stopwatch and returns time in milliseconds between start and stop

File Manipulation stuff:

  • beetroot.file.move(start, end) ; Moves files

  • beetroot.file.rename(start, end) ; Renames files

  • beetroot.file.delete(file_to_delete, force=<bool>) ; Deletes files

  • beetroot.file.dump(file, data) ; Dumps data to file as string or bytestring

  • beetroot.file.jdump(file, data, pp=<bool>) ; Dumps data

  • beetroot.file.load(file) ; Reads data from file as string

  • beetroot.file.bload(file) ; Reads data from file as bytestring

  • beetroot.file.jload(file) ; Reads data from file as JSON object

TTS stuff:

  • beetroot.tts.say(text) ; Reads text with tts installed, requires pyttsx3 to be installed or use pip install beetroot[tts]

  • beetroot.tts.changeRate(text) ; Changes global tts talk speed, requires pyttsx3 to be installed or use pip install beetroot[tts]

  • beetroot.tts.changeVoice(text) ; Changes global tts voice you can pick ids from 0-n, depending on how many voices you have on your computer, requires pyttsx3 to be installed or use pip install beetroot[tts]

  • beetroot.tts.changeVolume(text) ; Changes global tts volume, requires pyttsx3 to be installed or use pip install beetroot[tts]

Hash stuff:

  • beetroot.hashl.hashf(text, secure=<bool>) ; Hashes an object.

  • beetroot.hashl.dehash(hash) ; Dehashes a hash, this totally works and is definitely possible and is absolutely not a dumb joke that I’m making…

Miscellaneous stuff:

  • beetroot.objtype(obj) ; python type(), but better

  • beetroot.test() ; Literally just a hello world program.

  • beetroot.quicksort(arr) ; Quicksort, which in most cases is slightly faster than Python3’s default Timsort.

  • beetroot.cyclesort(arr) ; Significantly slower than beetroot.quicksort(), but uses less memory.

  • beetroot.swap(array, index_1, index_2) ; Swaps 2 items in list.

  • beetroot.execfile(file) ; Execute .py script

  • beetroot.systemstats() ; Returns [Username, OS, OS version, OS architecture, computer nodename, IP address, MAC address]

  • beetroot.unline(string) ; Makes a multi-line string a single-line string

  • beetroot.reline(string) ; Reverses beetroot.unline()

  • beetroot.pixelgrab(x, y) ; Grabs the colour of the pixel on your screen at (x, y), requires PIL, use pip install pillow

  • beetroot.mousepixelgrab() ; Grabs colour of the pixel at your mouse, requires PIL and pyautogui, use pip install pillow pyautogui or pip install beetroot[img]

  • beetroot.remove(str, item_to_remove) ; Removes all occurences of item_to_remove in str

  • beetroot.siteize(str) ; Makes text into site names, for example “hello there” becomes “www.HelloThere.com”

  • beetroot.taskkill(task, killamount=1) ; I see a task and I E A T it. Pass tasks to it through the “task” argument. killamount argument determines how many instances will be killed. Use None for all.

  • beetroot.crash() ; Crashes pyth-

  • beetroot.admin() ; Requests UAC elevation on Windows.

  • beetroot.cython(file, pypath=<path>) ; Generates a cython extension and cleans up afterwards. Requires python installed on PATH to use. Or whatever the Unix equivalent of PATH is. Uses pypath to find your python installation, or you can not include it and it uses sys.executable instead.

  • beetroot.printn() ; Prints an object without a trailing newline at the end.

  • beetroot.getch() ; Input, but it only waits for one character.

  • beetroot.recursion() ; A context manager that lets you temporarily set your recursion depth. Use with beetroot.recursion(<some recursion limit here>): <do something here> Your recursion limit will be reset after.

  • beetroot.suppress() ; A suppression context manager, use it with the “with” keyword like beetroot.recursion(). This will temporarily suppres stdout and stderr, preventing anything from being printed to console, even with sys.stderr.write. This will, however, not silence error messages, although that’s probably a good thing.

  • beetroot.speed() ; Use as a decorator, memoizes and Cython compiles code to MASSIVELY speed up code. I think. If you are using this with random functions, use the nocache=True argument.

  • beetroot.retargs() ; Returns a list of all arguments of function.

  • beetroot.locate() ; Throws an error, allows you to locate your beetroot installation.

  • beetroot.strlist() ; Makes every single item in a list a string, with str() or .decode(), with proper bytestring handling.

  • beetroot.errprint() ; Prints stuff to stderr.

  • beetroot.errprintn() ; Same as beetroot.errprint(), but it doesn’t print a trailing newline.

Memory functions and stuff:

  • beetroot.mem.mem() ; Returns [All memory, currently used memory, available memory].

  • beetroot.mem.swapmem() ; Same thing as beetroot.mem(), except it’s Swap memory instead.

Youtube garbage:

  • beetroot.yt.search(search_term) ; Enter a search term, the function returns the link for the first hit on that search. Requires youtube-search, use pip install youtube-search or pip install beetroot[yt]

  • beetroot.yt.dl(url, filename, fileformat, playlist=<bool>) ; Downloads a video or playlist from url. Valid codecs include mp3, ogg, wav, m4a, aac, flac, mp4, webm, avi, opus, mkv, mov, flv, aiff and wma. Requires youtube-dl, use pip install youtube-dl or pip install beetroot[yt]

Text manipulation stuff:

  • beetroot.text.udown(text) ; Flips text upside-down

  • beetroot.text.zalgo(text, crazy=<int>) ; Adds zalgo to text, change crazy argument to modify craziness of zalgo text, default value is 1

  • beetroot.text.rouxls(sentence) ; Rouxls-ify text so it sounds stupid.

  • beetroot.text.spamton(text) ; Spamtonify text so you sound like [[Spamton G. Spamton]]

  • beetroot.text.greek(text) ; Replaces English alphabet with Greek alphabet.

  • beetroot.text.russian(text) ; Replaces English alphabet with Cyrillic alphabet.

  • beetroot.text.reverse(text) ; Self-explanatory. Reverses text.

  • beetroot.text.b65536encode(text) ; Encodes text into Base65536.

  • beetroot.text.base65536decode(text) ; Decodes Base65536.

  • beetroot.text.phoneencode(text) ; Encodes text using a cellphone keypad

  • beetroot.text.phonedecode(text) ; Reverses beetroot.text.phoneencode()

  • beetroot.text.dotify(text) ; Dotifies text, so “hi there” becomes “H.I. T.H.E.R.E.”

  • beetroot.text.spaceify(text) ; Spaceifies text, so “hi there” becomes “h i t h e r e”

Compression class:

  • beetroot.comp.compress(string) ; Compress an object using hybrid zlib/lzma

  • beetroot.comp.decompress(string) ; Reverses beetroot.comp.compress().

M A T H .

  • beetroot.math.increment(n) ; Increments n.

  • beetroot.math.double(n) ; Doubles n.

  • beetroot.math.square(n) ; Squares n.

  • beetroot.math.sqrt(n) ; Square roots n.

  • beetroot.math.factorial(n) ; Calculates the factorial of a number.

PICKLES.

  • beetroot.pkl.pkl(pickle, file_path_to_output_delicious_pickle) ; pass data and it gets turned into a big green pickle.

  • beetroot.pkl.unpkl(file_path_to_load_delicious_pickle_from) ; load pickle from pickle to eat pickle loaded from pickle.

Amazing functions that should be called whenever possible

  • beetroot.beetroot() ; A great function that you should call whenever you can

  • beetroot.totally_not_a_rickroll() ; Totally not a rickroll.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Beetroot-1.1.7.1.tar.gz (35.4 kB view hashes)

Uploaded Source

Built Distribution

Beetroot-1.1.7.1-py2.py3-none-any.whl (36.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page