Skip to main content

Developer's tools

Project description

mbmutils

Simpmle common utilities.

Installation

pip install mbmutils

f-Functions

The f-functions are simple string utilities of common actions. They have the standard pattern of:

return string after|before|between the keys

These all use the "first found" index. Meaning if there are more than one instance of the key found, they use the first. Because of this there are functions that look from the front (f_left | f_right) and functions that look from the back (f_left_back | f_right_back).

function Description
f_right return everything to the right of the key
f_left return everything to the left of the key
f_right_back return everything to the right of the key, starting from the back
f_left_back return everything to the left of the key, starting from the back
f_between return everything between the keys

You will also find a not_found parameter to these functions. This allows you to define what is returned if the key is not found in the string.

Examples

from mbmutils import mu

my_string = "hello there fancy world!"

print({mu.f_right(my_string, ' fancy ')})
# -> world!

print({mu.f_left(my_string, ' fancy ')})
# -> hello there 

print({mu.f_left(my_string, 'will not find')})
# -> None 

print({mu.f_left(my_string, 'will not find',
                 not_found="not here")})
# -> not here 

Path functions

There are also a few path-finding functions that search for a path containing the partial_path provided. These will search the current path and then begin looking upward from there.

There are 2 functions: 1 for files and the other for directories.

from mbmutils import mu

# assuming current folder is
# /path/to/python/code
mu.find_folder_path('data')
# will return the first valid:
#   -> path/to/python/code/data
#   -> path/to/python/data
#   -> path/to/data
#   -> path/data

# again, assuming current folder is
# /path/to/python/code
mu.find_folder_path('my_file.json')
# will return the first valid:
#   -> path/to/python/code/my_file.json
#   -> path/to/python/my_file.json
#   -> path/to/my_file.json
#   -> path/my_file.json

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

mbmutils-1.2.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mbmutils-1.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file mbmutils-1.2.0.tar.gz.

File metadata

  • Download URL: mbmutils-1.2.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for mbmutils-1.2.0.tar.gz
Algorithm Hash digest
SHA256 21a89e088e8e5a2fae44b2ef203b708f8a444aa03789ad7823b9ba6c22e53c4f
MD5 02f3d195b03084524e47b42fcc9c6774
BLAKE2b-256 1b6c27f358857333019537e584074a5d7154fa4b7ea63ebc27d8e814721dda84

See more details on using hashes here.

File details

Details for the file mbmutils-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: mbmutils-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.9

File hashes

Hashes for mbmutils-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a34e20b5366c8ea422b6fcc8429c40a61cad08ae64001ca09fabd55fe796311a
MD5 01dbf18fb7eeba73c5c89153a5fec99b
BLAKE2b-256 9de9755c11c4aa4da433f4357bb468cece8e20e0d43864810915d39021845bb4

See more details on using hashes here.

Supported by

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