Skip to content

alok1974/compage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compage

Generic reusable python utilities and tools.

compage.services


Classes, Functions and other Objects can be stored and retrieved when needed. Painless implementation of patterns like Dependency Injection.

from compage.service import ServiceManager as mgr


# Code to be injected
class ToBeInjected(object):
    foo = 'foo'


# Injection is expected here
class InjectionReceiver(object):
    def __init__(self, injected_code):
        self._injected_code = injected_code

    @property
    def injected_code(self):
        return self._injected_code


# Injection code added to the manager
mgr.add('injected', ToBeInjected())

# Injection
toBeInjected = mgr.get('injected')
target = InjectionReceiver(toBeInjected)

assert target.injected_code.foo == 'foo'

compage.installutils


Light weight package installer a la setup.py(distutils).

Example: Installs (copies) package foo from the /src/foo/ to /custom/site-packages/

from compage.installutil import setup

# install - `True` to install, `False` to uninstall
install = True

# force_update - `True` to overwrite(update) existing package
force_update = False

# ignore - `list` of glob-style patterns to ignore files and directories while
# copying from `src_dir` to `site`
ignore = ['*.pyc']

# site - location where the package should be installed. Note that this
# location should be in sys.path
site = '/custom/site-packages/'

# package_name - Name of the package to install
package_name = 'foo'

# src_dir - Path to source code directory
src_dir = '/src/foo/'

args = [site, package_name]
kwargs = {
    'src_dir': src_dir,
    'install': install,
    'force_update': force_update,
    'ignore': ignore,
}

setup(*args, **kwargs)

About

Generic python utilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages