A packe for all things that should be native
Project description
SbNative
An extention to python for debugging and such. Things that, well Should Be Native
SbNative may be used for
- private projects.
- public projects (The SbNative repo must be referenced in a Readme in case the source code is available.)
DO NOT DISTRIBUTE.
ALL NON MENTIONED RIGHTS RESERVED.
Chapter 1: debugging
All of the neccessary dependencies are located or imported in the debugtools.py file.
-
switchTerminalStacking. Terminal stacking is a method for compressing logged information into a single line if possible. Ex:from sbNative.debugtools import log for _ in range(10): log("this module should be native!")
leads to this result when not using terminal stacking:
LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5 LOG: this module should be native! --> c:FILEPATH.py:5which obviously is not very clean... Instead, doing this:
from sbNative.debugtools import log,switchTerminalStacking switchTerminalStacking() for _ in range(10): log("this module should be native!")
leads to an arguably cleaner output:
LOG: this module should be native! --> c:FILEPATH.py:7 [10x] -
log. Prints all the arguments given to the console and the file + line of the call. Supports more advanced logging when paired with thecleanReprclass decorator. As shown above, it also claryfies that a value has been logged. The reason for the file and line are to find it and edit/remove the logging call quickly. In many editors, (also VSCODE) you may CTRL+LEFTCLICK the line and it will redirect you to the file and corresponding line of the log call. Ex:LOG: this module should be native! --> c:/---/Desktop/test1.py:6The depth parameter controls how far the lookup into the callstack watches for the filename and number after the
-->. This is a feature for functions written by you, to redirect the user or yourself to the line your function was called at. Incrementing goes further into the callstack. Default: 2. -
ilog. "Info Log". Behaves largely likelogFirst argument will be used to represent what is being logged. -
isFromCall. Gets if a function with the namefuncNameis in the callstack. Used by__clsReprto determine if it should add markers in the form oflignSplitSignwhere newlines can be added if the logging string is too long. -
cleanRepr. A decorator which makes the representation of your class as clean as possible. If you don't want specific class or instance variables to be included, you may specify thier name as arguments for this function. -
getTerminalOutputs. Returns the terminal output content recorded while the function was running, and the result from the function in a tuple. (TerminalOutput,FunctionResult) WARNING: THIS FUNCTION ALLOCATES THE RESULT TO YOUR DRIVE AND NOT MEMORY. PRINTING MAY BE VERY SLOW, DO NOT EVER USE IN PRODUCTION WITH HIGH WORKLOADS. -
timer. A simple decorator for timing the execution time of a function or method. Brags about theilogfunction. (: -
tPlotArgsEnums or "Flags" to sort after the execution times of the functions or the arguments passed to the function. -
timePlotterWorks the same way as thetimerdecorator, tho it returns an object and the decorator is the functiontimePlotter.time. The major difference is the ability to plot the times on a matplotlib graph. You can sort the time or arguments with the Enums fromtPlotArgs. The reverse kwarg may only reverse the x axis. The arguments or keyarguments that are supposed to be displayed on the plot have to be passed into thetrackArgs/trackKwargsparameters. For args, these have to be the indicies of the argument, for kwargs the name of the keyword-argument. Decorate the function to be tracked with thetimermethod, and plot them with theshowone. You may not use the same instance on multiple functions, otherwise, an error will be raised.
Chapter 2: runtime utilities
All of the neccessary dependencies are located or imported in the runtimetools.py file.
-
getPathRetrieves the path of the file it has been called in. Returns aPathobject from the built-inpathlibmodule. -
globaliseAllSubitemsAdds all the subitems of a module or folder containing a__init__.pyfile to the global scope, do not ever use this function if you are not desperate, the IDE wont recognise its behaviour. -
execWithExcTbExtends the built-inexecfunction, tho shows the exceptions when one is raised, with the appropriate format. -
castToTypeHintNOT IMPLEMENTED COMPLETELY YET. -
safeIterAllows iteration and removal of items inside the iterable simultaneously.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sbNative-0.0.6.tar.gz.
File metadata
- Download URL: sbNative-0.0.6.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c43671fae08dd1c68822f04cb94c808c3b7679aaaee2539006e600035b5ef08b
|
|
| MD5 |
137ff6dfbcb58caac73006e39a0b6d82
|
|
| BLAKE2b-256 |
3b0cb60e7370e14cce1aec5c9649fcfe1e730fc12056379b4272497e7505ce13
|
File details
Details for the file sbNative-0.0.6-py3-none-any.whl.
File metadata
- Download URL: sbNative-0.0.6-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d2575d5b9f6eee49850d8da904d260f42a4e6f709c06e95a21d8ede03b36959
|
|
| MD5 |
d5716eec250fa2b27d49b3287fd1bc87
|
|
| BLAKE2b-256 |
8b945b71707d6c114bc3799c4162380a74e7fd3dbfaef0026e06ffd9292a01ad
|