nimblebox logo
Docs
v2.1.0

nbox.utils

Utility objects and functions.

This has a couple of cool things:

  • get_logger: a master logger for nbox, this can be modified to log through anything
  • isthere: a decorator that checks if a package is installed, if not it raises an error It is more complicated than it needs to be because it is seedling for a way to package functions and code together so that it can be used in a more dynamic way.
  • get_files_in_folder: a function that returns all files in a folder with a certain extension
  • fetch: a function that fetches a url and caches it in tempdir for faster loading
  • get_random_name: a function that returns a random name, if True is passed returns an uuid4() for truly random names :)
  • hash_: a function that returns a hash of any python object, string is accurate, others might be anything, but atleast it returns something.
  • folder/join: to be used in pair, join(folder(__file__), "server_temp.jinja") means relative path "../other.py". Scattered throughout the codebase, the super generic name will bite me.
  • to_pickle/from_pickle: to be used in pair, to_pickle(obj, "path") and from_pickle("path") to save and load python objects to disk.
  • DBase: सस्ता-protobuf (cheap protobuf), can be nested and get_dict will get for all children
  • PoolBranch: Or how to use multiprocessing, but blocked so you don't have to give a shit about it.

Functions

iconfunctionget_logger
[source]
iconfunctionlog_traceback
[source]
iconfunctiondeprecation_warning
[source]
iconfunctionload_module_from_path
[source]
iconfunctionisthere
[source]
(soft:bool)
Parameters
  • soft -

    If False raises ImportError. Defaults to True.

Checks all the packages

iconfunctionget_files_in_folder
[source]

Get files with ext in folder

iconfunctionfetch
[source]

Fetch and cache a url for faster loading, force re-downloads

iconfunctionfolder
[source]

get the folder of this file path

iconfunctionjoin
[source]

convienience function for os.path.join

iconfunctionto_pickle
[source]
iconfunctionfrom_pickle
[source]
iconfunctionpy_to_bs64
[source]
iconfunctionpy_from_bs64
[source]
iconfunctionto_json
[source]
iconfunctionfrom_json
[source]
iconfunctionget_assets_folder
[source]
iconfunctionget_random_name
[source]

Get a random name, if uuid is True, return a uuid4

iconfunctionhash_
[source]

Hash sting of any item

iconfunctionget_mime_type
[source]
iconfunctionthreaded_map
[source]

inputs is a list of tuples, each tuple is the input for single invocation of fn. order is preserved.

iconfunction_exit_program
[source]

Classes

iconclassenv
[source]
iconfunctionset
[source]
iconfunctionget
[source]
iconclassFileLogger
[source]
iconfunction__init__
[source]
iconfunctionlog
[source]
iconclassDBase
[source]
iconfunction__init__
[source]
iconfunctionget
[source]
iconfunctionget_dict
[source]
iconfunction__repr__
[source]
iconfunctionjson
[source]
iconclassSimplerTimes
[source]
iconfunctionget_now_datetime
[source]
iconfunctionget_now_float
[source]
iconfunctionget_now_i64
[source]
iconfunctionget_now_str
[source]
iconfunctionget_now_pb
[source]
iconfunctioni64_to_datetime
[source]
nbox SDKnbox provides built in access to all the APIs and packages them in the most user friendly manner.Star 0