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.1.0.tar.gz (2.8 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.1.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mbmutils-1.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for mbmutils-1.1.0.tar.gz
Algorithm Hash digest
SHA256 733fe857d91465988ba15f616b867657f4db325511930559b2bfc1b42a6c11fe
MD5 23816f223d2bdbb396a7b7d35732580e
BLAKE2b-256 dfcbd9f7f4e6b63d09fa3a8f4a97d9bb2d6575f0c0ab11dfd9f03d578632ef14

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mbmutils-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.13

File hashes

Hashes for mbmutils-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb4d81c0253ef4bef5cbbee5e77181489795e65f66311c6dc354592dfb7ac443
MD5 a6dc895bda59b5a717eddfa63c90cb1f
BLAKE2b-256 1cec0e7d264e5b89327220441ee14ae9f8d540408ab3e1751d1714731665ec2c

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