Ejemplo n.º 1
0
    def test_getmembers(self):
        """ Test getmembers() """
        m = exdoc.getmembers(C)
        self.assertEqual(m, [
            ('c', C.c),
            ('f', C.f),
            ('p', C.p),
            ('s', C.s),
        ])

        # Try with predicate
        m = exdoc.getmembers(C, lambda key, value: key not in ('p', 's'))
        self.assertEqual(m, [
            ('c', C.c),
            ('f', C.f),
        ])
Ejemplo n.º 2
0
    def test_getmembers(self):
        """ Test getmembers() """
        m = exdoc.getmembers(C)
        self.assertEqual(list(m), [
            ('c', C.c),
            ('f', C.f),
            ('p', C.p),
            ('s', C.s),
        ])

        # Try with predicate
        m = exdoc.getmembers(C, lambda key, value: key not in ('p', 's'))
        self.assertEqual(list(m), [
            ('c', C.c),
            ('f', C.f),
        ])
Ejemplo n.º 3
0
def doccls(cls, *predicates):
    return {
        'class': doc(cls),
        'attrs':
        {key: doc(value, cls)
         for key, value in getmembers(cls, *predicates)},
    }
Ejemplo n.º 4
0
def docmodule(module, *predicates):
    return {
        'module': doc(module),
        'attrs':
        {key: doc(value)
         for key, value in getmembers(module, *predicates)},
    }
Ejemplo n.º 5
0
import mailem
from exdoc import doc, getmembers

import json

doccls = lambda cls, *predicates: {
    'cls': doc(cls),
    'attrs': {name: doc(m) for name, m in getmembers(cls, *predicates)}
}

data = {
    'mailem': doc(mailem),
    'Message': doc(mailem.Message),
    'Attachment': doc(mailem.Attachment),
    'ImageAttachment': doc(mailem.ImageAttachment),
    'Postman': doccls(mailem.Postman),
    'connection': doc(mailem.connection),
    'SMTPConnection': doc(mailem.connection.SMTPConnection),
    'LoopbackConnection': doc(mailem.connection.LoopbackConnection),
    'Template': doccls(mailem.template.Template, None, lambda k, v: k=='__call__' or not k.startswith('_')),
    'TemplateRegistry': doccls(mailem.template.TemplateRegistry),
}

print json.dumps(data, indent=2)
Ejemplo n.º 6
0
#! /usr/bin/env python

import json
import inspect
from exdoc import doc, getmembers

import j2cli
import j2cli.context
import j2cli.extras.filters


README = {
    'formats': {
        name: doc(f)
        for name, f in j2cli.context.FORMATS.items()
    },
    'extras': {
        'filters': [doc(v)
                    for k, v in getmembers(j2cli.extras.filters)
                    if inspect.isfunction(v) and inspect.getmodule(v) is j2cli.extras.filters]
    }
}

print(json.dumps(README))
Ejemplo n.º 7
0
import good, good.schema.errors, good.voluptuous
from exdoc import doc, getmembers

import json

doccls = lambda cls, *allowed_keys: {
    'cls': doc(cls),
    'attrs': {name: doc(m, cls) for name, m in getmembers(cls, None, lambda key, value: key in allowed_keys or not key.startswith('_'))}
}

joindict = lambda *dicts: reduce(lambda memo, d: memo.update(d) or memo, dicts, {})

docmodule = lambda mod: {
    'module': doc(mod),
    'members': [ doc(getattr(mod, name)) for name in mod.__all__]
}

data = {
    'good': doc(good),
    'voluptuous': doc(good.voluptuous),

    'Schema': doccls(good.Schema, None, '__call__'),
    'errors': doc(good.schema.errors),
    'Invalid': doccls(good.Invalid),
    'MultipleInvalid': doccls(good.MultipleInvalid),
    'markers': docmodule(good.markers),

    'helpers': docmodule(good.helpers),

    'predicates': docmodule(good.validators.predicates),
    'types': docmodule(good.validators.types),
Ejemplo n.º 8
0
import json
from exdoc import doc, getmembers, subclasses

# Methods
doccls = lambda cls, *allowed_keys: {
    'cls': doc(cls),
    'attrs': {name: doc(m, cls)
              for name, m in getmembers(cls, None,
                                        lambda key, value: key in allowed_keys or not key.startswith('_'))}
}

docmodule = lambda mod: {
    'module': doc(mod),
    'members': [ doc(getattr(mod, name)) for name in mod.__all__]
}

# Data
import mongosql
from mongosql.handlers import project, sort, group, filter, join, joinf, aggregate, limit, count
from mongosql import query, MongoQuerySettingsDict, StrictCrudHelperSettingsDict
from mongosql import ModelPropertyBags, CombinedBag, CountingQuery
from mongosql.crud import crudhelper, CrudHelper, StrictCrudHelper, CrudViewMixin, saves_relations

data = dict(
    mongosql=doc(mongosql),
    handlers=doc(mongosql.handlers),
    operations={
        m.__name__.rsplit('.', 1)[1]: doc(m)
        for m in (project, sort, group, filter, join, joinf, aggregate, limit, count)},
    mongosql_query=doc(mongosql.query),
Ejemplo n.º 9
0
#! /usr/bin/env python

import json
import inspect
from exdoc import doc, getmembers

import j2cli
import j2cli.context
import j2cli.extras.filters


README = {
    'formats': {
        name: doc(f)
        for name, f in j2cli.context.FORMATS.items()
    },
    'extras': {
        'filters': {k: doc(v)
                    for k, v in getmembers(j2cli.extras.filters)
                    if inspect.isfunction(v) and inspect.getmodule(v) is j2cli.extras.filters}
    }
}

assert 'yaml' in README['formats'], 'Looks like the YAML library is not installed!'

print(json.dumps(README))
Ejemplo n.º 10
0
def docmodule(module, *predicates):
    return {
        'module': doc(module),
        'attrs': {key: doc(value) for key, value in getmembers(module, *predicates)},
    }
Ejemplo n.º 11
0
#! /usr/bin/env python

import json
import inspect
from exdoc import doc, getmembers

import shinto_cli
import shinto_cli.context
import shinto_cli.extras.filters

README = {
    'formats':
    {name: doc(f)
     for name, f in shinto_cli.context.FORMATS.items()},
    'extras': {
        'filters': [
            doc(v) for k, v in getmembers(shinto_cli.extras.filters)
            if inspect.isfunction(v)
        ]
    }
}

print json.dumps(README)
Ejemplo n.º 12
0
def doccls(cls, *predicates):
    return {
        'class': doc(cls),
        'attrs': {key: doc(value) for key, value in getmembers(cls, *predicates)},
    }
Ejemplo n.º 13
0
def docmodule(module):
    return { name: doc(value)
             for name, value in list(getmembers(module)) + [('__module__', module)] }
Ejemplo n.º 14
0
def docmodule(module):
    return { name: doc(value)
             for name, value in getmembers(module) + [('__module__', module)] }
Ejemplo n.º 15
0
#! /usr/bin/env python

import json
import inspect
from exdoc import doc, getmembers

import shinto_cli
import shinto_cli.context
import shinto_cli.extras.filters


README = {
    'formats': {
        name: doc(f)
        for name, f in shinto_cli.context.FORMATS.items()
    },
    'extras': {
        'filters': [doc(v)
                    for k, v in getmembers(shinto_cli.extras.filters)
                    if inspect.isfunction(v)]
    }
}

print json.dumps(README)
Ejemplo n.º 16
0
#! /usr/bin/env python

import json
import inspect
from exdoc import doc, getmembers

import j2cli_3
import j2cli_3.context
import j2cli_3.extras.filters

README = {
    'formats':
    {name: doc(f)
     for name, f in list(j2cli_3.context.FORMATS.items())},
    'extras': {
        'filters': [
            doc(v) for k, v in getmembers(j2cli_3.extras.filters)
            if inspect.isfunction(v)
        ]
    }
}

print(json.dumps(README))