Home > Zuo-s-Recipes-and-Drafts

Zuo-s-Recipes-and-Drafts

Zuo-s-Recipes-and-Drafts is a project mainly written in Python, based on the GPL-2.0 and 2 other licenses found.

Zuo's Recipes and Drafts: small pieces of (a probably useful) code

,--------------------------------------------------------------------. | Zuo's Recipes and Drafts: small pieces of (a probably useful) code | `--------------------------------------------------------------------'

[code in Python, unless explicitly marked differently]

Copyright (c) 2010, 2011 Jan Kaliszewski (zuo). All rights reserved.

All content is licensed under the MIT License (see: MIT_LICENSE), unless explicitly marked differently.


Repo content:

  • auxmethods.py [plus auxmethods_test.py] -- a module that provides an easy way to define and use your own CLOS-like around/before/after auxiliary methods (implemented using native Python features: decorators, class inheritance plus super(), private name mangling).

  • caseswitch.py -- a very fast switch/case-like dispatch tool (dict-or-list-based); -- you can define your dispatcher in an elegant, declarative way, as a class (possibly subclassing it...) with easy-to-use decorators; -- using subclasses does not affect efficiency.

  • clonetools/* -- tools for cloning classes and functions, useful when you need to "copy" a class or a function to adjust it (e.g. adding slots to all base clases), without hurting the original class/function object(s); -- IT'S AN ALPHA VERSION!

    • clonetools/flatmirror.py -- a submodule that can be used as a standalone module; -- for making "flat mirrors" of classes, i.e. fake subclasses with reduced class hierarchy.
  • flocktests.py -- tiny fcntl.flock() (Unix file lock) behaviour sampling script; -- an exemplary/educational piece of code (not a utility script).

  • mplogfilehandler.py [plus mplogfilehandler_quicktest.py] -- simple multiprocess-safe logging and interprocess locking classes; -- Unix implementation (flock-based) + generic abstract classes.

  • namedtuple_with_abc.py -- if you need to define named tuple subclasses (including reusable abstract ones) adding/overriding some methods; to have the named tuple ABC (abstract base class) for isinstance()/issubclass() tests; or simply would like to define your named tuple classes in a class-syntax-based and DRY way (without repeating type names...) -- this recipe is for you.

  • smoothloop.py -- use this script to automagically loop your .WAV instrument samples (to use them in any music sequencer/tracker, e.g. MilkyTracker...); -- requires numpy; -- licenced under GPL 2+ (see: LICENSE_GPL2 and LICENSE_GPL3).

  • trace_logging.py -- just import + call -- and you can filter and log your call/return/ exception/etc. events (you can use the standard Python logging framework or pass your custom logging-or-doing-anything object); -- quite a flexible tool and about 50 effective SLOC only (excluding the example script); -- for debugging rather than for production (programs noticeably slow down).

  • ...to be continued :)

Previous:demo_app