A Python implementation of the classic cowsay program for generating ASCII art with various characters delivering messages
npx @tessl/cli install tessl/pypi-cowpy@1.1.0A Python implementation of the classic cowsay program that generates ASCII art with various characters (cowacters) delivering messages in speech or thought bubbles. Cowpy provides both a command-line interface and a Python library with 45 different character designs.
pip install cowpycowpyfrom cowpy import cowAccess specific cowacter classes directly:
# Individual cowacter classes
from cowpy.cow import Moose, Vader, Tux, HelloKitty
from cowpy.cow import EYES, COWACTERS # Constantsfrom cowpy import cow
# Create a specific cowacter
moose = cow.Moose()
message = moose.milk("Hello from the moose!")
print(message)
# Use different options
cow_with_thoughts = cow.Moose(thoughts=True, eyes='dead', tongue=True)
message = cow_with_thoughts.milk("I'm thinking...")
print(message)
# Get a cowacter by name
cow_class = cow.get_cow('vader')
vader = cow_class()
message = vader.milk("I am your father")
print(message)
# Generate random cowacter output
random_message = cow.milk_random_cow("Random fun!")
print(random_message)Cowpy uses a class-based architecture centered around the Cowacter base class:
The foundation of cowpy's functionality, providing the base Cowacter class and instantiation methods.
class Cowacter:
def __init__(self, eyes='default', thoughts=False, tongue=False, body=None): ...
def milk(self, msg): ...
def get_cow(name='default'): ...Helper functions for listing available options and generating random output.
def eye_options(): ...
def cow_options(): ...
def milk_random_cow(msg, sfw=True): ...
def get_cowacters(sfw=True, sort=False): ...
def get_eyes(sfw=True, sort=False): ...
def not_safe_for_work(cow='', eyes=''): ...Complete CLI implementation with argument parsing and interactive features.
def main(): ...The CLI supports extensive options including cowacter selection, eye customization, thought bubbles, tongue display, random selection, and NSFW content filtering.
# Eye type options
EYES = {
'default': "oo",
'borg': "==",
'dead': "xx",
'greedy': "$$",
'paranoid': "@@",
'stoned': "**",
'tired': "--",
'wired': "OO",
'young': ".."
}
# NSFW content identifiers
NOT_SAFE_FOR_WORK_COWACTERS = ['bongcow', 'sodomized', 'headincow', 'telebears']
NOT_SAFE_FOR_WORK_EYES = ['stoned']