Skip to main content

Basic utils in Python.

Project description

pybasics - 0.3

Basic utils in Python.

Install

pip3 install pybasics

Examples

# Read/Write text files
from pybasics import read_file
from pybasics import write_file

str_data = read_file('data.dat', split=False)
write_file('data.dat', str_data, mode='w', join=False)


# Read/Wite json files and pretty print
from pybasics import read_json
from pybasics import write_json
from pybasics import pretty_json

json_data = read_json('data.json')
pretty_json(json_data)
write_json('data.json', json_data)


# Read/Write pickle binary files
from pybasics import read_pickle
from pybasics import write_pickle

pickle_data = read_pickle('data.pickle')
write_pickle('data.pickle', pickle_data)


# Get list of subdirectories in path
from pybasics import list_dir

subdirs = list_dir('.')


# Get filename with most recent modification in path
from pybasics import last_file

lastfile = last_file('.')


# Requests
from pybasics import try_except
from pybasics import webcheck

url = 'https://google.com'

if webcheck(url):
  # Run your code
  pass

data = try_except(url)


# Mongodb
from pybasics import mgdb
from pybasics import mgcol

mydb = mgcol('dbname', create=False, port=27017)
mycol = mgcol('dbname', 'colname', create=False, port=27017)

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

pybasics-0.3.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

pybasics-0.3.2-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pybasics-0.3.2.tar.gz.

File metadata

  • Download URL: pybasics-0.3.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for pybasics-0.3.2.tar.gz
Algorithm Hash digest
SHA256 bbdeebd44932a14deeef571a9ff5ff8a0b88382d254eaa15c8fe4f9839af280f
MD5 e3c9bad563e12d9166e82f2a6ff9951d
BLAKE2b-256 50dcb2fe2a40e960f7bc7c08e78c20c3edcd6c4efcd5ee734e9babb9923bc8ac

See more details on using hashes here.

File details

Details for the file pybasics-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pybasics-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for pybasics-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee44a2c7508c9f02218694a67e4b2cce8ec46593bb0001cf6f3f3c26f12af2cb
MD5 8735ef2e735bbee285c8615ad4c85bf3
BLAKE2b-256 18895ae81c643793e914894d0018e24825cdf4637d8a45f007a82dbda9ad756b

See more details on using hashes here.

Supported by

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