Skip to main content

Method behavior modification at runtime, made easy.

Project description

Harmonify

Harmonify is a Python library that allows users to change the behavior of classes at runtime, with nothing more than a few function calls. Inspired by Harmony (the very popular C# library that also allows runtime behavior modification), Harmonify is flexible and uses a simple system based on monkey-patching. Like its C# equivalent, it can be used for:

  • Debugging: Inject logging or checks into methods without changing them permanently.
  • Testing: Isolate parts of your code by temporarily changing how certain methods behave.
  • Extending Libraries: Add new features or modify behavior of classes from libraries you can't edit directly.
  • Experimentation: Play around with how code runs in a non-destructive way.

Features

  • Prefix Patching: Run your custom code before the original method executes.
  • Postfix Patching: Run your custom code after the original method executes, even allowing you to modify its return value.
  • Replace Patching: Completely swap out the original method's logic with your own.
  • Create & Delete methods: Add or remove methods from a class or a module, without changing the other ones.
  • Easy Unpatching: Restore methods to their original state with a simple call.

Installation

Installing Harmonify is as easy as using pip:

pip install harmonify

After that, Harmonify will be available globally!

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

harmonify_patcher-1.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

harmonify_patcher-1.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file harmonify_patcher-1.1.1.tar.gz.

File metadata

  • Download URL: harmonify_patcher-1.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for harmonify_patcher-1.1.1.tar.gz
Algorithm Hash digest
SHA256 118ba904f01fd222cb1bbb95aa16f12061e2df5093bc9d31712688fe1a5c8390
MD5 f2eb515c5022f6e5f026e00aa76c8b1f
BLAKE2b-256 c7cf89124bf5378f8372dc1a3bfb6d7ab743730789ac0cb81c1a801d74b2f4ee

See more details on using hashes here.

File details

Details for the file harmonify_patcher-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for harmonify_patcher-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c4c46450344c8d3f166304fc79150bf011d728fe4b00ca2fc85d6a84b5569f3
MD5 f4f4d9abc7ae097c44553e944b1857ce
BLAKE2b-256 f2d9a020ffe0e5ae0f7901b155b03b93d6678a547149c830100b4ce93090ee48

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