markovchain.cli package¶
Submodules¶
markovchain.cli.image module¶
- class markovchain.cli.image.TraversalProgressWrapper(obj, channels, parent=None)[source]¶
Bases:
markovchain.util.ObjectWrapper
Traversal object wrapper.
Shows image traversal progress.
- pbar_parent¶
Parent progress bar.
- Type
tqdm.tqdm
- markovchain.cli.image.cmd_create(args)[source]¶
Create a generator.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.image.cmd_filter(args)[source]¶
Filter an image.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.image.cmd_generate(args)[source]¶
Generate images.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.image.cmd_update(args)[source]¶
Update a generator.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.image.create_arg_parser(parent)[source]¶
Create command subparsers.
- Parameters
parent (
argparse.ArgumentParser
) – Command parser.
- markovchain.cli.image.outfiles(markov, fmt, nfiles, progress, start=0)[source]¶
Get output file paths.
- Parameters
markov (
markovchain.base.MarkovBase
) – Markov chain generator.fmt (
str
) – File path format string.nfiles (
int
) – Number of files.progress (
bool
) – Show progress bars.start (
int
, optional) – Initial image level (default: 0).
- Returns
Output file paths.
- Return type
generator
ofstr
- markovchain.cli.image.read(fnames, markov, progress, leave=True)[source]¶
Read data files and update a generator.
- Parameters
fnames (
list
ofstr
) – File paths.markov (
markovchain.base.MarkovBase
) – Generator to update.progress (
bool
) – Show progress bar.leave (
bool
, optional) – Leave progress bars (default:True
).
markovchain.cli.main module¶
markovchain.cli.text module¶
- markovchain.cli.text.cmd_create(args)[source]¶
Create a generator.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.text.cmd_generate(args)[source]¶
Generate text.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.text.cmd_update(args)[source]¶
Update a generator.
- Parameters
args (
argparse.Namespace
) – Command arguments.
markovchain.cli.util module¶
- class markovchain.cli.util.NoProgressBar[source]¶
Bases:
object
Missing progress bar class.
- warning¶
True if a missing progress bar warning was printed.
- Type
bool
- warning = False¶
- markovchain.cli.util.check_output_format(fmt, nfiles)[source]¶
Validate file format string.
- Parameters
fmt (
str
) – File format string.nfiles (
int
) – Number of files.
- Raises
ValueError – If nfiles < 0 or format string is invalid.
- markovchain.cli.util.cmd_settings(args)[source]¶
Print generator settings.
- Parameters
args (
argparse.Namespace
) – Command arguments.
- markovchain.cli.util.infiles(fnames, progress, leave=True)[source]¶
Get input file paths.
- Parameters
fnames (
list
ofstr
) – File paths.progress (
bool
) – Show progress bar.leave (
bool
, optional) – Leave progress bar (default: True).
- Returns
Input file paths.
- Return type
generator
ofstr
- markovchain.cli.util.load(cls, fname, args)[source]¶
Load a generator.
- Parameters
cls (
type
) – Generator class.fname (
str
) – Input file path.args (
argparse.Namespace
) – Command arguments.
- Return type
cls
- markovchain.cli.util.no_tqdm(iterable=None, *args, **kwargs)[source]¶
Print a missing progress bar warning if it was not printed.
- Parameters
iterable (
iterable
orNone
, optional) – Iterable to decorate with a progress bar (default: None).- Return type
iterable
ormarkovchain.cli.util.NoProgressBar
- markovchain.cli.util.outfiles(fmt, nfiles, progress, leave=True)[source]¶
Get output file paths.
- Parameters
fmt (
str
) – File path format string.nfiles (
int
) – Number of files.progress (
bool
) – Show progress bars.leave (
bool
, optional) – Leave progress bar (default: True).
- Raises
ValueError – If nfiles <= 0.
- Returns
Output file paths.
- Return type
generator
ofstr
- markovchain.cli.util.pprint(data, indent=0, end='\n')[source]¶
Pretty print JSON data.
- Parameters
data – JSON data.
indent (
int
, optional) – Indent level in characters (default: 0).end (
str
, optional) – String to print after the data (default: ‘\n’).
- markovchain.cli.util.save(markov, fname, args)[source]¶
Save a generator.
- Parameters
markov (
markovchain.Markov
) – Generator to save.fname (
str
) – Output file path.args (
argparse.Namespace
) – Command arguments.