Exemple #1
0
#!/usr/bin/env python

import os
import ConfigParser as cp
import click
from pyexpo import PySpace, Action
from pyexpo.utils import abs_dir


tdata_abspath = abs_dir(__file__) / '../tests/data'
paths = [
    abs_dir(tdata_abspath) / 'path1',
    abs_dir(tdata_abspath) / 'path2',
    abs_dir(tdata_abspath) / 'basic',
]


class ModuleCLI(click.MultiCommand):
    #it's for Package also!
    def __init__(self, *args, **kwargs):
        self._pyobject = kwargs.pop('pyobject', None)
        super(ModuleCLI, self).__init__(*args, **kwargs)

    def list_commands(self, ctx):
        return [so.name.split('.')[-1] for so in self._pyobject.children]

    def get_command(self, ctx, name):
        child = self._pyobject[name]
        if isinstance(child, Action):
            return ActionCLI(name, pyobject=child)
        else:
Exemple #2
0
from pyexpo import explore_paths, PySpace, Package
from pyexpo.utils import abs_dir
import os

DATA_DIR = abs_dir(__file__) / 'data'

PATH1      = abs_dir(DATA_DIR) / 'path1'
PATH2      = abs_dir(DATA_DIR) / 'path2'
PATH_BASIC = abs_dir(DATA_DIR) / 'basic'

PATHS = (PATH1, PATH2, PATH_BASIC)


def setup():
    print "SETUP!"


def teardown():
    print "TEAR DOWN!"


def test__simple():
    names = {i.name for i in explore_paths(PATHS)}
    assert 'pkg_bar' in names


def test__toplevel_package():
    space = PySpace(only_paths=PATHS)
    p = space['foo']
    # variants:
    #p = space.get('foo')