Skip to main content

Some cute utilties for my other projects

Project description

iroiro

A swiss-knife-like library that collects cute utilities for my other projects.

This library only depends on Python standard library and Python itself. It's functionalities will not depend on any third-party packages in a foreseeable future.

Examples:

# color strings
import iroiro
iroiro.orange('TEXT')   # \033[38;5;214mTEXT\033[m

# Invoke external command and retrieve the result.
p = iroiro.run(['seq', '5'])
p.stdout.lines  # ['1', '2', '3', '4', '5']

# Invoke external command and retrieve the result in a non-blocking manner.
# Functions could be used as command, so they could be mixed in pipe line.
p1 = iroiro.command(['seq', '5'])

def func(streams, *args):
    for line in streams[0]:
        streams[1].writeline('iro: {}'.format(line))

p2 = iroiro.command(func, stdin=True)

iroiro.pipe(p1.stdout, p2.stdin)
p1.run()
p2.run()
p2.stdout.lines   # ['iro: 1', 'iro: 2', 'iro: 3', 'iro: 4', 'iro: 5']

From my own perspective, Python's subprocess interface is not friendly enough for simple uses.

For more detailed API usage, see doc/iroiro.md

Installation

sh$ pip3 install iroiro

Or just copy the whole folder to your machine, and add the path to sys.path:

import sys
sys.path.insert(0, '/some/path/to/place/iroiro')
import iroiro

Test

Testing:

sh$ python3 -m unittest

With pytest-cov:

sh$ pipx install pytest-cov --include-deps

or

sh$ pipx install pytest
sh$ pipx runpip pytest install pytest-cov

sh$ pytest --cov=iroiro --cov-report=html

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

iroiro-0.3.1.tar.gz (70.2 kB view details)

Uploaded Source

Built Distribution

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

iroiro-0.3.1-py3-none-any.whl (63.0 kB view details)

Uploaded Python 3

File details

Details for the file iroiro-0.3.1.tar.gz.

File metadata

  • Download URL: iroiro-0.3.1.tar.gz
  • Upload date:
  • Size: 70.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for iroiro-0.3.1.tar.gz
Algorithm Hash digest
SHA256 43c0c5619979411ccda804fb398bf8038c8d25f5d664f0a25be90e67793c7546
MD5 528cb4cbd729b6461977e4304eb65472
BLAKE2b-256 9a0ab3114d7df8d5191c01df5461ec4e78a77d8719aa95c8b4f85b62e87b4a27

See more details on using hashes here.

File details

Details for the file iroiro-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: iroiro-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 63.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for iroiro-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 285c04000757ee8973efb543ba6cd0b3f85517480f924efec48e1d73ef8e4a29
MD5 04c6dbf54e73f2009a6de40f71d2fe50
BLAKE2b-256 ad63a61a02adb06cdb904433bde558d8f938f9752f39ac22dcca827ebcfa091a

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