Skip to main content

Common utilities to ease development of Python packages

Project description

https://badge.fury.io/py/easydev.svg https://github.com/cokelaer/easydev/actions/workflows/main.yml/badge.svg https://coveralls.io/repos/cokelaer/easydev/badge.svg?branch=main https://static.pepy.tech/personalized-badge/easydev?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
documentation:

http://easydev-python.readthedocs.io/en/latest/

contributions:

Please join https://github.com/cokelaer/easydev

source:

Please use https://github.com/cokelaer/easydev

issues:

Please use https://github.com/cokelaer/easydev/issues

Python version supported:

3.9, 3.10, 3.11, 3.12, 3.13, 3.14

Overview

The easydev package provides miscellaneous utility functions and classes that are repeatedly useful during the development of Python packages. The goal is to help developers speed up their work by providing ready-to-use tools for common tasks such as parameter validation, logging, progress bars, configuration files, multiprocessing, and more.

It has been used as an incubator for other packages (e.g., colormap) and is used in projects such as bioservices, sequana, and GDSCTools.

Installation

Install the latest release from PyPI:

pip install easydev

Features

  • Parameter validationcheck_param_in_list, check_range

  • Dictionary utilitiesswapdict, AttrDict (access dict keys as attributes, supports nested dicts)

  • Logging – coloured logging via Logging class

  • Progress barProgress works in Python, IPython, and Jupyter notebooks

  • Timer – measure elapsed time with the Timer context manager

  • Profilingdo_profile decorator using line_profiler

  • Configuration filesCustomConfig and DynamicConfigParser for INI-style config management

  • Shell commandsshellcmd and execute wrappers around subprocess/pexpect

  • File utilitiestouch, mkdirs, md5

  • MultiprocessingMultiProcessing class for easy parallel job execution

  • Codecsto_list, list2string and other conversion helpers

  • URL utilitiesisurl_reachable and related helpers

  • Sphinx integration – bundled Sphinx theme and copybutton extension

Quick Start

Parameter validation:

from easydev import check_param_in_list, check_range

check_param_in_list("on", ["on", "off"])   # passes silently
check_range(0.5, 0, 1)                     # passes silently

AttrDict – access nested dictionary keys as attributes:

from easydev import AttrDict

d = AttrDict(**{"server": {"host": "localhost", "port": 8080}})
print(d.server.host)   # localhost
d.server.port = 9090

Coloured logging:

from easydev import Logging

logger = Logging("myapp", "WARNING")
logger.warning("something went wrong")
logger.debug("not shown at WARNING level")
logger.level = "DEBUG"
logger.debug("now it is shown")

Progress bar:

from easydev import Progress

pb = Progress(100)
for i in range(100):
    # do work here
    pb.animate(i + 1)

Timer:

from easydev import Timer
import time

times = []
with Timer(times):
    time.sleep(0.1)
print(f"elapsed: {times[0]:.2f}s")

Multiprocessing:

from easydev.multicore import MultiProcessing

def square(n):
    return n * n

t = MultiProcessing(maxcpu=4)
for i in range(10):
    t.add_job(square, i)
t.run()
print(t.results)

Changelog

Version

Description

0.13.3

  • update pyproject with contribs from @s-t-e-v-e-n-k see PR37

0.13.2

0.13.1

  • fix get_dependencies

0.13.0

  • fix requirements (line_profiler) and CI

0.12.2

  • For developers: move to pyproject. add precommit

  • replace pkg_resources (deprecated) with importlib

  • replace appdirs with more generic platformdirs

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

easydev-0.14.0.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

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

easydev-0.14.0-py3-none-any.whl (57.7 kB view details)

Uploaded Python 3

File details

Details for the file easydev-0.14.0.tar.gz.

File metadata

  • Download URL: easydev-0.14.0.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for easydev-0.14.0.tar.gz
Algorithm Hash digest
SHA256 da3c82b89debe71c13d946a6514a85bdc3034fa878aeaf9d361721f07ac42f44
MD5 767b521a08ba0409a83a26b195feb905
BLAKE2b-256 f8bda73fd1828ab7e152d9c71123396b581c529f3b01f37a1e845339f476e18d

See more details on using hashes here.

File details

Details for the file easydev-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: easydev-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 57.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.14 Linux/6.14.5-100.fc40.x86_64

File hashes

Hashes for easydev-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 774cce412ad543ef707fc3f437eff200422bee4ca2b1b7e063fa5ca40b48d942
MD5 8a82c3a3cdfe181e9dac8949afeb363a
BLAKE2b-256 0f4d1f697261368745b5d6cdfc952bb91cfa9fb72c74bf1c5d120039571922fe

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