init_example

class kafkaaggregator.cli.init_example(ctx: Context, *args: Any, key_serializer: Optional[Union[CodecT, str]] = None, value_serializer: Optional[Union[CodecT, str]] = None, **kwargs: Any)

Bases: AppCommand

Initialize the source topic used in the aggregation example.

Attributes Summary

abstract

blocking_timeout

Return the blocking timeout used for this command.

builtin_options

console_port

Return the :pypi:`aiomonitor` console port.

daemon

loglevel

Return the log level used for this command.

options

prog_name

redirect_stdouts

redirect_stdouts_level

require_app

Methods Summary

__call__(*args, **kwargs)

Call command-line command.

abbreviate_fqdn(name, *[, prefix])

Abbreviate fully-qualified Python name, by removing origin.

as_click_command()

Convert command into :pypi:`click` command.

as_service(loop, *args, **kwargs)

Wrap command in a mode.Service object.

bold(text)

Return text in bold.

bold_tail(text, *[, sep])

Put bold emphasis on the last part of a foo.bar.baz string.

carp(s, **kwargs)

Print something to stdout (or use file=stderr kwargs).

color(name, text)

Return text having a certain color by name.

dark(text)

Return cursor text.

dumps(obj)

Serialize object using JSON.

execute(*args, **kwargs)

Execute command.

from_handler(*options, **kwargs)

Decorate async def command to create command class.

import_relative_to_app(attr)

Import string like "module.Model", or "Model" to model class.

on_stop()

Call after command executed.

on_worker_created(worker)

Call when creating faust.Worker to execute this command.

parse(argv)

Parse command-line arguments in argv and return mapping.

run()

Initialize the source topic used in the aggregation example.

run_using_worker(*args, **kwargs)

Execute command using faust.Worker.

say(message[, file, err])

Print something to stdout (or use file=stderr kwarg).

table(data[, title])

Format table data as ANSI/ASCII table.

tabulate(data[, headers, wrap_last_row, ...])

Create an ANSI representation of a table of two-row tuples.

to_key(typ, key)

Convert command-line argument string to model (key).

to_model(typ, value, serializer)

Convert command-line argument to model.

to_topic(entity)

Convert topic name given on command-line to app.topic().

to_value(typ, value)

Convert command-line argument string to model (value).

worker_for_service(service[, loop])

Create faust.Worker instance for this command.

Attributes Documentation

abstract: ClassVar[bool] = False
blocking_timeout

Return the blocking timeout used for this command.

builtin_options: OptionSequence = [<function version_option.<locals>.decorator>, option('--app', '-A', help='Path of Faust application to use, or the name of a module.'), option('--quiet/--no-quiet', '-q', default=False, help='Silence output to <stdout>/<stderr>.'), option('--debug/--no-debug', default=False, help='Enable debugging output, and the blocking detector.'), option('--no-color/--color', '--no_color/--color', default=False, help='Enable colors in output.'), option('--workdir', '-W', default=None, type=<click.types.Path object>, help='Working directory to change to after start.'), option('--datadir', '-D', default='{conf.name}-data', type=<click.types.Path object>, help='Directory to keep application state.'), option('--json', default=False, is_flag=True, help='Return output in machine-readable JSON format'), option('--loop', '-L', default='aio', type=Choice('['aio', 'eventlet', 'uvloop']'), help='Event loop implementation to use.'), option('--logfile', '-f', callback=<function compat_option.<locals>._callback>, expose_value=False, default=None, type=<click.types.Path object>, help='Path to logfile (default is <stderr>).'), option('--loglevel', '-l', callback=<function compat_option.<locals>._callback>, expose_value=False, default='WARN', type=Choice('['crit', 'error', 'warn', 'info', 'debug']'), help='Logging level to use.'), option('--blocking-timeout', callback=<function compat_option.<locals>._callback>, expose_value=False, default=10.0, type=<class 'float'>, help='when --debug: Blocking detector timeout.'), option('--console-port', callback=<function compat_option.<locals>._callback>, expose_value=False, default=50101, type=IntRange(1, 65535), help='when --debug: Port to run debugger console on.')]
console_port

Return the :pypi:`aiomonitor` console port.

daemon: bool = False
loglevel

Return the log level used for this command.

options: Optional[OptionList] = ()
prog_name: str = ''
redirect_stdouts: Optional[bool] = None
redirect_stdouts_level: Optional[int] = None
require_app = True

Methods Documentation

__call__(*args: Any, **kwargs: Any) NoReturn

Call command-line command.

This will raise SystemExit before returning, and the exit code will be set accordingly.

abbreviate_fqdn(name: str, *, prefix: str = '') str

Abbreviate fully-qualified Python name, by removing origin.

app.conf.origin is the package where the app is defined, so if this is examples.simple it returns the truncated:

>>> app.conf.origin
'examples.simple'
>>> abbr_fqdn(app.conf.origin,
...           'examples.simple.Withdrawal',
...           prefix='[...]')
'[...]Withdrawal'

but if the package is not part of origin it provides the full path:

>>> abbr_fqdn(app.conf.origin,
...           'examples.other.Foo', prefix='[...]')
'examples.other.foo'
classmethod as_click_command() Callable

Convert command into :pypi:`click` command.

as_service(loop: AbstractEventLoop, *args: Any, **kwargs: Any) ServiceT

Wrap command in a mode.Service object.

bold(text: str) str

Return text in bold.

bold_tail(text: str, *, sep: str = '.') str

Put bold emphasis on the last part of a foo.bar.baz string.

carp(s: Any, **kwargs: Any) None

Print something to stdout (or use file=stderr kwargs).

Note:

Does not do anything if the --debug option is enabled.

color(name: str, text: str) str

Return text having a certain color by name.

Examples::
>>> self.color('blue', 'text_to_color')
>>> self.color('hiblue', text_to_color')
See Also:

:pypi:`colorclass`: for a list of available colors.

dark(text: str) str

Return cursor text.

dumps(obj: Any) str

Serialize object using JSON.

async execute(*args: Any, **kwargs: Any) Any

Execute command.

classmethod from_handler(*options: Any, **kwargs: Any) Callable[[Callable], Type[AppCommand]]

Decorate async def command to create command class.

import_relative_to_app(attr: str) Any

Import string like “module.Model”, or “Model” to model class.

async on_stop() None

Call after command executed.

on_worker_created(worker: Worker) None

Call when creating faust.Worker to execute this command.

classmethod parse(argv: Sequence[str]) Mapping

Parse command-line arguments in argv and return mapping.

async run() None

Initialize the source topic used in the aggregation example.

run_using_worker(*args: Any, **kwargs: Any) NoReturn

Execute command using faust.Worker.

say(message: str, file: Optional[IO] = None, err: Optional[IO] = None, **kwargs: Any) None

Print something to stdout (or use file=stderr kwarg).

Note:

Does not do anything if the --quiet option is enabled.

table(data: Sequence[Sequence[str]], title: str = '', **kwargs: Any) BaseTable

Format table data as ANSI/ASCII table.

tabulate(data: Sequence[Sequence[str]], headers: Optional[Sequence[str]] = None, wrap_last_row: bool = True, title: str = '', title_color: str = 'blue', **kwargs: Any) str

Create an ANSI representation of a table of two-row tuples.

See Also:

Keyword arguments are forwarded to terminaltables.SingleTable

Note:

If the --json option is enabled this returns json instead.

to_key(typ: Optional[str], key: str) Any

Convert command-line argument string to model (key).

Arguments:

typ: The name of the model to create. key: The string json of the data to populate it with.

Notes:

Uses key_serializer to set the codec for the key (e.g. "json"), as set by the --key-serializer option.

to_model(typ: Optional[str], value: str, serializer: Optional[Union[CodecT, str]]) Any

Convert command-line argument to model.

Generic version of to_key()/to_value().

Arguments:

typ: The name of the model to create. key: The string json of the data to populate it with. serializer: The argument setting it apart from to_key/to_value

enables you to specify a custom serializer not mandated by key_serializer, and value_serializer.

Notes:

Uses value_serializer to set the codec for the value (e.g. "json"), as set by the --value-serializer option.

to_topic(entity: str) Any

Convert topic name given on command-line to app.topic().

to_value(typ: Optional[str], value: str) Any

Convert command-line argument string to model (value).

Arguments:

typ: The name of the model to create. key: The string json of the data to populate it with.

Notes:

Uses value_serializer to set the codec for the value (e.g. "json"), as set by the --value-serializer option.

worker_for_service(service: ServiceT, loop: Optional[AbstractEventLoop] = None) Worker

Create faust.Worker instance for this command.