Stuff i use in my projects
Project description
Dexv-Stuff
Stuff i use in my projects
Installation
pip install dexvstuff
Features
- Logger: My own logger which i like
- Files: Simplified file operations
- JsdomRuntime: Execute js in a dom environment
- Wabt: WebAssembly Binary Toolkit wrapper for Python. For a better WABT wrapper, check out wabt.py
Usage
Logger
from dexvstuff import Logger
# basic logger
log = Logger()
# customized
log = Logger(prefix="Dexv", indent=2) # prefix is optional, indent can be any number (default is 0)
log.info("This is an info message")
log.success("This is a success message")
log.warning("This is a warning message")
log.failure("This is a failure message")
log.debug("This is a debug message")
log.captcha("This is a captcha message")
log.PETC() # Press Enter To Continue
Files
from dexvstuff import Files
Files.create("example.txt")
Files.create(["dir1/file1.txt", "dir2/file2.txt"])
Files.write("example.txt", "Dexvstuff is cool")
print(Files.read("example.txt"))
Files.append("example.txt", "\nDexvstuff is even cooler")
print(Files.get_file_size("example.txt"))
Files.delete("example.txt")
JsdomRuntime
from dexvstuff import JsdomRuntime
runtime = JsdomRuntime()
print(runtime.eval("console.log('Dexvstuff is cool')"))
print(runtime.eval("new Promise((resolve) => setTimeout(() => resolve('Dexvstuff is cool'), 1000))", promise=True)) # resolves promises
print(runtime.eval('''(function() { return new Uint8Array([1, 2, 3]) })()''', byte_array=False)) # support js byte arrays
Wabt
from dexvstuff import Wabt
wabt = Wabt()
wat_output, errors = wabt.wasm2wat("example.wasm")
wasm_output, errors = wabt.wat2wasm("example.wat")
objdump_output, errors = wabt.wasm_objdump("example.wasm")
...
Documentation
Logger
Logger(prefix=None, indent=0)
: create a new logger instanceprefix
: optional string to prefix all messages (default: None)indent
: number of spaces to indent messages (default: 0)
info(message)
: info messagesuccess(message)
: success messagewarning(message)
: warning messagefailure(message)
: error messagedebug(message)
: debug message (only shown in debug mode)captcha(message)
: captcha-related messagePETC()
: pause execution until Enter is pressed
Files
create(path)
: create file or directoryread(path)
: read file contentwrite(path, content)
: write content to fileappend(path, content)
: append content to filedelete(path)
: delete fileget_file_size(path)
: get file size in bytesexists(path)
: check if file/directory exists
JsdomRuntime
eval(code, promise=False, byte_array=False)
: execute JavaScript codepromise
: set to True if code returns a promisebyte_array
: set to True if code returns a byte array
Wabt
wat2wasm(file)
: convert .wat to .wasmwasm2wat(file)
: convert .wasm to .watwasm_objdump(file)
: inspect WASM filewasm_decompile(file)
: decompile WASM to C-like code- All WABT tools are supported but not all are defined in the wrapper, you can still use them through dynamic attribute access
- Example:
wabt.wasm_validate('file.wasm')
will call the wasm-validate tool - See WABT documentation for all available tools
- Example:
License
MIT License - See LICENSE for more information
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
dexvstuff-0.0.6.tar.gz
(6.3 kB
view details)
Built Distribution
File details
Details for the file dexvstuff-0.0.6.tar.gz
.
File metadata
- Download URL: dexvstuff-0.0.6.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
66cd8237416ca571d26796e48053b80dbecc5430149a4ca4f475019f1b7fda3d
|
|
MD5 |
b9b296f1a9daabd3d1c15e0e5fc639d4
|
|
BLAKE2b-256 |
4836af2ea5e1fe54f5473222de98ff4533e45df429311d6dc9170485466c629c
|
File details
Details for the file dexvstuff-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: dexvstuff-0.0.6-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
bdd2fce0d824ff40c6fbc006d684489b695b2d69ef813f19a908f4f169ba0d01
|
|
MD5 |
b6cc92fa67725709a710d24ad0ca29aa
|
|
BLAKE2b-256 |
47b44f1a92c94a8da666b7ce6a37ed76c68cf6777b90d9e65de8c8c2b451ed28
|