Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

basic utils for python3

Project description

Eic_utils

Utilities from python3 including coloful logs, procedure logs timer, basic image operation and so on.

Install

$ pip install eic_utils

Components

Cache

An quick data storage support [pickle, str, bin, json].

Functions

Function Instruction
items Lists items of caches.
remove Deletes a cache file.
dump Saves or rewrites a cache file.
load Loads from a cache file.

Examples

from eic_utils.cache import Cache
cache = Cache('/tmp/data')
cache.dump(data={'hi', 'hello'}, name='greeting.pkl')
print(cache.load(name='greeting.pkl'))
cache.dump(data='hi'.encode('utf-8'), name='greeting.bin', file_type='bin')
print(cache.load(name='greeting.bin', file_type='bin'))
cache.dump(data={'hi': 'hello'}, name='greeting.json', file_type='json')
print(cache.load(name='greeting.json', file_type='json'))
cache.dump(data={'hi', 'hello'}, name='greeting.txt', file_type='str')
print(cache.load(name='greeting.txt', file_type='str'))

print(cache.items())
cache.remove('greeting.txt')
print(cache.items())

image

colorful_str

Color List

Code Code1 Color
(#r) (#red) red
(#g) (#green) green
(#y) (#yellow) yellow
(#b) (#blue) blue
(#w) (#white) white
(#magenta) magenta
(#black) black
(#cyan) cyan
(#) default

Examples

from eic_utils.base import colorful_str
print(colorful_str('(#r)this is a red message.(#)',
				   'this is a normal message.',
				   '(#b)this is a blue value {}(#).'.format(2),
				   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.log('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.suc('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.err('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.wrn('(#r)this is a red message.(#)',
					   'this is a normal message.',
					   '(#b)this is a blue value {}(#).'.format(2),
					   '(#g)this is a green dict {}.'.format({1:2})))
print(colorful_str.dict({'a': 's', 'b': 's'}))

image

procedure

Log and Timer for a block of codes.

Examples

from eic_utils.base import procedure
with procedure('hi') as p:
    x = 123 + 123
    p.show_time('x has be calculated.', x)
    p.add_log('x =', x)
    y = x + 34
    p.add_log('y =', y)

with procedure('hi', new_line=True):
    pass

image

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for eic-utils, version 3.2
Filename, size File type Python version Upload date Hashes
Filename, size eic_utils-3.2-py3-none-any.whl (9.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size eic_utils-3.2.tar.gz (8.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page